diff --git a/src/Libraries/RevitNodes/Elements/Element.cs b/src/Libraries/RevitNodes/Elements/Element.cs index 82d698ca7..26fbcc5d9 100644 --- a/src/Libraries/RevitNodes/Elements/Element.cs +++ b/src/Libraries/RevitNodes/Elements/Element.cs @@ -377,7 +377,7 @@ public object GetParameterValueByName(string parameterName) /// /// Override the element's color in the active view. /// - /// The color to apply to a solid fill on the element. + /// The color to apply to a solid fill and projection lines on the element. public Element OverrideColorInView(Color color) { TransactionManager.Instance.EnsureInTransaction(DocumentManager.Instance.CurrentDBDocument); @@ -398,7 +398,47 @@ public Element OverrideColorInView(Color color) TransactionManager.Instance.TransactionTaskDone(); return this; } + + /// + /// Override only the element's surface color in the active view. + /// + /// The color to apply to a solid fill on the element. + public Element OverrideSurfaceColorInView(Color color) + { + TransactionManager.Instance.EnsureInTransaction(DocumentManager.Instance.CurrentDBDocument); + var view = DocumentManager.Instance.CurrentUIDocument.ActiveView; + var ogs = view.GetElementOverrides(InternalElementId); + + var patternCollector = new FilteredElementCollector(DocumentManager.Instance.CurrentDBDocument); + patternCollector.OfClass(typeof(FillPatternElement)); + FillPatternElement solidFill = patternCollector.ToElements().Cast().First(x => x.GetFillPattern().IsSolidFill); + + var overrideColor = new Autodesk.Revit.DB.Color(color.Red, color.Green, color.Blue); + ogs.SetProjectionFillColor(overrideColor); + ogs.SetProjectionFillPatternId(solidFill.Id); + view.SetElementOverrides(InternalElementId, ogs); + + TransactionManager.Instance.TransactionTaskDone(); + return this; + } + + /// + /// Reset the element's overrides in the active view. + /// + public void ResetViewOverrides() + { + TransactionManager.Instance.EnsureInTransaction(DocumentManager.Instance.CurrentDBDocument); + + var view = DocumentManager.Instance.CurrentUIDocument.ActiveView; + + var ogs = new OverrideGraphicSettings(); + + view.SetElementOverrides(InternalElementId, ogs); + + TransactionManager.Instance.TransactionTaskDone(); + } + /// /// Set one of the element's parameters. ///