こちらの続きです。
CAMのオペレーションを選択したい - C#ATIA
APIフォーラムのこちらに記載しました。
Re: Can we select a Setup programmatically? - Autodesk Community
オペレーションでは無く、セットアップの選択です。
'Setups=1' をドキュメントを作成した時、又はCAMを最初に使った時の
言語に依存する ような事を書いたのですが、試してみると
日本語環境でも 'Setups=1' のままで選択出来るようです。
(Treeの "設定" は恐らく一つしか無いはずなので、Setups=1の決め打ちで良いはず)
オペレーションもその続きなので、恐らくこれで大丈夫でしょう。
ドキュメント名をURLエンコードしなきゃダメだって気が付いたのが
今回の収穫です。
前回、何の為にオペレーション選択したかったんだっけ?
追記です。
つまり、最初のセットアップの最初のオペレーションを選択したい場合は
こうなのさ。
# Fusion360API Python script import traceback import adsk.fusion import adsk.core import adsk.cam from urllib.parse import quote 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")) # target setup setup = cam.setups[0] # target operation operation = setup.operations[0] # ObjectPaths.Onk onk = u'ONK::CmpInst={}/Cmp={}/{}/{}={}/{}={}'.format( quote(doc.name), quote(doc.name), 'Setups=1', setup.name, setup.operationId, operation.name, operation.operationId) app.log(onk) # select operation app.executeTextCommand(u'Commands.Select {}'.format(onk)) except: if ui: ui.messageBox('Failed:\n{}'.format(traceback.format_exc()))