Community
Fusion API and Scripts
Got a new add-in to share? Need something specialized to be scripted? Ask questions or share what you’ve discovered with the community.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Pocket 2d operation causes Fusion 360 to crash

4 REPLIES 4
SOLVED
Reply
Message 1 of 5
omedvydskiy
249 Views, 4 Replies

Pocket 2d operation causes Fusion 360 to crash

Hi, I am creating a 2d pocket operation for my setup and it cause the Fusion 360 crash. I am trying to add selected face (Planar face with id 52) as a pocket selection to the pocket operation.

It crashes on line "pocketSel.inputGeometry = [face]"

The same via UI looks successful.

 

    input = setup.operations.createInput('pocket2d')
    input.tool = tool  
    input.displayName = 'Pocket 2D'

    # Get the "pockets" parameter from the operation, which is a CAD Contour 2D.
    # The name of the parameter will vary depending on the type of operation.
    contourParam: adsk.cam.CadContours2dParameterValue = input.parameters.itemByName('pockets').value

    # Get the CurveSelections object from the CAD contour. This
    # object manages the list of contour selections.
    curveSelections = contourParam.getCurveSelections()

    # Create a new pocket selection.
    pocketSel: adsk.cam.PocketSelection = curveSelections.createNewPocketSelection()

    # Set some properties of pocket contour.
    pocketSel.isSelectingSamePlaneFaces = False

    # Add the selected face to the face contour.
    pocketSel.inputGeometry = [face]

    # Apply the curve selection back to the parameter.
    contourParam.applyCurveSelections(curveSelections)
 
    op = setup.operations.add(input)

omedvydskiy_0-1691400688549.png

4 REPLIES 4
Message 2 of 5
kandennti
in reply to: omedvydskiy

Hi @omedvydskiy -San.

 

Similar errors have been reported in the past.

https://forums.autodesk.com/t5/fusion-360-api-and-scripts/fusion-cam-api-pocket2d-input-parameter-er... 


Currently the only way seems to be to use CurveSelection.

・・・
    # Get the CurveSelections object from the CAD contour. This
    # object manages the list of contour selections.
    curveSelections = contourParam.getCurveSelections()

    # Create a new pocket selection.
    # pocketSel: adsk.cam.PocketSelection = curveSelections.createNewPocketSelection()

    # Set some properties of pocket contour.
    # pocketSel.isSelectingSamePlaneFaces = False

    # Add the selected face to the face contour.
    # pocketSel.inputGeometry = [face]

    # Select Face Edge.
    chain: adsk.cam.CurveSelection = curveSelections.createNewChainSelection()
    chain.isReverted = True
    chain.inputGeometry = [face.edges[0]]

    # Apply the curve selection back to the parameter.
    contourParam.applyCurveSelections(curveSelections)
・・・
Message 3 of 5
omedvydskiy
in reply to: kandennti

Thank you for your reply.
Message 4 of 5
echatzief
in reply to: kandennti

Hi Kandennti, hope you're doing great!

I noticed in line 17 you're setting the reversion of the chain selection to True, using the isReverted method from the api, but how can one tell if it be True since it only depends on Fusion's guess (see image attached) ?

Thank you!

 

Message 5 of 5
kandennti
in reply to: echatzief

@echatzief -San.

 

I simply ran the test code and ture the isReverted method because it was the other side.
Perhaps there are some rules, but I have not looked into them.

 

Since the April update, I feel that the CAM API has added enough functionality for automation.
I feel that now we need a technique to find and determine the required geometry in CAD.

 

Also, in this case, I think it is possible to get the same results by using a 3D Pocket instead of a 2D Pocket.
In the case of the 3D Pocket, the CAD data geometry is automatically used to make decisions, which should make it easier to think about the area.
In this regard, the choice of operation should also be important.

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk DevCon in Munich May 28-29th


Autodesk Design & Make Report