Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Post-processing #6888

Closed
KnatteAnka opened this issue Sep 3, 2021 · 12 comments
Closed

Post-processing #6888

KnatteAnka opened this issue Sep 3, 2021 · 12 comments

Comments

@KnatteAnka
Copy link

Version

Version 2.4.0-alpha1+Win64

Operating system type + version

Windows 10

3D printer brand / version + firmware version (if known)

N/A (Prusa MK2.5S)

Behavior

new behavior that Post-processing is done before copying item to location gives me problems.

Problem is that my script for Starting Printer, copying and mounting the networkdrive need to be run after the export is done :(

Is there any way to run a file when the file is exported?
Or is it possible to add a check box old or new behavior. (Run when copied [Checkbox])

@xorza
Copy link
Contributor

xorza commented Sep 3, 2021

I'd suggest that we have two scripts

rename current one to pre-processing
add a post-processing one

@bubnikv
Copy link
Collaborator

bubnikv commented Sep 6, 2021 via email

@KnatteAnka
Copy link
Author

KnatteAnka commented Sep 8, 2021

it is used to run command when a file is processed
1: Start printer
2: Connect to Wifi SD-card
3: Copy rename and copy G-code to Wifi SD-card
Rename format is that it adds a number before it
example
Export name: Somefile.gcode
Copy to SD-card name: NNNN_Somefile.gcode
NNNN is a number that is counting down from 9999 to 0000

@bubnikv
Copy link
Collaborator

bubnikv commented Sep 9, 2021 via email

@KnatteAnka
Copy link
Author

Here is the script,
As a short hot fix for the alpha i use Post.bat to start a new window of Move_rename.bat and in that i have a 10s delay (To give PS time to copy the Gcode to the export folder but that is not optimal because is the time always the same independent of file size...

Post.bat

E:  
cd E:\Export  
start Move_Rename.bat  

Move_Rename.bat

@echo off

chcp 850
chcp 65001
Color F0 

E:
cd E:\Export

timeout 10
set Number=1000

Echo ------------------Test connection--------------
ping -n 1 -w 50 "192.168.3.74" | findstr /r /c:"[0-9] *ms"

if %errorlevel% == 0 (
    echo Printer is started.
    goto Begin
) else (
    echo Printer is offline.
    echo Starting 3DPrinter
)
Echo -------------------------------
start http://192.168.3.88/relay/0?turn=on
timeout 30
:Begin
Echo Starting SDCARD network
set Number=99
net use X: \\192.168.3.74\DCIM
:Start
Echo -------------------------------
Echo Starting SDCARD Export
for /f "delims=" %%x in (Select.txt) do set Number=%%x
set /a Number= Number-1

set File=None
for /F "delims=" %%i IN ('dir /B *.gcode') DO set File=%%i
Set NewFile=%Number%_%File%
IF EXIST "%File%" (
	echo Copying %NewFile%
	Echo ┌────────────────
	Echo │ %Number%
	Echo └────────────────
	rem echo Copying %NewFile%
	rem Echo ^<ESC^>�[31m Copying %NewFile%	�[30m
Color F0 
	move "%File%" "X:/%NewFile%"
	echo %Number% > Select.txt
	goto Start
)
Echo -------------------------------
Echo Done Export.
timeout 60
exit

Select.txt
2453

@sej7278
Copy link

sej7278 commented Oct 1, 2021

is this the same as #6042 (which was for 2.3.0?!) which one should we be commenting on?

i have a similar problem - post-processing script makes some tweaks to the gcode dualstrusion/fan pwm/retraction and then runs gpx to convert to x3g format for flashforge creator pro.

the problem is the post-processing works on the /tmp file, but PrusaSlicer seems to send the output to SLIC3R_PP_OUTPUT_NAME and gpx tries to run on a non-existant file (race condition - the SLIC3R_PP_OUTPUT_NAME doesn't exist until post-processing is finished)

@bubnikv
Copy link
Collaborator

bubnikv commented Oct 4, 2021

@sej7278

I don't understand your workflow and your issue.

but PrusaSlicer seems to send the output to SLIC3R_PP_OUTPUT_NAME and gpx tries to run on a non-existant file (race condition - the SLIC3R_PP_OUTPUT_NAME doesn't exist until post-processing is finished)

Are you running the gpx tool asynchronously wrt. to PrusaSlicer post processing script?

@sej7278
Copy link

sej7278 commented Oct 4, 2021

No, gpx needs to run on the final file at the end of post-processing, but that file doesn't exist in its final destination until after pp with this change, so you can't run gpx as part of pp

@bubnikv
Copy link
Collaborator

bubnikv commented Oct 4, 2021

Why don't you run gpx from pp in the temp file and either rename the output file from gpx to the original file name or set SLIC3R_PP_OUTPUT_NAME accordingly? PrusaSlicer will copy the produced file for you to the target location.

@sej7278
Copy link

sej7278 commented Oct 4, 2021

As that's a hack. I could equally say why doesn't the guy who made the PR save to ssd then copy to his slow nas

@KnatteAnka
Copy link
Author

well as talked about in the other tread maybe add a Deployment Command line that can be run when fully exported.

I would put it even at printer level and not at filament level.
To be able to easy change filament but still run the same deployment command.

But note that I have a workaround for new behaviour so its not a high priority. Even if the workaround is not optimal.

@bubnikv
Copy link
Collaborator

bubnikv commented Dec 8, 2021

We have documented the current behavior
https://help.prusa3d.com/en/article/post-processing-scripts_283913

I think everybody could adjust her / his script to work with the current framework.

Also please note that the current behavior (modifying the G-code in place by the post processing script) was always specified by the Slic3r manual, thus if somebody used the post processing script to rename the G-code, one did not follow the manual. From the manual:

Each script will be passed the absolute path of the G-code file that Slic3r generates. The script will need to modify it in-place; alternatively it can output the new G-code to a temporary file and then overwrite the original one with it.

https://manual.slic3r.org/advanced/post-processing

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants