I was wondering to get section shape of column elements in dynamo and if I use getparameter node I am getting the integer value of values. I want to extract the data of section shape of columns. I want to convert “31” to “Rectangle”. I even checked with element.parameter node there I am getting section shape as “Rectangle” but if I check the values of the parameter then I get “31” for all.
So is there any way to get that through python?
Here is the sample:
@Draxl_Andreas I mean to say if I try to get the parameter value then I am getting Section shape parameter value as “31” not as Rectangle. I want it to get as rectangle.
@Nick_Boyts I have tried it but not getting this. The code follows as below
import clr
import sys
sys.path.append(r'C:\Program Files (x86)\IronPython 2.7\Lib')
import System
from System.Collections.Generic import *
clr.AddReference('ProtoGeometry')
from Autodesk.DesignScript.Geometry import *
clr.AddReference("RevitNodes")
import Revit
clr.ImportExtensions(Revit.Elements)
clr.ImportExtensions(Revit.GeometryConversion)
clr.AddReference("RevitServices")
import RevitServices
from RevitServices.Persistence import DocumentManager
from RevitServices.Transactions import TransactionManager
clr.AddReference("RevitAPI")
clr.AddReference("RevitAPIUI")
import Autodesk
from Autodesk.Revit.DB import *
from Autodesk.Revit.UI import *
doc = DocumentManager.Instance.CurrentDBDocument
uiapp = DocumentManager.Instance.CurrentUIApplication
app = uiapp.Application
uidoc = uiapp.ActiveUIDocument
def tolist(obj1):
if hasattr(obj1,"__iter__"): return obj1
else: return [obj1]
#Preparing input from dynamo to revit
elem = UnwrapElement(IN[0])
elem_param = elem.LookupParameter("Section Shape")
paramvalue = elem_param.AsString()
OUT = elem_param.AsString()
import clr
clr.AddReference('ProtoGeometry')
from Autodesk.DesignScript.Geometry import *
clr.AddReference('RevitAPI')
from Autodesk.Revit.DB import *
#The inputs to this node will be stored as a list in the IN variables.
if isinstance(IN[0], list):
element = UnwrapElement(IN[0])
else:
element = [UnwrapElement(IN[0])]
name = IN[1]
prefix = IN[2]
listout = []
if prefix == False:
formatOptions = FormatOptions()
formatOptions.UseDefault = False
formatOptions.UnitSymbol = UnitSymbolType.UST_NONE
def checkParameter(param):
for p in param:
internal = p.Definition
if internal.BuiltInParameter != BuiltInParameter.INVALID:
return p
return param[0]
for e in element:
param = e.GetParameters(name)
if len(param) == 0:
listout.append(None)
else:
p = checkParameter(param)
if p.StorageType == StorageType.String:
listout.append(p.AsString())
elif p.StorageType == StorageType.ElementId:
listout.append(p.AsValueString())
elif p.StorageType == StorageType.Integer:
listout.append(p.AsValueString())
else:
if prefix == False:
formatOptions.DisplayUnits = p.DisplayUnitType
listout.append(p.AsValueString(formatOptions))
else:
listout.append(p.AsValueString())
#Assign your output to the OUT variable.
OUT = listout