After reading in a .step file with:
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.
If anyone has a more elegant/direct solution I would like to know, but in the meantime, this hack worked:
geo = OCCGeometry('someModel.step') #import step file
#Find the number of faces using Python's try: except: else: feature for exception handling
faces = 0
while i > 0:
geo.SetFaceMeshsize(faces,1000) #try the set face mesh size function
i = 0 #end while loop if index out of range error. Last value of 'faces' retained.
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)