Compare commits
11 Commits
Author | SHA1 | Date | |
---|---|---|---|
|
cca4ccbb8c | ||
|
33ee735f83 | ||
|
99780c1cb8 | ||
|
0d966f0556 | ||
|
fbc1e82651 | ||
|
a20779495d | ||
|
3b36821681 | ||
|
9d7e5abcf8 | ||
|
28619792b2 | ||
|
d9aad27449 | ||
|
5036cc0eba |
20
README.md
20
README.md
@ -2,6 +2,14 @@
|
|||||||
|
|
||||||
Script to generate production files (part -> step, dxf, pdf)
|
Script to generate production files (part -> step, dxf, pdf)
|
||||||
|
|
||||||
|
# Usage:
|
||||||
|
1. Download the latest release: https://git.lurenaud.com/lurenaud/SldwrksExporter/releases
|
||||||
|
2. Unzip and run the export.exe file
|
||||||
|
3. Select the folder with the parts, to generate the production files
|
||||||
|
4. Open and wait
|
||||||
|
It works faster with solidworks closed
|
||||||
|
|
||||||
|
# Working from source:
|
||||||
|
|
||||||
## Prerequisite:
|
## Prerequisite:
|
||||||
- python (to install type python in terminal, it will open the windows store to install it) (or: `curl -o python.exe https://www.python.org/ftp/python/3.11.1/python-3.11.1-amd64.exe; python.exe /quiet InstallAllUsers=1 PrependPath=1 Include_test=0`)
|
- python (to install type python in terminal, it will open the windows store to install it) (or: `curl -o python.exe https://www.python.org/ftp/python/3.11.1/python-3.11.1-amd64.exe; python.exe /quiet InstallAllUsers=1 PrependPath=1 Include_test=0`)
|
||||||
@ -10,7 +18,7 @@ Script to generate production files (part -> step, dxf, pdf)
|
|||||||
## Automatic install
|
## Automatic install
|
||||||
will dowwnload the git repo, install everything and launch the program.
|
will dowwnload the git repo, install everything and launch the program.
|
||||||
copy paste this line in an **Administrator** powershell or windows terminal
|
copy paste this line in an **Administrator** powershell or windows terminal
|
||||||
`Set-ExecutionPolicy -ExecutionPolicy RemoteSigned; curl -o installFrom0.cmd https://git.lurenaud.com/lurenaud/SldwrksExporter/raw/branch/main/installFromZeroScript/installFrom0.cmd; .\installFrom0.cmd`
|
`curl -o installFrom0.cmd https://git.lurenaud.com/lurenaud/SldwrksExporter/raw/branch/main/scripts/installFrom0.cmd; .\installFrom0.cmd`
|
||||||
|
|
||||||
## Manual install
|
## Manual install
|
||||||
1. Get the code:
|
1. Get the code:
|
||||||
@ -30,3 +38,13 @@ copy paste this line in an **Administrator** powershell or windows terminal
|
|||||||
## Use:
|
## Use:
|
||||||
In terminal: `.\gui.py path\toFloderOfFiles` will generate step, pdf and dxf in a export folder
|
In terminal: `.\gui.py path\toFloderOfFiles` will generate step, pdf and dxf in a export folder
|
||||||
Double click the gui.py file
|
Double click the gui.py file
|
||||||
|
|
||||||
|
## Generate exe file
|
||||||
|
|
||||||
|
Using auto-py-to-exe
|
||||||
|
`pip install auto-py-to-exe`
|
||||||
|
|
||||||
|
Export command, will generate the exe file in dist folder
|
||||||
|
```
|
||||||
|
pyinstaller --noconfirm --onefile --console --add-data "C:/Users/lucienrenaud/Desktop/SldwrksExporter/scripts/export-pdf-dxf.ps1;." --add-data "C:/Users/lucienrenaud/Desktop/SldwrksExporter/scripts/export-step.ps1;." --add-data "C:/Users/lucienrenaud/Desktop/SldwrksExporter/scripts/SolidWorks.Interop.sldworks.dll;." "C:/Users/lucienrenaud/Desktop/SldwrksExporter/scripts/export.py"
|
||||||
|
```
|
2
gui.py
2
gui.py
@ -18,7 +18,7 @@ else:
|
|||||||
else:
|
else:
|
||||||
# sg.popup('The filename you chose was', fname)
|
# sg.popup('The filename you chose was', fname)
|
||||||
print(fname)
|
print(fname)
|
||||||
cmd = "python scripts/run.py " + str(fname)
|
cmd = "python scripts/runFolder.py " + str(fname)
|
||||||
print(cmd)
|
print(cmd)
|
||||||
p = subprocess.run(cmd, shell=True)
|
p = subprocess.run(cmd, shell=True)
|
||||||
|
|
||||||
|
93
scripts/export.py
Normal file
93
scripts/export.py
Normal file
@ -0,0 +1,93 @@
|
|||||||
|
# example: .\run.py path_to_folder\
|
||||||
|
|
||||||
|
import os
|
||||||
|
import sys
|
||||||
|
import pathlib
|
||||||
|
import subprocess
|
||||||
|
from rich.progress import track
|
||||||
|
from rich import print
|
||||||
|
import PySimpleGUI as sg
|
||||||
|
|
||||||
|
def dirToFileList(folder):
|
||||||
|
# folder input
|
||||||
|
input = next(os.walk(folder))
|
||||||
|
files = input[2]
|
||||||
|
path = input[0]
|
||||||
|
path = path.replace('/', '\\')
|
||||||
|
filesList = []
|
||||||
|
for f in files:
|
||||||
|
f = f.replace('/', '\\')
|
||||||
|
filesList.append(str(path) + '\\' + str(f))
|
||||||
|
|
||||||
|
runFiles(filesList)
|
||||||
|
|
||||||
|
|
||||||
|
def runFiles(files):
|
||||||
|
currentPath = os.path.dirname(os.path.realpath(__file__))
|
||||||
|
# print("Current path script" + currentPath)
|
||||||
|
|
||||||
|
partFiles = [s for s in files if ".SLDPRT" in s] # get only parts files
|
||||||
|
drwgFiles = [s for s in files if ".SLDDRW" in s] # get only drawings files
|
||||||
|
|
||||||
|
print("\nParts: \n", partFiles)
|
||||||
|
print("\nDrawings: \n", drwgFiles, "\n")
|
||||||
|
|
||||||
|
partWithoutExention = [os.path.splitext(x)[0] for x in partFiles] # remove extension
|
||||||
|
drwgWithoutExtension = [os.path.splitext(x)[0] for x in drwgFiles] # remove extension
|
||||||
|
# print("Parts without extension: ", partWithoutExention)
|
||||||
|
|
||||||
|
# Check if each part has drawings and print
|
||||||
|
for p in partWithoutExention:
|
||||||
|
if str(p) not in str(drwgFiles):
|
||||||
|
print(p, " doesn't have drawing file\n")
|
||||||
|
|
||||||
|
for p in files: # create export directory
|
||||||
|
outputFolder = os.path.split(p)[0] + "\\export\\"
|
||||||
|
# print("Out folder: ", outputFolder)
|
||||||
|
if not os.path.exists(outputFolder):
|
||||||
|
os.makedirs(outputFolder)
|
||||||
|
# print("\nExport folder created\n")
|
||||||
|
|
||||||
|
# part files
|
||||||
|
for i in track(partWithoutExention, description="Exporting step files...", total=len(partWithoutExention)):
|
||||||
|
path, input = os.path.split(i)
|
||||||
|
i = i.replace('/', '\\')
|
||||||
|
path = path.replace('/', '\\')
|
||||||
|
outputFolder = path + "\\export\\"
|
||||||
|
|
||||||
|
commandstep = "PowerShell -NoProfile -ExecutionPolicy Bypass -File " + currentPath + '\export-step.ps1 "' + i + '" "' + outputFolder + input + '"'
|
||||||
|
# print(commandstep)
|
||||||
|
subprocess.run(commandstep, capture_output=True)
|
||||||
|
|
||||||
|
# drawings files
|
||||||
|
for i in track(drwgWithoutExtension, description="Exporting PDF and DXF...", total = len(drwgWithoutExtension)):
|
||||||
|
path, input = os.path.split(i)
|
||||||
|
i = i.replace('/', '\\')
|
||||||
|
path = path.replace('/', '\\')
|
||||||
|
outputFolder = path + "\\export\\"
|
||||||
|
commandPdfDxf = "PowerShell -NoProfile -ExecutionPolicy Bypass -File " + currentPath + '\export-pdf-dxf.ps1 "' + i + '" "' + outputFolder + input + '"'
|
||||||
|
# print(commandPdfDxf)
|
||||||
|
subprocess.run(commandPdfDxf, capture_output=True)
|
||||||
|
|
||||||
|
if __name__ == '__main__':
|
||||||
|
if len(sys.argv) > 1:
|
||||||
|
cmd = str(sys.argv[1] )
|
||||||
|
dirToFileList(cmd)
|
||||||
|
else:
|
||||||
|
fname = sg.Window('Exporter',
|
||||||
|
[[sg.Text('Folder to export')],
|
||||||
|
[sg.In(), sg.FilesBrowse(button_text="Open files"), sg.FolderBrowse(button_text="Open folder")],
|
||||||
|
[sg.Open(), sg.Cancel()]]).read(close=True)[1][0]
|
||||||
|
|
||||||
|
if not fname:
|
||||||
|
sg.popup("Cancel", "No filename supplied")
|
||||||
|
raise SystemExit("Cancelling: no filename supplied")
|
||||||
|
else:
|
||||||
|
if os.path.isdir(fname):
|
||||||
|
dirToFileList(str(fname))
|
||||||
|
else:
|
||||||
|
runFiles(str(fname).split(';'))
|
||||||
|
|
||||||
|
input("\nDone\n\n Press enter to quit\n")
|
||||||
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
|||||||
git clone https://git.lurenaud.com/lurenaud/SldwrksExporter.git
|
git clone https://git.lurenaud.com/lurenaud/SldwrksExporter.git
|
||||||
copy SldwrksExporter\scripts\runExport.cmd runExport.cmd
|
copy SldwrksExporter\scripts\runExport.cmd runExport.cmd
|
||||||
cd SldwrksExporter
|
cd SldwrksExporter
|
||||||
powershell -file "install.ps1"
|
powershell -file "scripts\install.ps1"
|
||||||
(goto) 2>nul & del "%~f0" & cmd /c exit /b 10
|
(goto) 2>nul & del "%~f0" & cmd /c exit /b 10
|
Loading…
Reference in New Issue
Block a user