Message 1 of 7
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hi, I'm trying to get compensation type from existing operations, but without any satisfying result. Does anybody know how to get it?
My goal is to rename the operation if it's using tool compensation controlled by the control system of the machine, as is customary in our company.
Thanks in advance for your help.
Sample script with message box instead of op. renaming below:
import adsk.core, adsk.fusion, adsk.cam, traceback, adsk.drawing
app = adsk.core.Application.get()
ui = app.userInterface
doc = app.activeDocument
products = doc.products
cam = adsk.cam.CAM.cast(products.itemByProductType("CAMProductType"))
def toolComp():
for setup in cam.setups:
for op in setup.operations:
getCompensation = op.parameters.itemByName('compensationType')
getStrategy = op.strategy
if getCompensation == '\'control\'':
comp = "- tool compensation active"
elif getCompensation == '\'off\'':
comp = "- tool center"
elif getCompensation == None:
comp = "- null"
else:
comp = "- other"
ui.messageBox(getStrategy + comp )
def run(context):
try:
toolComp()
except:
if ui:
ui.messageBox('Failed:\n{}'.format(traceback.format_exc()))
Solved! Go to Solution.