Crashing when selecting BrepFace using createNewFaceContourSelection() on a setupInput Object

Crashing when selecting BrepFace using createNewFaceContourSelection() on a setupInput Object

Joshua.mursic
Advocate Advocate
582 Views
3 Replies
Message 1 of 4

Crashing when selecting BrepFace using createNewFaceContourSelection() on a setupInput Object

Joshua.mursic
Advocate
Advocate

Fusion is crashing when I select BrepFaces for boundaries on the setupInput object, but not when I select a sketch object.

 

 

 

import adsk.core, adsk.fusion, adsk.cam, traceback
app = adsk.core.Application.get()
ui = app.userInterface

def run(context):
    try:
        doc = app.activeDocument
        design:adsk.fusion.Design = doc.products.itemByProductType("DesignProductType")
        design.workspaces.itemById("FusionSolidEnvironment").activate()
        root = design.rootComponent
        #create new component and Brep Body
        occ = root.occurrences.addNewComponent(adsk.core.Matrix3D.create())
        s = occ.component.sketches.add(occ.component.xYConstructionPlane)
        s.sketchCurves.sketchLines.addTwoPointRectangle(adsk.core.Point3D.create(-0.5,-0.5,0),adsk.core.Point3D.create(0.5,0.5,0))
        extrudes = occ.component.features.extrudeFeatures
        exFeature = extrudes.addSimple(s.profiles.item(0),adsk.core.ValueInput.createByReal(1),adsk.fusion.FeatureOperations.NewBodyFeatureOperation)
        body = exFeature.bodies.item(0)
        body.name = "Body"

        #activate CAM
        ui.workspaces.itemById("CAMEnvironment").activate()
        cam:adsk.cam.CAM = doc.products.itemByProductType('CAMProductType')
        
        #Get the occurence and body in CAM workspace
        cadRoot = cam.designRootOccurrence.component
        occurrence = cadRoot.occurrences.item(0)
        stockBody = occurrence.component.bRepBodies.itemByName("Body")
        #get lowest face
        stockFaces = []
        for face in stockBody.faces:
            stockFaces.append(face)
        sortedList = sorted(stockFaces,key=lambda face: face.centroid.z) #default is ascending
        lowestFace:adsk.fusion.BRepFace = sortedList[0].createForAssemblyContext(occurrence)
        
        #create a new setup
        setups = cam.setups
        setupInput = setups.createInput(adsk.cam.OperationTypes.MillingOperation)
        setupInput.stockMode = adsk.cam.SetupStockModes.SolidStock
        setupInput.stockSolids = [stockBody]
        setup = setups.add(setupInput)
        #Create a new operation
        operations = setup.operations
        operationInput = operations.createInput("pocket_clearing")
        parameters = operationInput.parameters

        #Get the boundary parameter
        parameters.itemByName("boundaryMode").value.value = 'selection'
        boundary:adsk.cam.CadContours2dParameterValue = parameters.itemByName("machiningBoundarySel").value
        curveSels: adsk.cam.CurveSelections = boundary.getCurveSelections()
        
        # WORKS - set the sketch to be the boundary
        if False:
            sel = curveSels.createNewSketchSelection()
            sel.inputGeometry = [s]
            boundary.applyCurveSelections(curveSels)

        # WORKS - set the edges of the face to be the boundary
        if False:
            sel = curveSels.createNewChainSelection()
            sel.inputGeometry = [edge for edge in lowestFace.edges]
            boundary.applyCurveSelections(curveSels)

        # CRASH - set the face to be the boundary
        if True:
            sel = curveSels.createNewFaceContourSelection()
            sel.inputGeometry = [lowestFace]
            boundary.applyCurveSelections(curveSels)

        #add the operation to the setup
        operations.add(operationInput)
        
    except:
        ui.messageBox('Failed:\n{}'.format(traceback.format_exc()))

 

 

 

0 Likes
Accepted solutions (1)
583 Views
3 Replies
Replies (3)
Message 2 of 4

Joshua.mursic
Advocate
Advocate
Accepted solution

As a work around, you can select all the edges of the face and use the .createNewChainSelection() method. This works as expected.

0 Likes
Message 3 of 4

sameer_babarNJS6C
Autodesk
Autodesk

We have logged an issue FUS-173100 for it & we are looking for the solution .

 

Thanks,
Sameer Babar.
Autodesk Fusion Team

0 Likes
Message 4 of 4

Joshua.mursic
Advocate
Advocate

This also occurs with the createNewSilhouetteSelection() method, just in case that is not mentioned in FUS-173100

0 Likes