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.
Solved! Go to Solution.
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.
Solved! Go to Solution.
Solved by lukaskohout. Go to Solution.
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.
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.
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.
Can be such a parameter have simbol at all there is no?
But Revit somehow takes the dimensions from the space of the sheet.
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.
Can be such a parameter have simbol at all there is no?
But Revit somehow takes the dimensions from the space of the sheet.
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
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
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...
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...
Can't find what you're looking for? Ask the community or share your knowledge.