Forum Message

 

 

We have moved the forum to https://forum.ngsolve.org . This is an archived version of the topics until 05/05/23. All the topics were moved to the new forum and conversations can be continued there. This forum is just kept as legacy to not invalidate old links. If you want to continue a conversation just look for the topic in the new forum.

Notice

The forum is in read only mode.

Number of Faces on Imported Geometry

More
3 years 11 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
3 years 11 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.138 seconds