可以和前面例子剪切的图比较.
代码: 全选
from OCC.Display.SimpleGui import *
from OCC.BRepPrimAPI import *
from OCC.BRepAlgoAPI import *
from OCC.BRepBuilderAPI import *
from OCC.gp import *
display, start_display, add_menu, add_function_to_menu = init_display()
my_box = BRepPrimAPI_MakeBox(10.,20.,30.).Shape()
my_cube = BRepPrimAPI_MakeBox(5.,10.,10.).Shape()
# Define transformation
theTransformation = gp_Trsf()
from_pnt = gp_Pnt(0.,0.,0.)
to_pnt= gp_Pnt(5.,10.,15.)
theTransformation.SetTranslation(from_pnt,to_pnt);
# Apply transformation
myBRepTransformation = BRepBuilderAPI_Transform(my_cube,theTransformation)
my_cube_moved = myBRepTransformation.Shape()
aShape = BRepAlgoAPI_Cut(my_box,my_cube_moved).Shape()
display.DisplayShape(aShape)
start_display()