diff --git a/gui.py b/gui.py index c4b1b26..dc4385e 100644 --- a/gui.py +++ b/gui.py @@ -1,16 +1,23 @@ import PySimpleGUI as sg -import sys +import subprocess +import sys, os -if len(sys.argv) == 1: - fname = sg.Window('My Script', - [[sg.Text('Document to open')], - [sg.In(), sg.FileBrowse()], +if len(sys.argv) > 1: + cmd = "python scripts/run.py " + str(sys.argv[1] ) + print(cmd) + p = subprocess.Popen(cmd, shell=True) +else: + fname = sg.Window('Files exporter', + [[sg.Text('Folder to export')], + [sg.In(), sg.FolderBrowse()], [sg.Open(), sg.Cancel()]]).read(close=True)[1][0] -else: - fname = sys.argv[1] -if not fname: - sg.popup("Cancel", "No filename supplied") - raise SystemExit("Cancelling: no filename supplied") -else: - sg.popup('The filename you chose was', fname) \ No newline at end of file + if not fname: + sg.popup("Cancel", "No filename supplied") + raise SystemExit("Cancelling: no filename supplied") + else: + # sg.popup('The filename you chose was', fname) + print(fname) + cmd = "python scripts/run.py " + str(fname) + print(cmd) + p = subprocess.Popen(cmd, shell=True) diff --git a/runSimple.py b/runSimple.py deleted file mode 100644 index 46c1d2b..0000000 --- a/runSimple.py +++ /dev/null @@ -1,19 +0,0 @@ -# example: .\run.py path\Part1 -import os -import sys -import pathlib -import subprocess - -# folder input -if(sys.argv[1]): - pass - -files = sys.argv[1:] # take files given in input -currentPath = str(pathlib.Path().resolve()) - -for i in files: - input = str(i) - commandstep = "PowerShell -NoProfile -ExecutionPolicy Bypass -File " + currentPath + "\export-step.ps1 " + input - commandPdfDxf = "PowerShell -NoProfile -ExecutionPolicy Bypass -File " + currentPath + "\export-pdf-dxf.ps1 " + input - subprocess.run(commandstep) - subprocess.run(commandPdfDxf) diff --git a/sample_parts/Part1 - Copy - Copy.SLDPRT b/sample_parts/Part1 - Copy - Copy.SLDPRT new file mode 100644 index 0000000..cb8f832 Binary files /dev/null and b/sample_parts/Part1 - Copy - Copy.SLDPRT differ diff --git a/sample_parts/Part1 - Copy.SLDDRW b/sample_parts/Part1 - Copy.SLDDRW new file mode 100644 index 0000000..9665d40 Binary files /dev/null and b/sample_parts/Part1 - Copy.SLDDRW differ diff --git a/sample_parts/Part1 - Copy.SLDPRT b/sample_parts/Part1 - Copy.SLDPRT new file mode 100644 index 0000000..cb8f832 Binary files /dev/null and b/sample_parts/Part1 - Copy.SLDPRT differ diff --git a/SolidWorks.Interop.sldworks.dll b/scripts/SolidWorks.Interop.sldworks.dll similarity index 100% rename from SolidWorks.Interop.sldworks.dll rename to scripts/SolidWorks.Interop.sldworks.dll diff --git a/export-file.cmd b/scripts/export-file.cmd similarity index 100% rename from export-file.cmd rename to scripts/export-file.cmd diff --git a/export-file.ps1 b/scripts/export-file.ps1 similarity index 100% rename from export-file.ps1 rename to scripts/export-file.ps1 diff --git a/export-pdf-dxf.ps1 b/scripts/export-pdf-dxf.ps1 similarity index 100% rename from export-pdf-dxf.ps1 rename to scripts/export-pdf-dxf.ps1 diff --git a/export-step.ps1 b/scripts/export-step.ps1 similarity index 100% rename from export-step.ps1 rename to scripts/export-step.ps1 diff --git a/run.py b/scripts/run.py similarity index 87% rename from run.py rename to scripts/run.py index 8c32a3b..4e5a59a 100644 --- a/run.py +++ b/scripts/run.py @@ -45,13 +45,13 @@ if not os.path.exists(outputFolder): # part files for i in track(partWithoutExention, description="Exporting step files..."): input = str(i) - commandstep = "PowerShell -NoProfile -ExecutionPolicy Bypass -File " + currentPath + '\export-step.ps1 "' + path + "\\" + input + '" "' + outputFolder + input + '"' + commandstep = "PowerShell -NoProfile -ExecutionPolicy Bypass -File " + currentPath + '\scripts\export-step.ps1 "' + path + "\\" + input + '" "' + outputFolder + input + '"' # print(commandstep) subprocess.run(commandstep, capture_output=True) # drawings files for i in track(drwgWithoutExtension, description="Exporting PDF and DXF..."): input = str(i) - commandPdfDxf = "PowerShell -NoProfile -ExecutionPolicy Bypass -File " + currentPath + '\export-pdf-dxf.ps1 "' + path + "\\" + input + '" "' + outputFolder + input + '"' + commandPdfDxf = "PowerShell -NoProfile -ExecutionPolicy Bypass -File " + currentPath + '\scripts\export-pdf-dxf.ps1 "' + path + "\\" + input + '" "' + outputFolder + input + '"' # print(commandPdfDxf) subprocess.run(commandPdfDxf, capture_output=True)