By Joe Ye
In the Revit UI of the family editor, you can set the OmniClass value using the "Category and Parameters" button on the Manage tab.I'm having great difficulty figuring out how to do this via API.For example, with code I want to set the OmniClass on the family to: 126.96.36.199.37.
There are a number of other settings on that GUI dialog (particularly Family Category) that would be nice to be able to change as well.
These parameters value such as 'Omniclass value' and 'Omniclass Title', can be changed programmatically. These parameters belong to owner family that this family document indicates. The parameters cannot be obtained by FamilyManager.get_Parameter(BuiltInParameter.OMNICLASS_CODE).
You can get the owner family by calling Document.OwnerFamily property .
With regard to changing the owner family's category, there is no exposed API to do it. An API wish was logged for this request.
Here is the code fragment showing how to change the OminiClass value.
public IExternalCommand.Result Execute(
ref string messages, ElementSet elements)
Application app = commandData.Application.Application;
Document doc = app.ActiveDocument;
//get the current family
Family thisFamily = null;
if (doc.IsFamilyDocument == true)
thisFamily = doc.OwnerFamily;
if (thisFamily != null)
Parameter parOmniclass = thisFamily.get_Parameter(