How to get all parameter choices in Revit?

How to get all parameter choices in Revit?

Anonymous
Not applicable
1,603 Views
7 Replies
Message 1 of 8

How to get all parameter choices in Revit?

Anonymous
Not applicable

There is an element's parameter that has like 5 choices (combobox's style). I know how to get the current selected one, but is there a way to retrieve the 4 other choices?

 

I have tried with GetValidTypes().

 

I've found this post for Revit 2010: http://stackoverflow.com/questions/4326106/how-to-get-all-parameter-choices-in-revit

But I can't make it work in Revit 2016/2017.

 

Thank you in advance.

 

Kind Regards.

1,604 Views
7 Replies
Replies (7)
Message 2 of 8

GonçaloFeio1321
Enthusiast
Enthusiast

Check if storageType is Integer. If so, the value is an enum.

I never found a table relating those BuiltInParameters and their corresponding enum Types.

Once you find the type, you can get the value by explicit casting, and the values using the static Enum methods.

 

Message 3 of 8

Anonymous
Not applicable

Thank you for your answer.

 

I have tried to make it work, but since there is no mapping table between de enums and the parameter that makes it hard.

I'll give you some more information. The parameters I would like to acces are family parameters and seems to be non Revit Standard parameters.

revit.png

 

Thank you in advance.

 

0 Likes
Message 4 of 8

GonçaloFeio1321
Enthusiast
Enthusiast

Those as family types, not enums. My mistake.

 

Get the family document with:

 

var document = familyInstance.Document;
var family = familyInstance.Symbol.Family;
var familyDocument = document.EditFamily(family);

Get the current value

 

 

var id = parameter.AsElementId();
var currentValue = familyDocument.GetElement(id);

Other values:

 

 

var validValues = new R.FilteredElementCollector(familyDocument).OfCategoryId(currentValue.Category.Id).OfClass(currentValue.GetType());

 

The last might need some extra checking, like valid types.

In case of nested shared families I guess this won't work, but that does not seem to be your case.

Message 5 of 8

Anonymous
Not applicable

Thank you for your information.

 

I think I'm getting very close.

 

My code:

if (m_parameter.StorageType == StorageType.ElementId && m_parameter.Definition.ParameterType == ParameterType.FamilyType)
            {
                FamilyInstance instance = m_parameter.Element as FamilyInstance;
                if (instance != null)
                {
                    var document = instance.Document;
                    Document familydoc = document.EditFamily(instance.Symbol.Family);
                    if (familydoc != null)
                    {
                        ElementId id = m_parameter.AsElementId();
                        Element currentValue = familydoc.GetElement(id);
                        Element currentValueDoc = doc.GetElement(id);
                     }
                }
            }

Every time I try to acces the currentValue in the familydoc, the result is null. The family document is loaded because the first time it takes a while, while the second time is very fast.

Now when I trie to get the currentValueDoc from my Revit Document it gives me the correct parameter with his current value. The type for the element is "NestedFamilyTypeReference" which is logic I presume.

 

So, am I doing something wrong accesing the element from my Family Document?

 

Thank you in advance.

0 Likes
Message 6 of 8

GonçaloFeio1321
Enthusiast
Enthusiast

Your currentValueDoc should only exist when using shared familIes, which does not seem to be the case.

0 Likes
Message 7 of 8

jeremytammik
Autodesk
Autodesk

Here is a recent discussion by The Building Coder of workarounds for drop-down enumerated parameter values:

 

http://thebuildingcoder.typepad.com/blog/2015/11/drop-down-enumerated-parameter-values.html

 

Cheers,

 

Jeremy



Jeremy Tammik
Developer Technical Services
Autodesk Developer Network, ADN Open
The Building Coder

Message 8 of 8

GonçaloFeio1321
Enthusiast
Enthusiast

Here is a tool I made some time ago to try to find out those parameters.

I found a few of them this way to use in a parameter adapter class, but soon gave up.

Not even with a lot of categories and instances in a project I could find every BuiltInParameter in use.

This image shows a match for the profile usage BuiltInParameter (Name from LabelUtils shown, not real name).

The listboxes and datagrids are not labeled, but you can guess what they are.

In the end, I would love to see a list from the factory itself, or in documented in the API types XML documentation.

 

 

epe.PNG

 

 

0 Likes