Changes between Version 63 and Version 64 of PythonOcc


Ignore:
Timestamp:
Oct 5, 2016, 9:52:08 AM (8 years ago)
Author:
mtelenta
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • PythonOcc

    v63 v64  
    392392
    393393}}}
     394
     395Risanje 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
     415import math
     416from OCC.gp import gp_Dir, gp_Pln, gp_Ax3, gp_XOY
     417from OCC.BRepPrimAPI import BRepPrimAPI_MakeBox
     418from OCC.BRepOffsetAPI import BRepOffsetAPI_DraftAngle
     419from OCC.Precision import precision_Angular
     420from OCC.BRep import BRep_Tool_Surface
     421from OCC.TopExp import TopExp_Explorer
     422from OCC.TopAbs import TopAbs_FACE
     423from OCC.Geom import Handle_Geom_Plane_DownCast
     424from OCC.TopoDS import topods_Face
     425
     426from OCC.Display.SimpleGui import init_display
     427display, start_display, add_menu, add_function_to_menu = init_display()
     428
     429
     430def 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
     447if __name__ == '__main__':
     448    draft_angle()
     449    start_display()
     450
     451}}}
    394452=== Izdelava primera Bottle z uporabo programskega jezika Python in knjižnice OCC ===
    395453Naslednji primer prikazuje izdelavo primera BottleCAD. Podrobnejši razdelek posameznih delov programske kode dobimo na [[http://trac.lecad.si/vaje/wiki/OpenCascade|MakeBottleCAD(C++)]].