Api to post processor setup sheet excel

Api to post processor setup sheet excel

nubrandao
Collaborator Collaborator
924 Views
13 Replies
Message 1 of 14

Api to post processor setup sheet excel

nubrandao
Collaborator
Collaborator

Hi@

 

@ i need help for a api script that post process my setupsheed Excel 2007

 

If possible, ask the NC program to select, and post but always with setup sheet excel 2007 post

 

Everytime i post a NC in heideiain or fidia, i need to duplicate, Change post to Excel setup and post again.

 

Would BE great an api to just select the NC i wanted and always post in setup sheet excell

0 Likes
Accepted solutions (1)
925 Views
13 Replies
Replies (13)
Message 2 of 14

rohit_maneYV8C9
Autodesk
Autodesk

Hello @nubrandao ,

Please find attached codes, You need to select single NC program before running this script, I hope you found this helpful.

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


def run(context):
    ui = None
    try:
        app: adsk.core.Application = adsk.core.Application.get()
        ui = app.userInterface
        camManger = adsk.cam.CAMManager.get()

        postLib = camManger.libraryManager.postLibrary
        # url = adsk.core.URL.create('system://setup-sheet-excel-2007.cps')
        url = adsk.core.URL.create('system://setup-sheet-excel-2007.new.cps')

        postPorcessor = postLib.postConfigurationAtURL(url)

        if not postPorcessor :
            ui.messageBox("Specified post processor not found!")
            return

        if ui.activeSelections.count != 1 :
            ui.messageBox("Please select only 1 ncprogram as a time")
            return
        Selections = ui.activeSelections.all
        for sel in Selections:
            ncProgram = adsk.cam.NCProgram.cast(sel)
            if ncProgram :
                orignalPost = ncProgram.postConfiguration

                ncProgram.postConfiguration = postPorcessor
                ncPostOpetion = adsk.cam.NCProgramPostProcessOptions.create()
                ncProgram.postProcess(ncPostOpetion)

                ncProgram.postConfiguration = orignalPost
                
                
        ui.messageBox("done")
        return
        

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

 
apart from that i think we can use 'use cascading post' option in NC program Window, it will help you to do same thing without ADD-IN but that may require some modification in postprocessor.

0 Likes
Message 3 of 14

nubrandao
Collaborator
Collaborator

I Will try thanks a lot

0 Likes
Message 4 of 14

nubrandao
Collaborator
Collaborator

appears this error

 

SCRIPT ERROR

 

(unicode error) 'unicodeescape' codec can't decode bytes in position 2-3: truncated \UXXXXXXXX escape (C:/Users/bnuno/AppData/Roaming/Autodesk/Autodesk Fusion 360/API/Scripts/Folha dos programas/Folha dos programas.py, line 13)

SCRIPT ERROR

 

 

i changed the link to my post processor, i think is this:

 

      postLib = camManger.libraryManager.postLibrary
        # url = adsk.core.URL.create('C:\Users\bnuno\AppData\Roaming\Autodesk\Fusion 360 CAM\Posts\setup-sheet-excel-2007.cps')
        url = adsk.core.URL.create('C:\Users\bnuno\AppData\Roaming\Autodesk\Fusion 360 CAM\Posts\setup-sheet-excel-2007.new.cps')

 

 

my post is in this folder: C:\Users\bnuno\AppData\Roaming\Autodesk\Fusion 360 CAM\Posts\setup-sheet-excel-2007.new.cps

0 Likes
Message 5 of 14

rohit_maneYV8C9
Autodesk
Autodesk
Accepted solution

You should not directly change the path of the post processor file in such a manner. The configurations for these post processors are typically stored in a post library, and there are specific ways to define the path based on where the post processor is located:

  • Local Folder: If the post processor is stored locally, the path should start with 'user://' + post name
  • Cloud Folder: For post processors stored in a cloud Folder, the path should begin with 'cloud://' + post name
  • Fusion Library : If the post processor is stored on Fusion library server, the path should start with 'system://' + post name.
  • Linked Folder: In cases where post processors are linked to other folder on your PC, the path might begin with 'linked://' + post name.

It's important to adhere to these conventions because they ensure that the system can reliably locate and utilize the specified post processor without causing disruptions or compatibility issues. Directly altering paths outside of these protocols can lead to errors or failures in post processing tasks.

 

0 Likes
Message 6 of 14

nubrandao
Collaborator
Collaborator

I Will try thanks

0 Likes
Message 7 of 14

nubrandao
Collaborator
Collaborator

It work perfectly

 

Thanks a lot 🙂

0 Likes
Message 8 of 14

dames123
Advocate
Advocate

@rohit_maneYV8C9   I was told that the setup sheet post won't work as cascading. It was a while ago though, can you confirm that we indeed can use it as a cascading post? That would simplify a lot of clicks.

 

Thanks.

 

0 Likes
Message 9 of 14

dames123
Advocate
Advocate

@rohit_maneYV8C9 ,

 

Also, in your script, is there a way to prompt the user to choose which post to use?

 

Thanks!

0 Likes
Message 10 of 14

nubrandao
Collaborator
Collaborator

I found a problem, if i have the same tool diameter, but differente number, cant post, it says that is a repeated tool

 

por example

 

T05_12r1_EPSM_SUP100XT12

 

T14_12R1_EPBPS_SUP100X150+M16X60

 

Cant use the script to post excell, it says there same tool 

0 Likes
Message 11 of 14

rohit_maneYV8C9
Autodesk
Autodesk

Hello @nubrandao 

Actually I haven't encountered any issues when testing this myself. I've tried various conditions and didn't encounter any problems. Could you please provide more details, such as which post-processor you're using and the specific tool data conditions? A screenshot would also be helpful.
It seems like you might be referring to the warning message about using the same tool number for two different tools. In Fusion software, this warning is simply meant to alert the user to a potential issue, but you can still proceed with your post-processing using the chosen post-processor.

0 Likes
Message 12 of 14

rohit_maneYV8C9
Autodesk
Autodesk

Hello @dames123 

We can use excel setup sheet post as a cascading post with some modification only issue is that image in overview worksheet will remain unchanged.

 

Also, there's another way to use the Excel setup sheet. You can understand this better by checking out the link:

Solved: Re: EXCELL setup sheet combine operations and tools - Autodesk Community  

Message 13 of 14

dames123
Advocate
Advocate
Very nice. Thanks for the info.
0 Likes
Message 14 of 14

nubrandao
Collaborator
Collaborator

one thing i noticed, if i have 10 toolpath, when post, i get alarm of 2 or 3 toolpath are outdate, if i run script to print setup excell, only print 7 toolpath

 

the solution to me was protect all toolpath

 

0 Likes