Today is the day of the Chinese Revit API webcast, and also the holiday of Ascension Day in many part of Europe. Just like last year, it is raining cats and dogs again.
Anyway, here is a useful answer to a little question that arises from time to time:
Question: I'm creating a new 3D view of a family instance like this:
Dim v As View3D = doc.Create.NewView3D( _ famInst.FacingOrientation) v.SectionBox = famInst.BoundingBox(v)
Now I would like to set its visual style to 'Shaded' or 'Shaded with Edges'.
Is there any way to achieve this using the API?
Answer: The view style can be changed by modifying the value of the 'Visual Style' parameter, which corresponds to the built-in parameter MODEL_GRAPHICS_STYLE. Each option in the 'Visual Style' property drop-down list in the property dialog corresponds to an integer value from 0 to 6:
In order to change the visual style to 'Shaded with edges', please set the parameter value to 4, for instance like this:
view.get_Parameter(
BuiltInParameter.MODEL_GRAPHICS_STYLE )
.set( 4 );
These numbers may have changed since they were first established. You can determine the correct numbers to use yourself by simply cycling through all the styles manually and checking the current parameter value as an integer each time, e.g. using the RevitLookup tool.
The technology preview 2 of the conceptual design and analysis tool Project Vasari, which includes access to the Revit API, is now available in an updated version compatible with Revit 2012: