HoleFeature reference on selected face

HoleFeature reference on selected face

Anonymous
Not applicable
528 Views
1 Reply
Message 1 of 2

HoleFeature reference on selected face

Anonymous
Not applicable

I want to make simple app to make holes for shelfs, so the easy way would be Hole feature, rather then sketch and extrude.

Idea is to select face for holes, edge from front and top and also the edge on the back.

 

Thank you

Screenshot_2.jpg

 

 

import adsk.core, adsk.fusion, adsk.cam, traceback

def run(context):
    ui = None
    try:
        holeDepth = adsk.core.ValueInput.createByReal(1.2)        
        app = adsk.core.Application.get()
        ui  = app.userInterface
        design = app.activeProduct
        rootComp = adsk.fusion.Component.cast(design.rootComponent)
        sketches = rootComp.sketches
        extrudes = rootComp.features.extrudeFeatures
        faceSel = ui.selectEntity('Select a face', 'Faces')
        if faceSel:
            selectedFace = adsk.fusion.BRepFace.cast(faceSel.entity)
            Edge1Sel = ui.selectEntity('Select a edge', 'LinearEdges')
            selEdge = adsk.fusion.BRepEdge.cast(Edge1Sel.entity)
            holes = rootComp.features.holeFeatures
            holeinput = holes.createSimpleInput(holeDepth)
            # ? holeinput.setPositionOnEdge(selectedFace,selEdge,1)
            holeinput.setDistanceExtent(holeDepth)
            hole = holes.add(holeinput)
    except:
        if ui:
            ui.messageBox('Failed:\n{}'.format(traceback.format_exc()))

 

 

Screenshot_3.jpg

 

 

0 Likes
Accepted solutions (1)
529 Views
1 Reply
Reply (1)
Message 2 of 2

p.seem
Advocate
Advocate
Accepted solution

Have you seen the setPositionByPlaneAndOffsets methods of the holefeatureinput?  It's described here.  It looks like that might do what you want, using your selected face and pair of edges.  

 

Good luck,

 

PS

0 Likes