Number of Faces on Imported Geometry

More
4 years 6 months ago #2638 by jleman
After reading in a .step file with:
Code:
geo = OCCGeometry('someModel.step')

...is there a way to get the number of faces in the geometry?

After meshing I see in the documentation that one can use .GetNFaceDescriptors(), however I need the number of faces before meshing to set up meshing iterators.
More
4 years 6 months ago #2642 by jleman
If anyone has a more elegant/direct solution I would like to know, but in the meantime, this hack worked:

Code:
geo = OCCGeometry('someModel.step') #import step file #Find the number of faces using Python's try: except: else: feature for exception handling i=1 faces = 0 while i > 0: try: geo.SetFaceMeshsize(faces,1000) #try the set face mesh size function except: i = 0 #end while loop if index out of range error. Last value of 'faces' retained. else: faces += 1 #increment 'faces' if no error print(faces) #note, this returns the 'faces' + 1, which is needed for the range functions geo.SetFaceMeshsize(0,1000) #set mesh size for air boundary geo.SetFaceMeshsize(1,1000) #set mesh size for ground plane for surface in range(2,faces): #iterate through surfaces of cuboid geo.SetFaceMeshsize(surface,200) #set mesh size for cuboid surfaces ngmesh = geo.GenerateMesh(maxh = 1000,grading = 0.75)
Time to create page: 0.103 seconds