Hello everyone,
I’d like to get the surfaces by element (different level in list) from the Python Script node (the 3 nodes are the same code) :
import clr
clr.AddReference("RevitAPI")
import Autodesk
from Autodesk.Revit.DB import *
clr.AddReference("RevitNodes")
import Revit
clr.ImportExtensions(Revit.GeometryConversion)
clr.AddReference('RevitServices')
import RevitServices
from RevitServices.Persistence import DocumentManager
doc = DocumentManager.Instance.CurrentDBDocument
items = UnwrapElement(IN[0])
outsurfaces = []
opt = Options()
opt.IncludeNonVisibleObjects = False
opt.View = doc.ActiveView
for item in items:
geoEle=item.get_Geometry(opt)
if geoEle != None:
for geoInstance in geoEle:
if isinstance(geoInstance, GeometryInstance):
for symbIns in geoInstance.SymbolGeometry:
if isinstance(symbIns, Solid) and symbIns.Volume != 0:
solid = SolidUtils.CreateTransformed(symbIns,geoInstance.Transform)
for face in solid.Faces:
outsurfaces.extend(face.ToProtoType())
else:
pass
OUT = outsurfaces
Thank you.
Hi,
there must be more methodical
outsurfaces_stock,outsurfaces = [],[]
opt = Options()
opt.IncludeNonVisibleObjects = False
opt.View = doc.ActiveView
for item in items:
geoEle=item.get_Geometry(opt)
if geoEle != None:
for geoInstance in geoEle:
if isinstance(geoInstance, GeometryInstance):
for symbIns in geoInstance.SymbolGeometry:
if isinstance(symbIns, Solid) and symbIns.Volume != 0:
solid = SolidUtils.CreateTransformed(symbIns,geoInstance.Transform)
for face in solid.Faces:
outsurfaces_stock.extend(face.ToProtoType())
outsurfaces.append(outsurfaces_stock)
outsurfaces_stock=[]
else:
pass
OUT = outsurfaces
Sincerely
christian.stan
Thanks for your assistance, but unfortunatelly, this is not the result I expected.
With your code, I have 8 sublists.
But what I’m looking for, is to get 2 sublists (the first sublist with the 42 surfaces of the first element and the second sublist with the 15 surfaces of the second element (as shown in the previous screenshot)).
For example, if I have 15 elements, I should have 15 sublists.
I need to separate the surfaces by sublist (so there would be the same amount of sublists than elements) to know which surface belongs to which family.
Hi,
if you lower them in the loop at the geoinstance level
cf. figure
(I think this should work)
but I’m still babbling in python
edit: in any case there are people clearly more gifted than me to put you on the right track
Sincerely
christian.stan
Thank you for your help @christian.stan !
We’ll see if someone will optimize the code, but for now, it’s fine by me
1 Like
Hi you have the native Element.Faces
node (doesn’t give you the expected result or maybe you are training in python)
cordially
christian.stan
It doesn’t always work or it isn’t working with previous Revit versions.
oops, sorry
cordially
christian.stan