Revit API Forum
Welcome to Autodesk’s Revit API Forums. Share your knowledge, ask questions, and explore popular Revit API topics.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

How get width parametr of Family Symbol Revit API

4 REPLIES 4
SOLVED
Reply
Message 1 of 5
Anonymous
2360 Views, 4 Replies

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

How get width parametr of Family Symbol Revit API

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

Tags (1)
Labels (3)
4 REPLIES 4
Message 2 of 5
lukaskohout
in reply to: Anonymous

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.
======================================================================

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
in reply to: lukaskohout

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

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.

Message 4 of 5
lukaskohout
in reply to: Anonymous

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.
======================================================================

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
in reply to: Anonymous

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

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

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report