About adding parameters for filtering elements

About adding parameters for filtering elements

Anonymous
Not applicable
517 Views
4 Replies
Message 1 of 5

About adding parameters for filtering elements

Anonymous
Not applicable

I've been working on an exporter Addin project to export parameters (in .csv format) and obj of Revit elements. The export procedure chooses what element to export by filtering whether an element has the parameter whose name is 'Installation Sequence,' which doesn't exist in structure families (especially Precast Concrete families of Structural Columns) originally.

 

I've researched Revit document how to add a new parameter, and here's how I do it:

 

1. Load a family
2. Enter the menu by [Edit Family] -> [Family Types] (In the Properties tab of Create ribbon) -> [New parameter]
3. Set new parameter 'Installation Sequence.' Its specification is in the screenshot:

parameter-spec.PNG

In the source code of the exporter Addin, the filter for this parameter is:

 

 

IList<Element> filtered = new FilteredElementCollector(doc)
.OfClass(typeof(FamilyInstance))
.Where(a => a.LookupParameter("Installation Sequence")?.AsInteger() >= 0)
.ToList();

 

 

I've checked (and confirmed) it does export .obj and parameters properly.

 

I want to know:

 

1. In my situation, is it okay to set the parameter specification the way I'm using it?
2. Is there another (perhaps more practical) way to add parameters?

 

If you have any uncertainty, please let me know.

0 Likes
Accepted solutions (1)
518 Views
4 Replies
Replies (4)
Message 2 of 5

jeremy_tammik
Alumni
Alumni
Accepted solution

This is an interesting question with several possible aspects to address.

  

Family and shared parameters were originally designed for user interaction. Do you want your user to see and interact with the parameter value? If not, you could also consider using extensible storage instead:

 

https://thebuildingcoder.typepad.com/blog/about-the-author.html#5.23

   

You might also be able to use a shared parameter instead of a family parameter, depending on your specific needs.

 

You describe a manual approach to add the family parameter. That could also be automated, if you prefer.

 

Otherwise, afaict, your approach seems perfectly reasonable to me, so I would answer 'yes' and 'no' to your questions, off-hand.

  

Jeremy Tammik Developer Advocacy and Support + The Building Coder + Autodesk Developer Network + ADN Open
Message 3 of 5

guillain.jolivet
Contributor
Contributor

I think you have to do like you did. The rfa file must be modified, if you want the parameter to be for just one (or several) families but not for all families of a category. But you can try to automate this process.

 

Maybe you can try something like that :

  • Open the family (.rfa) document,
  • Reach the FamilyManager and add a parameter
  • Reload the family in your document

(I'm not sure about the loading part...)

 

//Get the rfa document
Document family_doc = main_doc.EditFamily(family_to_modify);

Transaction trans = new Transaction(family_doc, "Add family parameter");
trans.Start();
//Create the family parameter
family_doc.FamilyManager.AddParameter("Installation Sequence", BuiltInParameterGroup.INVALID, ParameterType.Integer, true);
// Reload the family in the main document
family_doc.LoadFamily(main_doc);
trans.Commit();



 

 

Message 4 of 5

Anonymous
Not applicable
I've never thought about automating the parameter addition. Thank you for your reply and insightful ideas.
0 Likes
Message 5 of 5

Anonymous
Not applicable
Thank you for the reply. Maybe I could improve my project using your suggestion about automation.
0 Likes