Announcements
Attention for Customers without Multi-Factor Authentication or Single Sign-On - OTP Verification rolls out April 2025. Read all about it here.

How do change an orientation of operation by Python?

Anonymous

How do change an orientation of operation by Python?

Anonymous
Not applicable

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, adsk.cam, os, traceback

def run(context):
    ui = None
    try:
        app = adsk.core.Application.get()
        ui = app.userInterface
        doc = app.activeDocument
        products = doc.products
        cam = adsk.cam.CAM.cast(products.itemByProductType("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'
    except:
        if ui:
            ui.messageBox('Failed:\n{}'.format(traceback.format_exc()))
0 Likes
Reply
Accepted solutions (1)
858 Views
6 Replies
Replies (6)

kandennti
Mentor
Mentor

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.

1.png

0 Likes

Anonymous
Not applicable
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.
0 Likes

kandennti
Mentor
Mentor

@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.

https://help.autodesk.com/view/fusion360/ENU/?guid=MFG-TEMPLATE-LIBRARY-SELECTION 

 

Toolpath templates can also be called from the API.

https://help.autodesk.com/view/fusion360/ENU/?guid=GUID-AEF0708D-B657-4E9F-9032-4535E0D1C417 

 

 

0 Likes

Anonymous
Not applicable

@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
    try:
        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')
        setupcommand.execute(properties)
        commitcommand = ui.commandDefinitions.itemById('CommitCommand')
        commitcommand.execute()
        # A setup created but it ignored the argument.
    except:
        if ui:
            ui.messageBox('Failed:\n{}'.format(traceback.format_exc()))

 

0 Likes

kandennti
Mentor
Mentor
Accepted solution

@Anonymous .

 

There is very little information about "NamedValues".


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

https://forums.autodesk.com/t5/fusion-360-api-and-scripts/create-new-cam-setups/m-p/10215806 

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.

0 Likes

Anonymous
Not applicable

I see.

 

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

 

Thank you for showing me about it.

0 Likes