Retrieve tool associated with operation with Python API

Retrieve tool associated with operation with Python API

emanuelere_97
Explorer Explorer
336 Views
2 Replies
Message 1 of 3

Retrieve tool associated with operation with Python API

emanuelere_97
Explorer
Explorer

Hi,

I've successfully retrieved the setups of my CAM and the operations of every setups.

Now I would like to get the tool associated with every operation, but in the API reference of the Operation object I cannot find any reference to the tool used in that operation. 

Here's my code:

def run(context):
    ui = None
    try:
        app = adsk.core.Application.get()
        
        ui  = app.userInterface
        doc = app.activeDocument
        products = doc.products
        product = products.itemByProductType('CAMProductType')

        if product == None:
            ui.messageBox('There are no CAM operations in the active document')
            return

        cam = adsk.cam.CAM.cast(product)

        o = cam.setups.item(0).operations.item(0)
        for s in cam.setups:
            for o in s.operations:
                #here I want to retrieve the tool associated with this operation

    except:
        if ui:
            ui.messageBox('Failed:\n{}'.format(traceback.format_exc()))
0 Likes
337 Views
2 Replies
Replies (2)
Message 2 of 3

porsbym
Alumni
Alumni

Hi @emanuelere_97 , I'm afraid that the API doesn't currently expose tools.

 

Depending on what you are trying to accomplish, you may be able to use a custom post processor instead. Posts can be written in JavaScript and has more complete access to the toolpath and tool information.

 

For more information, take a look here: https://cam.autodesk.com/posts/

 

I hope this is helpful.

 

/Mark

0 Likes
Message 3 of 3

jeff.pek
Community Manager
Community Manager

Can you tell me what type of tool-related information you're looking for? Providing access to get -- and set -- additional information related to the operations is on our near-term roadmap for the API.

 

Mark's suggestion of exploring the use of a postprocessor for your needs is also a good one.

 

Thanks,

  Jeff

0 Likes