How to get a face from an intersection between two shapes

Hello,

I am trying to intersect two 3D shapes to get a common face and assign it to a group.

When I employ MakeSection (or MakeBoolean with parameter 4) like

section_intersect_lens_air = geompy.MakeSection(lens, air) or
section_intersect_lens_air = geompy.MakeBoolean(lens, air, 4)

I can add the result to the study

However, the result doesn’t seem to be a shape (contrastingly to what the docs mention).

Instead if check it type using the command below I get a BOOLEAN

print( section_intersect_lens_air )
print( type(section_intersect_lens_air) )
print( geompy.ShapeIdToType(section_intersect_lens_air.GetType()) )
<GEOM._objref_GEOM_Object object at 0x000001A800041320>
<class 'GEOM._objref_GEOM_Object'>
BOOLEAN

How can I get a shape/face from the intersection to assign it to a meshing group, which requires a shape as argument type?

*** EDIT ***

I found that it is possible to create a face from result of the intersection in the GUI with the ‘build Face’ command

image

However, I can’t seem to be able to create the face programmaticaly with any of the methods suggested in the docs

  # section_intersect_lens_air = geompy.MakeFaceFromSurface(geompy.MakeBoolean(lens, air, 4), True)
  # section_intersect_lens_air = geompy.MakeFaceWires([geompy.MakeBoolean(lens, air, 4)], 1) 
  # section_intersect_lens_air = geompy.MakeFace(geompy.MakeBoolean(lens, air, 4), True)

Many thanks,
Francisco

Hi,

you should use Partition to assemble your two 3D shapes. That will create the common face as a shared face. This will ensure a conform mesh.

Then you can get the common face with New Entity> Explode or Create Group. Or in python, get the face by GetInPlace (if you have already created the face as an independant shape) or GetFaceNearPoint (with a point located on the face). You will be able to create a group of mesh on it.

Christophe

1 Like

Thank you @cbourcier

I have been applying Partition to assemble the shapes and extracting Volumes and Faces with geompy.ExtractShapes. It worked well for the simple case in which two shapes share one faces.

However, one of the difficulties that I’m facing is when two shapes share dozens or even hundreds of faces. The list of objects from Extract Shapes that I get doesn’t seem to be ordered in a deterministic way - e.g. everytime the script loads, some of the faces/solids seem to have been assigned a different object id.

How can I manage object Ids in a systematic way? Should to keep stuctures with references to objects ? Can I make sure object ids are unique?

Thanks,
Francisco