Change an origin orientation of the setup.

Change an origin orientation of the setup.

Anonymous
Not applicable
497 Views
2 Replies
Message 1 of 3

Change an origin orientation of the setup.

Anonymous
Not applicable

 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?

0 Likes
Accepted solutions (1)
498 Views
2 Replies
Replies (2)
Message 2 of 3

kandennti
Mentor
Mentor
Accepted solution

Hi @Anonymous .

 

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

Anonymous
Not applicable
Hi, kandennti.
Thank you for showing me the program.
I'll try another way.
0 Likes