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()))
Solved! Go to Solution.
Solved by kandennti. Go to Solution.
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.
@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
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()))
@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.
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.