StorageType for shared and project parameters

StorageType for shared and project parameters

r.polyakov.unkeng
Contributor Contributor
612 Views
5 Replies
Message 1 of 6

StorageType for shared and project parameters

r.polyakov.unkeng
Contributor
Contributor

Hi there

Is it possible to get the StorageType for all shared and project parameters without accessing the elements?
With system parameters, everything seems simple:

 

Array bps = Enum.GetValues(typeof(BuiltInParameter));

foreach (BuiltInParameter bp in bps)
{
   string name = LabelUtils.GetLabelFor(bp);
   StorageType sType = doc.get_TypeOfStorage(bp);
   ...
}

 


Is something similar possible for other parameter types? I tried to get this for SharedParameterElement , but I can only extract ExternalDefinition.

 

0 Likes
613 Views
5 Replies
Replies (5)
Message 2 of 6

Yien_Chao
Advisor
Advisor

hi

 

.Definition.Name doesn't work?

0 Likes
Message 3 of 6

RPTHOMAS108
Mentor
Mentor

I didn't find an API way for that however you can create a simple function for the purpose.

 

You would have to get the SpecTypeId first and go from there. I recently compiled this function that converts SpecTypeId to StotageType.

 

Solved: Re: Find storage type information of built-in parameter from its Id - Autodesk Community - R...

 

Where does this above come from? It comes from me creating a family with a parameter of every SpecTypeId possible and then checking the StorageType on each of such. As noted at the time the results were kind of obvious but not from the starting point.

 

Message 4 of 6

r.polyakov.unkeng
Contributor
Contributor
It works, but I need StorageType
0 Likes
Message 5 of 6

r.polyakov.unkeng
Contributor
Contributor
Ok, but what is the benefit of using SpecTypeId ? In the same way, you can match ParameterType
0 Likes
Message 6 of 6

RPTHOMAS108
Mentor
Mentor

ParameterType was replaced with SpecTypeId.

 

I believe your issue is that you want to get the storage type without accessing an element with that parameter. Similar to TypeOfStorage for BIPs?

 

For parameters that are shared (bound in project or in family) or non-shared project parameters you can get the ParameterElement object. For shared parameters you can use SharedParameterElement.Lookup. There is no alternative to SharedParameterElement.Lookup for non-shared project parameters so you have to filter for ParameterElements and find the one you want by name. Since ParameterElement is the base class to SharedParameterElement it is important to rule out SharedParameterElements when filtering for ParameterElements. I believe you can use a class filter for the base class combined with an inverted one for SharedParameterElement. This is important for when your shared parameters have the same names as some of your non-shared ones. As developers we can't rule out that possibility.

 

Once you have this associated ParameterElement you cannot get the StorageType from that directly but you can get the SpecTypeId via ParameterElement.GetDefinition.GetDataType (which can then can be used to find the StorageType via my original link).

 

It is important to note also that Definition.GetDataType may return a SpecTypeId that represents a category (in the case of parameters representing a family type). To rule such out you should use SpecUtils.IsSpec.

 

The only type of parameter this will not work for is non-shared family parameters and built-in parameters (since neither have a ParameterElement). So in the end the only type of parameter you will not be able to find the storage type of without first getting an instance of that parameter is the non-shared family parameter.

0 Likes