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

Change an origin orientation of the setup.

2 REPLIES 2
SOLVED
Reply
Message 1 of 3
umemoto0722
227 Views, 2 Replies

Change an origin orientation of the setup.

 I want to change an origin orientation of the setup from the Python API in CAMEnvironment.

How to do set a CAMParameter of the origin orientation?

2 REPLIES 2
Message 2 of 3
kandennti
in reply to: umemoto0722

Hi @umemoto0722 .

 

I created one setup and ran the following 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]
        prms = [p for p in setup.parameters]

        for prm in prms:
            msg = f'{prm.name}:{prm.title}:{prm.expression}'
            print(msg)
    except:
        if ui:
            ui.messageBox('Failed:\n{}'.format(traceback.format_exc()))

 

It outputs a list of parameters for the setup.

 

1.png

The expression property of the "wcs_origin_boxPoint" parameter is
Red: 'top center'
Blue: 'top 4'

 

To change it to 'top 4' while it was 'top center', I ran the following code.

 

        prm = setup.parameters.itemByName('wcs_origin_boxPoint')
        prm.expression = 'top 4'

 

Unfortunately, I got an error and could not change it.
I guess the change in WCS is not yet supported.

Message 3 of 3
umemoto0722
in reply to: kandennti

Hi, kandennti.
Thank you for showing me the program.
I'll try another way.

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