elem = UnwrapElement(IN[0])
x = []
gOpts = Options()
geom = elem.get_Geometry(gOpts)
for j in geom:
face = j.Faces
for f in face:
eId = f.MaterialElementId
mat = doc.GetElement(eId).Name
x.append(mat)
OUT = x
This still won’t work. It returns this error for me
AttributeError: ‘GeometryInstance’ object has no attribute ‘Faces’
I tried approach with “get_Geometry” and then using GetInstanceGeometry or GetSymbolGeometry, but then I would also receive error "no attribute ‘Faces’ " even if output of GetInstanceGeometry would be Autodesk.Revit.DB.Solid (which in API has property ‘Faces’…)
Just to add to it - i’m feeding this code with a Column type family consisting of couple of simple extrusions and 1 nested family also with extrusions only - so nothing that would prevent reading Faces normally.
Just to add to it - I have 3 different codes for this task, here are they below with errors that i’m stuck on.
So this one returns
AttributeError: ‘Face’ object has no attribute ‘MaterialElementId’
x = []
for i in IN[0].Faces:
x.append(i)
srf = UnwrapElement(x)
faces = []
for e in srf:
faces.append(e.Faces)
for f in faces:
for fac in f:
elementId = fac.MaterialElementId
mat = doc.GetElement(elementId).Name
And this one returns
AttributeError: ‘GeometryInstance’ object has no attribute ‘Faces’
elem = UnwrapElement(IN[0])
x = []
gOpts = Options()
geom = elem.get_Geometry(gOpts)
for j in geom:
face = j.Faces
for f in face:
eId = f.MaterialElementId
mat = doc.GetElement(eId).Name
x.append(mat)
OUT = x
And last one returns
AttributeError: ‘list’ object has no attribute ‘MaterialElementId’
x = []
for i in IN[0].Faces:
x.append(i)
srf = UnwrapElement(x)
faces = []
for e in srf:
faces.append(e.Faces)
elementlist = list()
for face in UnwrapElement(faces):
try:
ref = face.Tags.LookupTag("RevitFaceReference")
face = doc.GetElement(ref).GetGeometryObjectFromReference(ref)
elementlist.append(face)
except:
elementlist.append(list())
for c in elementlist:
c.MaterialElementId()
mat.append(c)
OUT = mat
@filip.kabelis you just need to get rid of the extra elements, such as the Geometry Instance and the Analytical Model, if you check a structural column family using the Revit Lookup, it shows where the appropriate Solid element is buried, maybe a conditional to get rid of the geometry instance and the empty solid would be better than getting the right solid by index:
@jacob.small - removing DScript geometry did not help
@Elie.Trad - Bingo! These aren’t Structural Columns so no need filtering out the analytical model, but pointing the right index in loop looking for material IDs finally returned valid results
thank you all guys, case closed
PS. I have a question - what does gOpts = Options() actually do in this code?