Notifications
Clear all

Post Process Error Code 1  

  RSS
GohDesign
(@gohdesign)
New Member
Post Process Error Code 1

I am having issues PrusaSlicer calling out a script I wrote. I get this error. From looking around I think it is a permission thing. 

 

I am using Windows 11. Python 3.11

 

Publié : 30/11/2023 6:07 pm
GohDesign
(@gohdesign)
New Member
Topic starter answered:
RE: Post Process Error Code 1

Here is the python script.

#! python3
import sys
import re

flag = False

out = open('sys.argv[1]'+'_adjusted'+'.gcode', 'w')

with open('sys.argv[1].gcode') as f:
    for r in f:
        if re.search('G1 F', r):
            feedrate = r[3:]
            flag = True
            print(r[:-1] + ' ' + feedrate) # get rid of new line 
        elif flag:
            r = r[:-1] + ' ' + feedrate
            out.write(r)
            flag = False # Reset flag            
        else:
            out.write(r)
            flag = False # Reset flag
Publié : 30/11/2023 6:29 pm
JimB
 JimB
(@jimb)
Estimable Member
RE: Post Process Error Code 1

out = open('sys.argv[1]'+'_adjusted'+'.gcode', 'w')

You are trying to open a file named "sys.argv[1]_adjusted.gcode".  You probably meant sys.argv[1]+'_adjusted.gcode'

open('sys.argv[1].gcode')

Similar to above.  You probably meant open(sys.argv[1])

And another issue.  Your modification need to be put back in the sys.argv[1] file.

I would try making changes like

import os
...
infile = sys.argv[1] 
outfile = infile + '.tmp'
out = open(outfile, 'w')

with open(infile) as f:
....

os.rename(outfile, infile)
Publié : 01/12/2023 6:55 pm
ScottW a aimé
GohDesign
(@gohdesign)
New Member
Topic starter answered:
RE: Post Process Error Code 1

Thanks for the feedback. Feel stupid about missing the quotes. I did try it and still get the same error. Maybe I am missing something stupid again. It did process it successfully once i removed the quotes, but when I added your suggestion for using the os i got the same Error Code 1 again.

 

#! python3
import sys
import re
import os

flag = False

infile = sys.argv[1]
outfile = infile + '.tmp'

out = open(outfile, 'w')

with open(infile) as f:
    for r in f:
        if re.search('G1 F', r):
            feedrate = r[3:]
            flag = True
            print(r[:-1] + ' ' + feedrate) # get rid of new line 
        elif flag:
            r = r[:-1] + ' ' + feedrate
            out.write(r)
            flag = False # Reset flag            
        else:
            out.write(r)
            flag = False # Reset flag
    
os.rename(outfile, infile)
Publié : 01/12/2023 7:14 pm
_KaszpiR_
(@_kaszpir_)
Prominent Member
RE: Post Process Error Code 1

try something like this:
1. remove custom processing scripts.
2. generate gcode as normal, save it
3. run terminal and execute python + script and pass saved gcode file path as parameter - check what is the output of the script, because it looks like it does not work as standalone?

See my GitHub and printables.com for some 3d stuff that you may like.

Publié : 02/12/2023 3:27 pm
GohDesign
(@gohdesign)
New Member
Topic starter answered:
RE: Post Process Error Code 1

I have done that and it works great. That is what I have been doing to get by for now. Just would be nice to have it integrated into the slicer so it's one less step I have to do.

Publié : 03/12/2023 6:12 pm
TheYellowDuck
(@theyellowduck)
Membre
RE: Post Process Error Code 1

Hello 😀

Did you ever find a solution?

Publié : 11/06/2024 2:02 pm
Partager :