Skip to content

Commit 7e8549a

Browse files
authored
Execute when finished / No error on abort/close progress window
1 parent 6a0f065 commit 7e8549a

7 files changed

+87
-4
lines changed

PhotonFile.pyc

34.8 KB
Binary file not shown.

PhotonSlicer.py

Lines changed: 33 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -226,7 +226,11 @@ def _print_message(self,message,stderr):
226226
ap.add_argument("-g", "--gui", required=False,
227227
default=6.5,type=is_bool,
228228
help="show progress in popup window")
229-
229+
ap.add_argument("-e", "--execute", required=False,
230+
help="execute command when done \n"+
231+
"'photon' will be replace with output filename \n"+
232+
"if argument is 'folder' a file browser will open")
233+
230234
args = vars(ap.parse_args())
231235

232236
# Check photonfilename is valid only now (that we have stlfilename)
@@ -250,6 +254,7 @@ def _print_message(self,message,stderr):
250254
bottomexposure = float(args["bottomexposure"])
251255
bottomlayers = int(args["bottomlayers"])
252256
offtime = float(args["offtime"])
257+
linkedcmd = args["execute"]
253258

254259
S2I=Stl2Slices(stlfilename=stlfilename,
255260
outputpath=outputpath,
@@ -262,3 +267,30 @@ def _print_message(self,message,stderr):
262267
offtime=offtime,
263268
gui=gui
264269
)
270+
271+
"""
272+
Test on linux using:
273+
python3 PhotonSlicer.py -s STLs/bunny.stl -r 0.5 -l 0.1
274+
-e "wine ~/.wine/drive_c/Program\ Files/ANYCUBIC\ Photon\ Slicer64/ANYCUBIC\ Photon\ Slicer.exe /home/nard/PhotonSlicer/photon"
275+
"""
276+
import subprocess
277+
import platform
278+
import os
279+
def open_folder(path):
280+
if platform.system() == 'Darwin':
281+
subprocess.Popen(['open', path])
282+
#os.startfile(path)
283+
elif platform.system() == 'Linux':
284+
subprocess.Popen(['xdg-open', path])
285+
#os.startfile(path)
286+
elif platform.system() == 'Windows':
287+
os.startfile(path)
288+
#os.startfile(path)
289+
290+
if not linkedcmd==None:
291+
linkedcmd=linkedcmd.replace("photon",outputfile)
292+
os.system(linkedcmd)
293+
294+
if linkedcmd=="folder":
295+
folderpath=os.path.dirname(outputfile)
296+
open_folder(path=folderpath) # open current directory

Stl2Slices.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -540,9 +540,12 @@ def __init__(self, stlfilename, scale=1,
540540

541541
# Update GUI progress bar if gui active
542542
if self.gui:
543-
self.popup.update()
544-
progress=100*sliceNr/nrSlices
545-
self.progress_var.set(progress)
543+
try: # Check if user aborted/closed window
544+
self.popup.update()
545+
progress=100*sliceNr/nrSlices
546+
self.progress_var.set(progress)
547+
except Exception:
548+
None
546549

547550
if not self.gui: print () # close progress stdout and go to new line
548551

Stl2Slices.pyc

9.3 KB
Binary file not shown.

log.txt

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,51 @@ usage: PhotonSlicer.py [-h] -s STLFILENAME [-p PHOTONFILENAME]
33
[-be BOTTOMEXPOSURE] [-bl BOTTOMLAYERS] [-o OFFTIME]
44
[-g GUI]
55

6+
7+
---------------------------
8+
2018-11-11 09:21:54
9+
usage: PhotonSlicer.py [-h] -s STLFILENAME [-p PHOTONFILENAME]
10+
[-l LAYERHEIGHT] [-r RESCALE] [-t EXPOSURE]
11+
[-be BOTTOMEXPOSURE] [-bl BOTTOMLAYERS] [-o OFFTIME]
12+
[-g GUI] [-e EXECUTE]
13+
14+
Traceback (most recent call last):
15+
File "PhotonSlicer.py", line 235, in <module>
16+
args = vars(ap.parse_args())
17+
File "/usr/lib/python3.6/argparse.py", line 1746, in parse_args
18+
self.error(msg % ' '.join(argv))
19+
File "/usr/lib/python3.6/argparse.py", line 2400, in error
20+
self.print_usage(_sys.stderr)
21+
File "/usr/lib/python3.6/argparse.py", line 2370, in print_usage
22+
self._print_message(self.format_usage(), file)
23+
File "PhotonSlicer.py", line 161, in _print_message
24+
raise Exception(message)
25+
Exception: usage: PhotonSlicer.py [-h] -s STLFILENAME [-p PHOTONFILENAME]
26+
[-l LAYERHEIGHT] [-r RESCALE] [-t EXPOSURE]
27+
[-be BOTTOMEXPOSURE] [-bl BOTTOMLAYERS] [-o OFFTIME]
28+
[-g GUI] [-e EXECUTE]
29+
30+
31+
---------------------------
32+
2018-11-11 09:22:01
33+
usage: PhotonSlicer.py [-h] -s STLFILENAME [-p PHOTONFILENAME]
34+
[-l LAYERHEIGHT] [-r RESCALE] [-t EXPOSURE]
35+
[-be BOTTOMEXPOSURE] [-bl BOTTOMLAYERS] [-o OFFTIME]
36+
[-g GUI] [-e EXECUTE]
37+
38+
Traceback (most recent call last):
39+
File "PhotonSlicer.py", line 235, in <module>
40+
args = vars(ap.parse_args())
41+
File "/usr/lib/python3.6/argparse.py", line 1746, in parse_args
42+
self.error(msg % ' '.join(argv))
43+
File "/usr/lib/python3.6/argparse.py", line 2400, in error
44+
self.print_usage(_sys.stderr)
45+
File "/usr/lib/python3.6/argparse.py", line 2370, in print_usage
46+
self._print_message(self.format_usage(), file)
47+
File "PhotonSlicer.py", line 161, in _print_message
48+
raise Exception(message)
49+
Exception: usage: PhotonSlicer.py [-h] -s STLFILENAME [-p PHOTONFILENAME]
50+
[-l LAYERHEIGHT] [-r RESCALE] [-t EXPOSURE]
51+
[-be BOTTOMEXPOSURE] [-bl BOTTOMLAYERS] [-o OFFTIME]
52+
[-g GUI] [-e EXECUTE]
53+
151 KB
Binary file not shown.
636 KB
Binary file not shown.

0 commit comments

Comments
 (0)