As an actual CAD user, I can say that any time I have ever needed to fillet an 
edge, I *always* select the edge from the screen.
I have worked out a small example showing how to do this and it is appended 
below.
I have noticed that emailing sometimes causes lines of code to get 
'piggybacked' , so you may have to fix them.
I am wondering if I am doing things the hard way or if someone can point me to 
a repository of useful code snippets
(beyond the excellent examples that come with pyOCC).
I would feel kind of silly to be reinventing the wheel...
As always, feedback is welcome...

-Doug

# file: mySelectableFillet.py

from OCC.BRepPrimAPI import *
from OCC.BRepFilletAPI import *
from OCC.TopoDS import *
from OCC.TopExp import * # It won't run without this
from OCC.Display.SimpleGui import *

display, start_display, add_menu, add_function_to_menu = init_display()

def box(event=None):
    global aBox
    display.EraseAll()
    aBox = BRepPrimAPI_MakeBox(20,50,50).Shape()
    display.DisplayShape(aBox)
    display.FitAll()

def selectEdge(event=None):
    display.SetSelectionModeEdge()

def filletEdge(event=None):
    display.SetSelectionModeShape()
    aShape = display.GetSelectedShape()
    print type(aShape)
    anEdge = TopoDS.TopoDS().edge(aShape)
    print type(anEdge)
    fillet = BRepFilletAPI_MakeFillet(aBox)
    fillet.Add(4, anEdge)
    bBox = fillet.Shape()
    display.EraseAll()
    display.DisplayShape(bBox)
    display.FitAll()
    print 'Done'

def exit(event=None):
    sys.exit()

if __name__ == '__main__':
    add_menu('click in sequence')
    add_function_to_menu('click in sequence', box)
    add_function_to_menu('click in sequence', selectEdge)
    add_function_to_menu('click in sequence', filletEdge)
    add_function_to_menu('click in sequence', exit)
    start_display()
_______________________________________________
Pythonocc-users mailing list
Pythonocc-users@gna.org
https://mail.gna.org/listinfo/pythonocc-users

Reply via email to