Override graphics settings in DirectShape objects

Override graphics settings in DirectShape objects

Anonymous
Not applicable
2,644 Views
2 Replies
Message 1 of 3

Override graphics settings in DirectShape objects

Anonymous
Not applicable

Hi Guys, 

 

I am overriding the graphics settings for each of my DirectShape objects I seem to be able to only control the color of the lines, but I can't get access to actually changing the color of the surfaces which I also need, only their transparency. 

 

The only way I could do it is  via the Revit UI  is there any way I can change the forground pattern to solid via the API?

 

Capture.PNG

 

here is my code:

 

´´´
 for (int i = 0; i < solids.Count; i++)
            {
               
                DirectShape ds = DirectShape.CreateElement(doc, category);
                ds.ApplicationId = id_addin;
                ds.ApplicationDataId = areaObjects[i].UniqueId;
                IList<GeometryObject> list = new List<GeometryObject>();
                GeometryObject g = solids[i] as GeometryObject;
                list.Add(g);
            
                ds.SetShape(list);
Color color = new Color(255, 0, 0); OverrideGraphicSettings overrideGS = new OverrideGraphicSettings(); overrideGS.SetProjectionLineColor(color); overrideGS.SetSurfaceForegroundPatternColor(color); overrideGS.SetSurfaceBackgroundPatternColor(color); overrideGS.SetSurfaceForegroundPatternVisible(true); overrideGS.SetSurfaceTransparency(35); overrideGS.SetCutLineColor(color); doc.ActiveView.SetElementOverrides(ds.Id, overrideGS);
ds.Name = "Area volume for " + areaObjects[i].Name; } ´´´

Any hints would be great,

 

Thanks in advance

0 Likes
2,645 Views
2 Replies
Replies (2)
Message 2 of 3

jeremytammik
Autodesk
Autodesk

The best way to control the direct shape graphic settings is probably via its category, cf. 

 

https://thebuildingcoder.typepad.com/blog/2018/01/directshape-topics-and-happy-new-year.html#7

 



Jeremy Tammik
Developer Technical Services
Autodesk Developer Network, ADN Open
The Building Coder

0 Likes
Message 3 of 3

Anonymous
Not applicable

@jeremytammik  thanks again for getting back! 

 

When I create my Direct Shape geometry as a  Generic Mass Category, under its properties palette it does not have a Material and Finishes Parameter,  the option to click Edit Type is grayed out  and even  the Edit In-Place button does not appear under the Modify | Generic Models ribbon. In Addition, what I do get instead is some sort of default structural property and a Rebar button replacing the Edit In-Place button. 

 

In contrast I modeled by hand a simple extrusion in Revit and I put it under the the Generic Mass Category as well. This element does have all the missing parts that my direct shape lacks

 

DirectoShape_MissingEditParams.PNG

 

Created GenericM in Revit.PNG

 

So if I try to access the Direct Shapes Material Parameter via   

 

var p =  ds.get_Parameter(BuiltInParameter.MATERIAL_ID_PARAM);

p in this case will always be null because the material parameter does not exist.

 

so doing

 

Set(material.Id);

will not be possible.

 

 

Another method I tried was to create a Shared Parameter file. The first step works, in the sense that I do get a Material parameter in the properties pallete. But it does not fully work because I cant Edit In-Place my Direct Shape to succesfully make  a change in its Material.

 

Do you have any idea what could be wrong?

 

Thanks again for your time

0 Likes