Community
Fusion API and Scripts
Got a new add-in to share? Need something specialized to be scripted? Ask questions or share what you’ve discovered with the community.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Error in simply script to post all operations as separate file

4 REPLIES 4
SOLVED
Reply
Message 1 of 5
maurizio_manzi
132 Views, 4 Replies

Error in simply script to post all operations as separate file

Hello,

I want to post any operation in a separate file.

The script is very easy, but I get an error message after a few operations.

I can't found any error in the script itself.

Attached fusion360 cam-part and the script.

Path and name of the pp must be selected in the script. Also the nc-output folder.

Best regards

Maurizio

 

4 REPLIES 4
Message 2 of 5
kandennti
in reply to: maurizio_manzi

Hi @maurizio_manzi .

 

There was no cps file, so I tried "fanuc.cps".
I tried that and it gave me an error if the name of the NC program is not a number.
I could avoid the error by doing this, but the file name is not what I want.

・・・
        setups = cam.setups
        setup = setups.item(0)
        nameNum = 100
        for setup in setups:
            folders = setup.folders
            for folder in folders:
                operations = folder.allOperations
                for operation in operations:
                    if operation.hasToolpath == True:
                        # postInput = adsk.cam.PostProcessInput.create(operation.name, postConfig, outputFolder, units)
                        postInput = adsk.cam.PostProcessInput.create(str(nameNum), postConfig, outputFolder, units)
                        postInput.isOpenInEditor = viewResult
                        cam.postProcess(operation, postInput)
                        nameNum += 1
・・・

 

I could not figure out if there is a corresponding field in the "File name" of the GUI.

1.png

 

 

Message 3 of 5
maurizio_manzi
in reply to: kandennti

Hello,

you can post with the Heidenhain PP (now attached).

My problem is not the file name.

I think, it's a software bug in Fusion.

It works until the operation not have any tool-orientation.

At the first operation with a tool-orientation, you get an internal error.

Best regards

Maurizio

 

Message 4 of 5
kandennti
in reply to: maurizio_manzi

@maurizio_manzi .

 

We found the cause.
It was simply because the file name contained characters that could not be used.

・・・
        setups = cam.setups
        setup = setups.item(0)
        import re
        for setup in setups:
            folders = setup.folders
            for folder in folders:
                operations = folder.allOperations
                for operation in operations:
                    if operation.hasToolpath == True:
                        file_name = re.sub(r'[\\|/|:|?|.|"|<|>|\|]', '_', operation.name)
                        postInput = adsk.cam.PostProcessInput.create(file_name, postConfig, outputFolder, units)
                        postInput.isOpenInEditor = viewResult
                        cam.postProcess(operation, postInput)
・・・
Message 5 of 5
maurizio_manzi
in reply to: kandennti

Thank you very much

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk DevCon in Munich May 28-29th


Autodesk Design & Make Report