working !
This commit is contained in:
parent
114babf533
commit
11ab406847
@ -24,6 +24,4 @@ Script to generate production files (part -> step, dxf, pdf)
|
||||
|
||||
## Use:
|
||||
|
||||
`.\run.py path\Part1` (without extension) will generate step, pdf and dxf in path
|
||||
|
||||
For multiple files, add them in argument
|
||||
`.\run.py path\toFloderOfFiles` will generate step, pdf and dxf in a export folder
|
||||
|
@ -1,5 +1,5 @@
|
||||
$inputFilePath=$args[0]+".SLDDRW"
|
||||
$outFilePath=$args[0]
|
||||
$outFilePath=$args[1]
|
||||
|
||||
$ScriptDir = Split-Path $script:MyInvocation.MyCommand.Path
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
$inputFilePath=$args[0]+".SLDPRT"
|
||||
$outFilePath=$args[0]
|
||||
$outFilePath=$args[1]
|
||||
|
||||
$ScriptDir = Split-Path $script:MyInvocation.MyCommand.Path
|
||||
|
||||
|
53
run.py
53
run.py
@ -1,4 +1,5 @@
|
||||
# example: .\run.py path\Part1
|
||||
# example: .\run.py path_to_folder\
|
||||
|
||||
import os
|
||||
import sys
|
||||
import pathlib
|
||||
@ -6,17 +7,51 @@ import subprocess
|
||||
from rich.progress import track
|
||||
|
||||
# folder input
|
||||
if(sys.argv[1]):
|
||||
pass
|
||||
input = next(os.walk(sys.argv[1]))
|
||||
files = input[2]
|
||||
path = input[0]
|
||||
|
||||
|
||||
|
||||
files = sys.argv[1:] # take files given in input
|
||||
currentPath = str(pathlib.Path().resolve())
|
||||
|
||||
for i in track(files, description="Exporting...", total=len(files)):
|
||||
# print("files: ", files)
|
||||
# print("currentPath :", currentPath)
|
||||
# print("path: ", path)
|
||||
|
||||
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("Parts: ", partFiles)
|
||||
# print("Drawings: ", drwgFiles)
|
||||
|
||||
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")
|
||||
|
||||
|
||||
|
||||
outputFolder = str(path) + "\\export\\"
|
||||
# print("Out folder: ", outputFolder)
|
||||
|
||||
# create export directory
|
||||
if not os.path.exists(outputFolder):
|
||||
os.makedirs(outputFolder)
|
||||
print("Export folder created")
|
||||
|
||||
# part files
|
||||
for i in track(partWithoutExention, description="Exporting step 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
|
||||
commandstep = "PowerShell -NoProfile -ExecutionPolicy Bypass -File " + currentPath + '\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 + '"'
|
||||
# print(commandPdfDxf)
|
||||
subprocess.run(commandPdfDxf, capture_output=True)
|
||||
|
Loading…
Reference in New Issue
Block a user