Announcements
Due to scheduled maintenance, the Autodesk Community will be inaccessible from 10:00PM PDT on Oct 16th for approximately 1 hour. We appreciate your patience during this time.
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: 

CAM Operations Template

3 REPLIES 3
Reply
Message 1 of 4
Josh3GG88
336 Views, 3 Replies

CAM Operations Template

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

 

Thanks, Josh W

3 REPLIES 3
Message 2 of 4
kandennti
in reply to: Josh3GG88

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 

Message 3 of 4
Josh3GG88
in reply to: Josh3GG88

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

Message 4 of 4
kandennti
in reply to: Josh3GG88

@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()))

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

Post to forums  

Autodesk Design & Make Report