Skip to content

Instantly share code, notes, and snippets.

@inducer
Created July 21, 2012 05:48
Show Gist options
  • Save inducer/3154759 to your computer and use it in GitHub Desktop.
Save inducer/3154759 to your computer and use it in GitHub Desktop.
OpenCascade export bug
import OCC.gp as gp
import OCC.BRepPrimAPI as brep
import OCC.BRepAlgoAPI as brep_alg
import OCC.Utils.DataExchange.IGES as iges
import OCC.Utils.DataExchange.STEP as step
import OCC.Display.SimpleGui as gui
objs = []
for x in [0, 21]:
ax = gp.gp_Ax2(gp.gp_Pnt(x,0,0), gp.gp_Dir(0,1,0))
obj = brep.BRepPrimAPI_MakeTorus(ax, 10, 3).Shape()
objs.append(obj)
obj = brep_alg.BRepAlgoAPI_Fuse(*objs).Shape()
#obj = brep_alg.BRepAlgoAPI_Cut(*objs).Shape()
#obj = brep_alg.BRepAlgoAPI_Common(*objs).Shape()
if 0:
iges_writer = iges.IGESExporter("two-tori.igs")
iges_writer.add_shape(obj)
iges_writer.write_file()
iges_reader = iges.IGESImporter("two-tori.igs")
iges_reader.read_file()
read_obj, = iges_reader.get_shapes()
else:
step_writer = step.STEPExporter("two-tori.stp")
step_writer.add_shape(obj)
step_writer.write_file()
step_reader = step.STEPImporter("two-tori.stp")
step_reader.read_file()
read_obj, = step_reader.get_shapes()
display, start_display, add_menu, add_function_to_menu = gui.init_display()
display.DisplayShape(read_obj, update=True)
start_display()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment