Catastrophic error occurred in API function call

Catastrophic error occurred in API function call

karolis.s
Advocate Advocate
484 Views
2 Replies
Message 1 of 3

Catastrophic error occurred in API function call

karolis.s
Advocate
Advocate

Hello, I am playing with the new capabilities of Fusion 360 CAM API.

I don't understand why I get this error message, I looked at examples of how to retrieve this parameter at least several times. I can't see what I did wrong here.

 

Error message:

karoliss_0-1684174308863.png

Here is a proof I have valid template file:

karoliss_1-1684174479402.png

Source code:

#Author-
#Description-

import adsk.core, adsk.fusion, adsk.cam, traceback, os
camOptemplateSource = 'C:\\Users\\kkriv\\AppData\\Roaming\\Autodesk\\CAM360\\templates\\'

def run(context):
    ui = None
    try:
        app = adsk.core.Application.get()
        ui  = app.userInterface

        cam: adsk.cam.CAM = app.activeDocument.products.itemByProductType('CAMProductType')
        camOcc = cam.designRootOccurrence
        body = camOcc.bRepBodies[0]
        cam: adsk.cam.CAM = cam

        setups = cam.setups
        # Create a SetupsInput object to define a milling setup.
        setupInput = setups.createInput(adsk.cam.OperationTypes.MillingOperation)
        setupInput.models = [body]

        setupInput.name = 'DEBUG'
        setup = setups.add(setupInput)
        orientationParam = setup.parameters.itemByName('wcs_orientation_mode')
        choiceVal: adsk.cam.ChoiceParameterValue = orientationParam.value
        choiceVal.value = 'axesZX'

        originPoint = setup.parameters.itemByName('wcs_origin_boxPoint')
        choiceVal: adsk.cam.ChoiceParameterValue = originPoint.value
        choiceVal.value = 'center'

        template = getTemplate()
        results = setup.createFromTemplate(template)
        op: adsk.cam.Operation = results.item(0)

        contourParam: adsk.cam.CadContours2dParameterValue = op.parameters.itemByName('contours').value
        curveSelections = contourParam.getCurveSelections()

    except:
        if ui:
            ui.messageBox('Failed:\n{}'.format(traceback.format_exc()))

def getTemplate():
        source = camOptemplateSource + 'Contours'
        templates = os.listdir(source)
        return source + '\\' + templates[0]

 



 

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

karolis.s
Advocate
Advocate

If I try to use an alternative I get 'Unknown strategy' error.

karoliss_0-1684175312851.png

 

0 Likes
Message 3 of 3

kandennti
Mentor
Mentor
Accepted solution

Hi @karolis.s .

 

I don't know the cause, but I tried it on a whim and was able to avoid the error.

・・・
        template = getTemplate()
        results = setup.createFromTemplate(template)

        op: adsk.cam.Operation = results.item(0)
        op.isSuppressed = True
        op.isSuppressed = False

        contourParam: adsk.cam.CadContours2dParameterValue = op.parameters.itemByName('contours').value
        curveSelections = contourParam.getCurveSelections()
・・・