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: 

How do change an orientation of operation by Python?

Message 1 of 7
556 Views, 6 Replies

How do change an orientation of operation by Python?

I would like to change an orientation of drill operation by Python.


I tried to change a few below parameters.

- overrideToolView: 'true'

- view_orientation_mode: "'axesZX'"

- view_orientation_flipZ: 'true'

- view_orientation_axisZ: 'true'


But I got an error when change 'view_orientation_axisZ'.

The error said "can't change this value".

Is there a way that to select YZPlane for axisZ ?


My purpose is to set toolpaths for top, bottom, back, top, right and left in Python like sample.f3d.


Thank you.


sample code

import adsk.core,, os, traceback

def run(context):
    ui = None
        app = adsk.core.Application.get()
        ui = app.userInterface
        doc = app.activeDocument
        products = doc.products
        cam ="CAMProductType"))

        setups = cam.setups
        setup = setups[0]
        overrideToolView = operation.parameters.itemByName('overrideToolView')
        overrideToolView.expression = 'true'
        mode = operation.parameters.itemByName('view_orientation_mode')
        mode.expression = "'axesZX'"
        flipz = operation.parameters.itemByName('view_orientation_flipZ')
        flipz.expression = 'true'
        axisx = operation.parameters.itemByName('view_orientation_axisX')
        axisx.expression = 'true'
        if ui:
Labels (2)
Message 2 of 7
in reply to: Anonymous

Hi @Anonymous .


If the parameter name was 'view_orientation_flipX', there was no error.


You can check the parameter name by moving the mouse cursor to the corresponding part in the GUI and displaying the tooltip while holding down the Shift key.


Message 3 of 7
in reply to: kandennti

Hi, @kandennti .
Thank you for reply!

Sorry for the lack of explanation.
I want to rotate the z axis by 90 degrees, but with flip, it rotates 180 degrees.
If it turns 180 degrees I will not be able to set the toolpaths the side of the part.
Message 4 of 7
in reply to: Anonymous

@Anonymous .


I think you need to set the "Z Axis" and "X Axis", but I don't think it is currently possible to set them via the API.


I don't use Fusion360CAM, so I don't know much about it, but the most efficient way to work with it might be to create a toolpath template in advance and call it up. 


Toolpath templates can also be called from the API. 



Message 5 of 7
in reply to: kandennti

@kandennti .


Oh, Ok.


When to use toolpath template, "flip" can change false to true but an axis is not be able to change.
If I copy to another CAM with an operation that changed "Z axis" (or "X axis") and flip, the following warning will be displayed. And “Z-axis” to be empty.

"One or more operations that were moved or copied over have a manufacturing model that is different from the one referenced in the target setup.
All geometry selections associated with these operations have been cleared."


If you know of any, when executing commandDefinition.execute of 'IronSetup', it can take NamedValues as an argument.
What can I specify for the key of this argument, or will the argument be ignored?


sample code

import adsk.core, traceback
def run(_):
    ui = None
        app = adsk.core.Application.get()
        ui = app.userInterface
        properties = adsk.core.NamedValues.create()
        value = adsk.core.ValueInput.createByString('axisZX')
        properties.add('wcs_orientation_mode', value)
        setupcommand = ui.commandDefinitions.itemById('IronSetup')
        commitcommand = ui.commandDefinitions.itemById('CommitCommand')
        # A setup created but it ignored the argument.
        if ui:


Message 6 of 7
in reply to: Anonymous

@Anonymous .


There is very little information about "NamedValues".

I have tried to create a setup in the past, specifying the model. 

This is not the preferred way, but I can think of no other way to achieve something that is not provided by the API.
And it is very difficult to develop.

Message 7 of 7
in reply to: kandennti

I see.


I will try it on the assumption that it is not the recommended way.


Thank you for showing me about it.

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

Post to forums  

Technology Administrators

Autodesk Design & Make Report