Error in simply script to post all operations as separate file

Error in simply script to post all operations as separate file

maurizio_manzi
Advocate Advocate
429 Views
4 Replies
Message 1 of 5

Error in simply script to post all operations as separate file

maurizio_manzi
Advocate
Advocate

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

 

0 Likes
Accepted solutions (1)
430 Views
4 Replies
Replies (4)
Message 2 of 5

kandennti
Mentor
Mentor

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

 

 

0 Likes
Message 3 of 5

maurizio_manzi
Advocate
Advocate

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

 

0 Likes
Message 4 of 5

kandennti
Mentor
Mentor
Accepted solution

@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)
・・・
0 Likes
Message 5 of 5

maurizio_manzi
Advocate
Advocate

Thank you very much

0 Likes