Skip to content

Commit 3d35ea8

Browse files
committed
added work around for OCC conflict
1 parent a8edae3 commit 3d35ea8

File tree

1 file changed

+15
-1
lines changed

1 file changed

+15
-1
lines changed

assembly_mesh_plugin/plugin.py

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
import tempfile
2+
13
from OCP.TopoDS import TopoDS_Shape
24
import cadquery as cq
35
import gmsh
@@ -44,7 +46,19 @@ def assembly_to_gmsh(self, mesh_path="tagged_mesh.msh"):
4446
# All the solids in the current part should be added to the mesh
4547
for s in obj.moved(loc).Solids():
4648
# Add the current solid to the mesh
47-
gmsh.model.occ.importShapesNativePointer(s.wrapped._address())
49+
50+
with tempfile.NamedTemporaryFile(suffix=".brep") as temp_file:
51+
s.exportBrep(temp_file.name)
52+
gmsh.model.occ.importShapes(temp_file.name)
53+
54+
# TODO find a way to check if the OCC in gmsh is compatible with the
55+
# OCC in CadQuery. When pip installed they tend to be incompatible
56+
# and this importShapesNativePointer will seg fault. When both
57+
# packages are conda installed the importShapesNativePointer works.
58+
# Work around that works in both cases is to write a brep and import
59+
# it into gmsh. This is slower but works in all cases.
60+
# gmsh.model.occ.importShapesNativePointer(s.wrapped._address())
61+
4862
gmsh.model.occ.synchronize()
4963

5064
# All the faces in the current part should be added to the mesh

0 commit comments

Comments
 (0)