Compare commits

..

11 Commits
latest ... main

Author SHA1 Message Date
Lurenaud
cca4ccbb8c update readme 2023-02-10 13:55:56 +01:00
Lurenaud
33ee735f83 working :) 2023-02-10 13:55:26 +01:00
Lurenaud
99780c1cb8 Readme, update export command 2023-02-10 13:55:17 +01:00
Lurenaud
0d966f0556 support multiple files input from GUI 2023-02-10 13:31:09 +01:00
Lurenaud
fbc1e82651 change script name 2023-02-10 12:28:32 +01:00
Lurenaud
a20779495d Up readme after cleaning 2023-02-07 19:58:30 +01:00
Lurenaud
3b36821681 cleaning 2023-02-07 19:57:21 +01:00
Lurenaud
9d7e5abcf8 Readme typo 2023-02-07 19:54:26 +01:00
Lurenaud
28619792b2 Update readme 2023-02-07 19:52:44 +01:00
Lurenaud
d9aad27449 Update readme 2023-02-07 19:49:32 +01:00
Lurenaud
5036cc0eba add single file script called export 2023-02-07 19:47:37 +01:00
7 changed files with 114 additions and 3 deletions

View File

@ -2,6 +2,14 @@
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:
- 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
will dowwnload the git repo, install everything and launch the program.
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
1. Get the code:
@ -30,3 +38,13 @@ copy paste this line in an **Administrator** powershell or windows terminal
## Use:
In terminal: `.\gui.py path\toFloderOfFiles` will generate step, pdf and dxf in a export folder
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
View File

@ -18,7 +18,7 @@ else:
else:
# sg.popup('The filename you chose was', fname)
print(fname)
cmd = "python scripts/run.py " + str(fname)
cmd = "python scripts/runFolder.py " + str(fname)
print(cmd)
p = subprocess.run(cmd, shell=True)

93
scripts/export.py Normal file
View 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")

View File

@ -1,5 +1,5 @@
git clone https://git.lurenaud.com/lurenaud/SldwrksExporter.git
copy SldwrksExporter\scripts\runExport.cmd runExport.cmd
cd SldwrksExporter
powershell -file "install.ps1"
powershell -file "scripts\install.ps1"
(goto) 2>nul & del "%~f0" & cmd /c exit /b 10