Skip to content

Commit db793eb

Browse files
foreachthinglordofhyphens
authored andcommitted
Post-Processing Script updates (#54)
* Post-Processing Script updates * Update post-processing.md
1 parent 0a1f315 commit db793eb

File tree

1 file changed

+41
-2
lines changed

1 file changed

+41
-2
lines changed

src/advanced/post-processing.md

Lines changed: 41 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,23 @@ output:
3434
echo "Post-processing G-code file: $*"
3535
env | grep ^SLIC3R
3636

37-
For security reasons you can't supply arguments to the scripts. However, you
38-
can just write a wrapper script.
37+
38+
#### Post-Processing Script Parameters
39+
40+
You can use parameters with your script as such:
41+
42+
Examples:
43+
44+
`/path/to/executable` becomes `/path/to/executable` with the arg `outputfilename.gcode`
45+
46+
`/path/to/executable -arg -arg2` becomes `/path/to/executable` with `args -arg, -arg2`, and `outputfilename.gcode`
47+
48+
`/path/to/executable! with! spaces -arg -arg2` becomes `/path/to/executable with spaces with args -arg, -arg2`, and `outputfilename.gcode`
49+
50+
`/path/to/executable!! -arg -arg2` becomes `/path/to/executable!` with `args -arg, -arg2`, and `outputfilename.gcode`
51+
52+
`/path/to/executable option! with! spaces` becomes `/path/to/executable` with args `option with spaces` and `outputfilename.gcode`
53+
3954

4055
Perl example
4156
------------
@@ -58,3 +73,27 @@ If you are getting a *can't do inplace edit without backup* error when specifyin
5873
the post-process script, try adding `$^I = '.bak';` before the while loop. This will
5974
create a backup file of the generated G-Code file. Windows does not like to have two
6075
scripts creating and/or accessing a single file at once, so a backup is needed.
76+
77+
78+
Python example
79+
--------------
80+
81+
#### Windows
82+
To use a Python post-processing script with Windows, you'll need to adjust the paths like this:
83+
84+
C:\Program! Files! (x86)\Python37-32\python.exe c:\dev\SCPP\Slic3rConfigPrettyPrint.py -o --au "John Doe"
85+
86+
Note the **!** before all white-spaces! Make sure you adjust the path to your script as well.
87+
Yes, you can save your G-Code file to somewhere with spaces in it's path.
88+
89+
Your script needs to accept at least one parameter: The filename of your G-Code file.
90+
`-o` and `--au "John Doe"` are optional parameters. The filename, of your G-Code, will be added to the end of this string.
91+
92+
Python.exe will then run your script with the specified parameters.
93+
94+
This `example.py` will just output the filename submitted by Slic3r:
95+
96+
import sys
97+
print ('This is the name of your G-Code file: {0}'.format(sys.argv[1]))
98+
99+
`sys.argv[0]` is the script `example.py`.

0 commit comments

Comments
 (0)