Get Storage Type from BuiltInParameter

Get Storage Type from BuiltInParameter

franciscopossetto
Advocate Advocate
2,627 Views
10 Replies
Message 1 of 11

Get Storage Type from BuiltInParameter

franciscopossetto
Advocate
Advocate

I would like to get the type of element that is stored in certain parameters.

At this point, I just have the BuiltInParameter. I do not have elements in the model.

 

For example:

 

I have:

BuiltInParameter.LEVEL_PARAM 

 

and I would like to get:

Level

 

in order to create a collector like this:

new FilteredElementCollector(doc).OfClass(typeof(Level))

 

Thanks in advance.

Github:
https://github.com/franpossetto
0 Likes
Accepted solutions (1)
2,628 Views
10 Replies
Replies (10)
Message 2 of 11

joshua.lumley
Advocate
Advocate

Did you mean you would like to get the elements which have the BuiltInParameter.LEVEL_PARAM parameter?

Could you rephrase the question.

0 Likes
Message 3 of 11

franciscopossetto
Advocate
Advocate

Hi, Joshua.

I only need the type of object that will be stored in this parameter. In this sample, I add a collector because the next step that I want to do is check if certain parameter values exists in the model. I think the approach you mentioned in your reply could work as well.

 

Github:
https://github.com/franpossetto
0 Likes
Message 4 of 11

joshua.lumley
Advocate
Advocate

Alright, this is easy enough, used a switch conditional..

 

switch (myParameter.myStorageType) {
case StorageType.Double:
    break;
case StorageType.ElementId:
  break;
case StorageType.Integer:
  break;
case StorageType.None:
  break;
case StorageType.String:
  break;
}

 

 

0 Likes
Message 5 of 11

franciscopossetto
Advocate
Advocate

I am using this enumeration, but the problem is when I have other types. For Example, for parameters that store Levels, The storage type that I expect is "Autodesk.Revit.DB.Level". Because this parameter will contain an element which has this type.

Github:
https://github.com/franpossetto
0 Likes
Message 6 of 11

joshua.lumley
Advocate
Advocate

There are only 4 storage types in the same way there are only 3 subatomic particles (proton, neutron, electron).

 

Autodesk.Revit.DB.Level is a Class not a storage type. 

0 Likes
Message 7 of 11

franciscopossetto
Advocate
Advocate

Gotcha. Maybe I used the incorrect word to describe what I need to get.

Thanks.

Github:
https://github.com/franpossetto
0 Likes
Message 8 of 11

RPTHOMAS108
Mentor
Mentor
Accepted solution

If you are seeking what Element is the value of a parameter then the storage type will be ElementID.

 

You can't know what that value is until it is investigated. Sometimes you can make an educated guess by the form of BIP name. However beyond having a project containing everything possible and extracting class type names from elements associated with ElementIDs stored in parameters you can't know. That's a difficult task because you first have to know which built-in parameters are used in which element categories (if they are type or instance). Some BIP's are associated with multiple categories but you only have to find each BIP in one ElementType or Instance of one category.

 

What would be the reson you need this information because perhaps there is a better approach where you don't need to know.

 

 

0 Likes
Message 9 of 11

Revitalizer
Advisor
Advisor

Hi,

 

in the RevitAPI.chm, it says there is a Document.TypeOfStorage[BuiltInParameter] property.

 

There you are.

 

Revitalizer




Rudolf Honke
Software Developer
Mensch und Maschine





0 Likes
Message 10 of 11

franciscopossetto
Advocate
Advocate

Thanks for your answer. I think my question was not correctly written. The Answer above describes what I was needing, and it looks like, what I am needing is not possible to get.

 

Github:
https://github.com/franpossetto
0 Likes
Message 11 of 11

RPTHOMAS108
Mentor
Mentor

Another thing to consider is that Element is a base class for a lot of objects in the RevitAPI so you probably don't need it to be a Level until you know it is a Level i.e. you need to use it like a Level because Element doesn't have the member you require.

 

So if you wrote a function to return an Element from a parameter where the storage type is ElementID then that would cover a lot of things without casting to a subclass.  If you need to cast to a subclass it is because you know what subclass it is (in terms of how you want to use it).

 

If this is about presenting a list in a UI then use LabelUtils with the BuiltInParameter enum.

0 Likes