Skip to content

Commit 84d051c

Browse files
committed
Added draft angle example
1 parent 26120af commit 84d051c

File tree

1 file changed

+52
-0
lines changed

1 file changed

+52
-0
lines changed
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
##Copyright 2009-2015 Thomas Paviot ([email protected])
2+
##
3+
##This file is part of pythonOCC.
4+
##
5+
##pythonOCC is free software: you can redistribute it and/or modify
6+
##it under the terms of the GNU Lesser General Public License as published by
7+
##the Free Software Foundation, either version 3 of the License, or
8+
##(at your option) any later version.
9+
##
10+
##pythonOCC is distributed in the hope that it will be useful,
11+
##but WITHOUT ANY WARRANTY; without even the implied warranty of
12+
##MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13+
##GNU Lesser General Public License for more details.
14+
##
15+
##You should have received a copy of the GNU Lesser General Public License
16+
##along with pythonOCC. If not, see <http://www.gnu.org/licenses/>.
17+
18+
import math
19+
from OCC.gp import gp_Dir, gp_Pln, gp_Ax3, gp_XOY
20+
from OCC.BRepPrimAPI import BRepPrimAPI_MakeBox
21+
from OCC.BRepOffsetAPI import BRepOffsetAPI_DraftAngle
22+
from OCC.Precision import precision_Angular
23+
from OCC.BRep import BRep_Tool_Surface
24+
from OCC.TopExp import TopExp_Explorer
25+
from OCC.TopAbs import TopAbs_FACE
26+
from OCC.Geom import Handle_Geom_Plane_DownCast
27+
from OCC.TopoDS import topods_Face
28+
29+
from OCC.Display.SimpleGui import init_display
30+
display, start_display, add_menu, add_function_to_menu = init_display()
31+
32+
33+
def draft_angle(event=None):
34+
S = BRepPrimAPI_MakeBox(200., 300., 150.).Shape()
35+
adraft = BRepOffsetAPI_DraftAngle(S)
36+
topExp = TopExp_Explorer()
37+
topExp.Init(S, TopAbs_FACE)
38+
while topExp.More():
39+
face = topods_Face(topExp.Current())
40+
surf = Handle_Geom_Plane_DownCast(BRep_Tool_Surface(face)).GetObject()
41+
dirf = surf.Pln().Axis().Direction()
42+
ddd = gp_Dir(0, 0, 1)
43+
if dirf.IsNormal(ddd, precision_Angular()):
44+
adraft.Add(face, ddd, math.radians(15), gp_Pln(gp_Ax3(gp_XOY())))
45+
topExp.Next()
46+
adraft.Build()
47+
display.DisplayShape(adraft.Shape(), update=True)
48+
49+
50+
if __name__ == '__main__':
51+
draft_angle()
52+
start_display()

0 commit comments

Comments
 (0)