- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hello
I am trying to create a plugin which creates a new parameter under the Parameter Group 'Identity Data' of a specific Family.
I have done this before but I created a new parameter for all families under the Plates Category and so I adapted its script.
First, I am trying to create the parameter named "Marca" on all instances of the Mechanical Equipment Category (later I will try to do so just for the Family Type 'TPF-Pump').
However, I get the following error, where the Definition 'FamilyParamDef' became null.
Any ideas on why this is happening?
Any help would be appretiated.
The code was based on the Building Coder Sample
https://forums.autodesk.com/t5/revit-api-forum/shared-parameter-to-assign-to-elements/td-p/8455214
//test for one parameter string paramName = "Marca"; // cache application handle Autodesk.Revit.ApplicationServices.Application revitApp = commandData.Application.Application; // open shared parameter file DefinitionFile parafile = revitApp.OpenSharedParameterFile();
// get a group DefinitionGroup apiGroup = parafile.Groups.get_Item("Identity Data"); // get ParamName Definition FamilyParamDef = apiGroup.Definitions.get_Item(paramName); // get Mechanical Equipment category Category FamilyCat = commandData.Application.ActiveUIDocument.Document.Settings.Categories.get_Item(BuiltInCategory.OST_MechanicalEquipment); CategorySet categories = revitApp.Create.NewCategorySet(); categories.Insert(FamilyCat); // insert the new parameter InstanceBinding binding = revitApp.Create.NewInstanceBinding(categories); commandData.Application.ActiveUIDocument.Document.ParameterBindings.Insert(FamilyParamDef, binding, BuiltInParameterGroup.PG_DATA);
Solved! Go to Solution.