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.
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Create a facing operation

Message 1 of 3
160 Views, 2 Replies

Create a facing operation

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 :, tool : ->
    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() = '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 : = 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?

Message 2 of 3
in reply to: janHUUUQ

Hi @janHUUUQ -San.


I used the create_facing function you published and tried it with simple data and no error occurred.
Is it possible to publish an f3d file that can reproduce the error?

Message 3 of 3
in reply to: janHUUUQ

Thanks a lot @kandennti! I was not able to reproduce the error myself, so maybe I brought my fusion into a weird state. If I can reproduce, I will post an example.

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

Post to forums  

Autodesk DevCon in Munich May 28-29th

Autodesk Design & Make Report