| | 394 | |
| | 395 | Risanje prerezane piramide. |
| | 396 | [[Image(edge_primer.PNG, width=480px, right)]] |
| | 397 | {{{ |
| | 398 | ##Copyright 2009-2015 Thomas Paviot (tpaviot@gmail.com) |
| | 399 | ## |
| | 400 | ##This file is part of pythonOCC. |
| | 401 | ## |
| | 402 | ##pythonOCC is free software: you can redistribute it and/or modify |
| | 403 | ##it under the terms of the GNU Lesser General Public License as published by |
| | 404 | ##the Free Software Foundation, either version 3 of the License, or |
| | 405 | ##(at your option) any later version. |
| | 406 | ## |
| | 407 | ##pythonOCC is distributed in the hope that it will be useful, |
| | 408 | ##but WITHOUT ANY WARRANTY; without even the implied warranty of |
| | 409 | ##MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| | 410 | ##GNU Lesser General Public License for more details. |
| | 411 | ## |
| | 412 | ##You should have received a copy of the GNU Lesser General Public License |
| | 413 | ##along with pythonOCC. If not, see <http://www.gnu.org/licenses/>. |
| | 414 | |
| | 415 | import math |
| | 416 | from OCC.gp import gp_Dir, gp_Pln, gp_Ax3, gp_XOY |
| | 417 | from OCC.BRepPrimAPI import BRepPrimAPI_MakeBox |
| | 418 | from OCC.BRepOffsetAPI import BRepOffsetAPI_DraftAngle |
| | 419 | from OCC.Precision import precision_Angular |
| | 420 | from OCC.BRep import BRep_Tool_Surface |
| | 421 | from OCC.TopExp import TopExp_Explorer |
| | 422 | from OCC.TopAbs import TopAbs_FACE |
| | 423 | from OCC.Geom import Handle_Geom_Plane_DownCast |
| | 424 | from OCC.TopoDS import topods_Face |
| | 425 | |
| | 426 | from OCC.Display.SimpleGui import init_display |
| | 427 | display, start_display, add_menu, add_function_to_menu = init_display() |
| | 428 | |
| | 429 | |
| | 430 | def draft_angle(event=None): |
| | 431 | S = BRepPrimAPI_MakeBox(200., 300., 150.).Shape() |
| | 432 | adraft = BRepOffsetAPI_DraftAngle(S) |
| | 433 | topExp = TopExp_Explorer() |
| | 434 | topExp.Init(S, TopAbs_FACE) |
| | 435 | while topExp.More(): |
| | 436 | face = topods_Face(topExp.Current()) |
| | 437 | surf = Handle_Geom_Plane_DownCast(BRep_Tool_Surface(face)).GetObject() |
| | 438 | dirf = surf.Pln().Axis().Direction() |
| | 439 | ddd = gp_Dir(0, 0, 1) |
| | 440 | if dirf.IsNormal(ddd, precision_Angular()): |
| | 441 | adraft.Add(face, ddd, math.radians(15), gp_Pln(gp_Ax3(gp_XOY()))) |
| | 442 | topExp.Next() |
| | 443 | adraft.Build() |
| | 444 | display.DisplayShape(adraft.Shape(), update=True) |
| | 445 | |
| | 446 | |
| | 447 | if __name__ == '__main__': |
| | 448 | draft_angle() |
| | 449 | start_display() |
| | 450 | |
| | 451 | }}} |