2

I am attempting to assign options to a Revit OverrideGraphicsSettings:

OverrideGraphicSettings org = new OverrideGraphicSettings();
org.SetHalftone(true);
org.SetProjectionLineColor(Use_Color); org.SetProjectionFillColor(Use_Color);
org.SetProjectionFillPatternId(****);
doc.ActiveView.SetElementOverrides(ElementId Elem_Id, org);

This works, except for the following two problems:

  1. If I have already overridden in view to surface pattern from "By Material" to Solid Fill, the above code will DISABLE this override, returning it to By Material.
  2. The line with SetProjectionFillPatternId is disabled, because it isn't clear how to obtain a valid FillPatternId for Solid Fill.

My attempts at finding the answer include collection all defined materials and looping through them to find the Surface Pattern assigned, but I can't find the appropriate FillPatternId. Has anyone else dealt with this issue?

KeachyPeen
  • 147
  • 2
  • 13
  • 1
    Update: I did a collection of FillPatternElement and found the ElementId of the one named "Solid fill", and tried to put that in for the **** in the code above....this gave the error: – KeachyPeen Jul 15 '14 at 15:33
  • I was typing, and the site wouldn't let me edit...."The input argument 'fillpatternId' of function Autodesk::Revit::DB::OverrideGraphicSettings::SetProjectionFillPatternId is null" – KeachyPeen Jul 15 '14 at 15:36
  • 1
    Second update......there were two "ID" in the FillPatternElement. One was called UniqueId (which is the one that failed, and was a string). The other one was just Id, and that worked. Hope somebody else can benefit from my discovery. – KeachyPeen Jul 15 '14 at 15:53

1 Answers1

0

I may be 8 years too late. But here is the solution for people who read this later.

//CHANGE COLOR
string fillPatternName = "Wood 1"
Color color = new Color((byte)0, (byte)0, (byte)255);
OverrideGraphicSettings ogs = new OverrideGraphicSettings();
FillPatternElement fillPatternElement = FillPatternElement.GetFillPatternElementByName(doc, FillPatternTarget.Drafting, fillPatternName);
ogs.SetProjectionFillPatternId(fillPatternElement.Id);
ogs.SetProjectionFillColor(color);
uidoc.ActiveView.SetElementOverrides(ds.Id, ogs);
  • 1
    As it’s currently written, your answer is unclear. Please [edit] to add additional details that will help others understand how this addresses the question asked. You can find more information on how to write good answers [in the help center](/help/how-to-answer). – Community Jun 20 '22 at 20:50