Create a facing operation
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
I am trying to better understand how to create operations using the API. A great example is Manufacturing Workflow API Sample . It is a bit complex and I try to create a minimal facing operation example. Here is my code so far:
def create_facing(setup : adsk.cam.Setup, tool : adsk.cam.Tool) -> adsk.cam.OperationBase:
tool_type = tool.parameters.itemByName('tool_type').value.value
expected_tool_types = ["face mill", "flat end mill"]
if not tool_type in expected_tool_types:
raise Exception(f'Unexpected tool type. Expected: {expected_tool_types}. Got:{tool_type}')
input = setup.operations.createInput('face') # strategy
input.tool = tool
input.displayName = 'My Face Operation'
preset = tool.presets.add()
preset.name = 'My Preset name'
preset.parameters.itemByName('tool_spindleSpeed').expression = "4999 rpm"
preset.parameters.itemByName('tool_feedCutting').expression = "11 in/min"
# create a face operation input and set the parameters.
input.toolPreset = preset # assign created preset
input.displayName = 'Face Operation'
# add the operation to the setup
op : adsk.cam.OperationBase = setup.operations.add(input)
return op
If I run it, I get:
So something is wrong with my tool parameters. If I open and close the operation in the GUI without editing anything, all issues disappear. Apparently, fusion fixes the parameters:
Here are my questions:
* What is the meaning of the error messages? What does "different value with level 1" mean? It sounds like there are conflicting definitions for a parameter? How to debug this?
* It seems in the GUI fusion magically resolves the parameter issues. Does it assign some default values? Is there a way to assign defaults for all parameters in the API?
* Aside: Here the preset I create is added to the tool. I am not sure I want that, can it have side effects in other areas of the program? Is there a way to create a fresh preset without adding it to the tool?