Select setup operation in Fusion 360 using API

Select setup operation in Fusion 360 using API

jalindar.sabale
Explorer Explorer
834 Views
4 Replies
Message 1 of 5

Select setup operation in Fusion 360 using API

jalindar.sabale
Explorer
Explorer
Hello
I am working on Autodesk Fusion 360 customization project.
Manually we can select the setup operation and its display automatically update in viewport.
In below image I have selected the operation Facing OD manually and its display automatically updated in viewport.
Similarly can we select the setup operation through API and update its display in viewport.
I want to generate custom sheet report. In that report I need to write all the parameters of each operation and display image of each operation.
I am able to access all the parameters of operation and need to capture the image of each operation through API.
Please let me know if there is any option available for the same.
0 Likes
835 Views
4 Replies
Replies (4)
Message 2 of 5

BrianEkins
Mentor
Mentor

You should be able to use the ActiveSelections object that you get from the UserInterface object to do this, but I tried it and it's not working. There appears to be a bug with adding an Operation object to the selection. It's a bit strange because if I manually select it and then get the entity currently selected, it correctly returns the Operation. I'll follow-up to see if a bug can be reported and hopefully it will be fixed soon. 

---------------------------------------------------------------
Brian Ekins
Inventor and Fusion 360 API Expert
Website/Blog: https://EkinsSolutions.com
Message 3 of 5

jalindar_sabale8BXM7
Explorer
Explorer

Hello Brian, Is there any update on the above mentioned issue.

0 Likes
Message 4 of 5

boopathi.sivakumar
Autodesk
Autodesk

Hi @jalindar_sabale8BXM7 

I believe still this is not yet fixed. But there is work around for what you want to achieve through post processing 

#Author- Boopathi Sivakumar
#Description-

import adsk.core, adsk.fusion, adsk.cam, traceback
import os

def run(context):
    ui = None
    try:
        app = adsk.core.Application.get()
        ui  = app.userInterface
        cam: adsk.cam.CAM = app.activeProduct
        
        # First Setup
        setup = cam.setups.item(0)

        # First operation
        operation = setup.allOperations.item(0)

        # Active script path
        acPath = os.path.dirname(os.path.abspath(__file__))
        postPath = os.path.join(acPath, 'post.cps')

        # Create the post input
        postInput = adsk.cam.PostProcessInput.create('1001', postPath, acPath, adsk.cam.PostOutputUnitOptions.DocumentUnitsOutput)
        postInput.isOpenInEditor = False

        #pass either setup or operation
        cam.postProcess(setup, postInput)

        # Remove the nc file
        os.remove(os.path.join(acPath, '1001.txt'))

    except:
        if ui:
            ui.messageBox('Failed:\n{}'.format(traceback.format_exc()))

 

In the post processor we do have a option to export the operation images so by using a post you can pass setups or operations in the cam.postProcess method so this will eventually give you the operation images in the output Directory you are specifying
I have attached a sample post which is capable of exporting the operation images

 

sample.png

 


Boopathi Sivakumar
Senior Technology Consultant

Message 5 of 5

jalindar_sabale8BXM7
Explorer
Explorer

Hi Boopathi, 

Thanks for reply. It exports the operation images with toolpath. However, I need operation image with tool and toolpath in top view. It exports operation image in isometric view only. Can we export operation image with tool, toolpath and in top view? I have attached operation images with the current result and expected result. Please let me know if you have any suggestions.

0 Likes