Greetings.
I have done quite a bit of searching and can not determine how to do this. I would like to open a family file (*.rfa) with the API, loading it into a Document object, and generate a report about the parameters in the family in the order in which they are presented in the UI (in the "Family Types" dialog).
The only promising method I can find in the API is the GetOrderedParameters method, but this method exists on the Element class, and I cannot determine which "Element" in the family editor API (family document) to use for calling this method.
For example, the document object itself does not cast to an Element, the Document.FamilyManager object does not cast to an Element and the Document.FamilyManager.CurrentType object does not cast to an Element. I was hoping maybe the Document.FamilyManager.Parameters object would cast to an Element, but it does not.
The FamilyParameter object does not seem to have a property like DisplayOrderIndex, nor does the FamilyParameter.Definition object.
How does one get a list of FamilyParameter objects in the same order in which they are presented to the user in the "Family Types" dialog? Is there some other method (not Element.GetOrderedParameters) that I should be using?
There are methods on the FamilyManger object for setting the order of the parameters, but I cannot determine the proper method or methods/workflow for reading back the order of the FamilyParameters in the family as the user sees them.
Thank you very much for any assistance!
Solved! Go to Solution.
Solved by matthew_taylor. Go to Solution.
Hi @CoderBoy,
According to the API reference,
FamilyManager.GetParameters Method remarks:
"The parameters are family built-in parameters, category built-in parameters and shared parameters associated to the family types.
The collection consists of both visible and invisible parameters associated to the family types.
The parameters are returned in the order in which they appear in the Revit UI within a given group; however, parameters of different groups may be mixed within this output.
Currently the Revit UI order is determined first by group and next by the order of the individual parameters."
As for the order of the groups? It looks like the parameters are actually exported in order AND in group order when a type catalogue is created.
Perhaps there's a way of harnessing that?
Cheers,
-Matt
You may very well be correct.
The code with which I am working is iterating over the FamilyManager.Parameters collection, like this:
foreach (FamilyParameter familyParameter in document.FamilyManager.Parameters)
but I will try this instead:
foreach (FamilyParameter familyParameter in document.FamilyManager.GetParameters())
The code with which I am working (extending) was originally written many years ago, like in the days of Revit 2010 or 2011. There may not have been a GetParameters method in existence when it was created.
Thanks for the tip!