How get width parametr of Family Symbol Revit API

How get width parametr of Family Symbol Revit API

Anonymous
Not applicable
2,897 Views
4 Replies
Message 1 of 5

How get width parametr of Family Symbol Revit API

Anonymous
Not applicable

Hello. 

I have a problem with getting parameter width of Family Symbol. I searched all sheets in Revit LookUP. I searched on forums, but no result.

I need to get width of sybmol to placment it to correct point on the wall.

I try to use 

 e.get_Parameter()

from article    but it doesnt work on Revit 2019 API.

 

Pleas help.

2020-07-02_18-05-35.jpg

2020-07-02_18-08-56.jpg

2020-07-02_18-13-57.jpg

0 Likes
Accepted solutions (2)
2,898 Views
4 Replies
Replies (4)
Message 2 of 5

lukaskohout
Advocate
Advocate

Element.get_Parameter works only for internal or shared parameters. Your parameter looks like it is neither internal, neither shared  As you know the name of the parameter you want to get the value, try Element.LookupParameter(string parameterName), read carefuly the remarks below the method description:

https://www.revitapidocs.com/2020/4400b9f8-3787-0947-5113-2522ff5e5de2.htm

or safer way Element.GetParameters(string parameterName):

https://www.revitapidocs.com/2020/0cf342ef-c64f-b0b7-cbec-da8f3428a7dc.htm

 

First method retrieves all parameters with the given name and returns one randomly, second one will give you a IList<Parameter> which you will have to iterate through.

 


Hitting Accepted Answer is a Community Contribution from me as well as from you.
======================================================================
Message 3 of 5

Anonymous
Not applicable
Accepted solution

Thanks for answer!

I tried your way and unfortunately it doesn't help.

In both methods result null ( 

I looked for this parameter in Visual Studia debagger in a value and didt find any which looking like width of Symbol. 

2020-07-03_11-28-11.jpg

 

 Can be such a parameter have simbol at all there is no?

But Revit somehow takes the dimensions from the space of the sheet.

0 Likes
Message 4 of 5

lukaskohout
Advocate
Advocate
Accepted solution

Well, you should have your parameter name passed to the method ergo:

Element a = symbol as Element;
Parameter width_sym = a.LookupParameter("a1");

And from that you should get the value of parameter based on its StorageType. Since you probably know that the value is double, just use:

double value = width_sym.AsDouble();

 If you do not know the StorageType, then use:

switch (width_sym.StorageType)
{
    case StorageType.Double:
        double doubleValue = width_sym.AsDouble();
        // do your thing here

        break;
    case StorageType.Integer:
        int intValue = width_sym.AsInteger();
        // do your thing here

        break;
    case StorageType.ElementId:                    
        ElementId idValue = width_sym.AsElementId();
        // do your thing here

        break;
    case StorageType.String:
        string stringValue = width_sym.AsString();
        // do your thing here

        break;
}

 

 Please note that Parameter.AsValueString() returns parameter value as a string with units, like the user would see it.

https://www.revitapidocs.com/2020/5015755d-ee80-9d74-68d9-55effc60ed0c.htm

https://thebuildingcoder.typepad.com/blog/2019/04/batch-processing-and-aspects-of-asstringvalue.html...

 


Hitting Accepted Answer is a Community Contribution from me as well as from you.
======================================================================
Message 5 of 5

jeremytammik
Autodesk
Autodesk

Maybe the parameter is not an instance parameter, but a type parameter.

 

Do you know and understand the concepts of family, type and instance?

 

Instead of looking at the element's own personal parameters, look at its type's parameters.

 

RevitLookup will show them to you with no problem.

 

It can be a bit tricky to understand Revit, its family and BIM paradigms without any experience of using the product and working with BIMs from an end user perspective...

 



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