Hi,
Im trying to read a Type parameter from a revit object (structural framing) using the API. The (shared) parameter I
m trying to read is a dimension concerning the width of a concrete beam. I can find the parameter with the below code. But didn`t manage to get a read of the value. Can anyone help with this?
Param_Typ = Vloerrandbalk_Type.Parameters
for i in Param_Typ:
if “OPL_breedte” in i.Definition.Name: pass
Once you get the parameter you’re looking for you need to get the associated value using one of the following methods:
Thanks. That solved it.
To get the type parameter value of the width you need to add .AsDouble() to the parameter. Is there also a method to get the parameter value directly?
TransactionManager.Instance.EnsureInTransaction(doc)
Vloerrandbalk = doc.Create.NewFamilyInstance(Lijn_Rvt, Ligger_Rvt, Level_Rvt, Structure.StructuralType.Beam)
TransactionManager.Instance.TransactionTaskDone()
Vloerrandbalk_Type = doc.GetElement(Vloerrandbalk_Type_Id)
Param_Typ = Vloerrandbalk_Type.Parameters
for i in Param_Typ:
if “OPL_breedte” in i.Definition.Name: value = i.AsDouble()*304.8])
What do you mean? You get the value directly from the parameter.
I mean that the script first gets a list of all type parameters then looks for the parameter name in the list thats needed and then obtains the value. It seems a bit like a workaround.
Maybe it is also possible to get the value directly from the parameter without first listing all parameters and looping through the names. I can imagine it could also work like a dictionary.
I tried the lookup method but that doesnt seem to work.
You tried LookupParameter()
? That would be the only other option besides GetParameter()
, which is specific to 2022 and requires the ForgeTypeId
of the parameter. Parsing the element parameters one by one isn’t bad practice though, it’s relatively light.