pythonocc例子12-移动形体

OOo,TeX,KO,ABI,GIMP,Picasa,ProE,QCAD,Inkscape,Kicad,Eagle
回复
shirazbj
帖子: 333
注册时间: 2010-01-30 18:38

pythonocc例子12-移动形体

#1

帖子 shirazbj » 2010-07-16 12:15

先生成my_cube, 然后移动到指定点.

可以和前面例子剪切的图比较.

代码: 全选

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()
附件
move.JPG
免费NanoCAD=免费DraftSight+可API编程(用.net或者vbs和java脚本)=白白 AutoCAD
http://nanocad.com/
头像
YZMSQ
帖子: 575
注册时间: 2009-06-01 10:48
来自: 杭州

Re: pythonocc例子12-移动形体

#2

帖子 YZMSQ » 2010-07-16 18:49

好神奇啊,学习了! :em11
Linux/Unix命令行手册:Unix Toolbox
一位坛友推荐的学习Linux/Unix的好书:传送门
A life without passion resembles the shadow from a grave.
回复