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
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?
Thanks, Josh W
@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.
# 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()))