Announcements
Autodesk Community will be read-only between April 26 and April 27 as we complete essential maintenance. We will remove this banner once completed. Thanks for your understanding

CAM Operations Template

Josh3GG88
Enthusiast Enthusiast
538 Views
3 Replies
Message 1 of 4

CAM Operations Template

Josh3GG88
Enthusiast
Enthusiast

how would it be possible to pass an operation template into a setup using API?

 

Thanks, Josh W

Reply
Reply
0 Likes
539 Views
3 Replies
Replies (3)
Message 2 of 4

kandennti
Mentor
Mentor

Hi @Josh3GG88 -San.

 

You should be able to load the template with the Setup.createFromCAMTemplate2 method.

https://help.autodesk.com/view/fusion360/ENU/?guid=GUID-ED76E72F-3AE2-4669-BFF3-0249B00CCB4E 

 

Sample code can be found here.

https://help.autodesk.com/view/fusion360/ENU/?guid=GUID-AEF0708D-B657-4E9F-9032-4535E0D1C417 

 

If you want to try it out right away, you can download the script and f3d file attached to this topic.

https://forums.autodesk.com/t5/fusion-ri-ben-yu/rettsu-xueake-/m-p/12200892#M46814 

Reply
Reply
0 Likes
Message 3 of 4

Josh3GG88
Enthusiast
Enthusiast

Thanks. I got it to work now. My biggest problem was i needed the double slash "\\" in the file path. 

 

now for a different question, can i add a manufacturing model body to the "job_model" parameter after i create the setup?

Josh3GG88_0-1715983401681.png

 

 

Thanks, Josh W

Reply
Reply
0 Likes
Message 4 of 4

kandennti
Mentor
Mentor

@Josh3GG88 -San.

 

We have created a sample that changes the model.

In the attached f3d file “Setup1”, the “Before” body is set, but change it to the “After” body.

1.png

# Fusion360API Python script

import traceback
import adsk.core as core
import adsk.fusion as fusion
import adsk.cam as cam

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

        # CAM
        camObj: cam.CAM = app.activeProduct

        # Root Component
        rootOcc: fusion.Occurrence = camObj.designRootOccurrence
        rootComp: fusion.Component = rootOcc.component

        # Body "After"
        occ: fusion.Occurrence = rootComp.occurrences[0]
        body: fusion.BRepBody = occ.component.bRepBodies[0]
        body = body.createForAssemblyContext(occ)

        # Setup
        setup: cam.Setup = camObj.setups[0]

        # CAMParameter "job_model"
        param: cam.CAMParameter = setup.parameters.itemByName("job_model")

        # Change Model
        param.value.value = [body]

        ui.messageBox("Done")

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