Message 1 of 3
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
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:
Here is a proof I have valid template file:
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]
Solved! Go to Solution.