Schalter für minimiertes Laufen von SE dazu
This commit is contained in:
@@ -4,13 +4,14 @@ import argparse
|
|||||||
import win32com.client
|
import win32com.client
|
||||||
import pythoncom
|
import pythoncom
|
||||||
|
|
||||||
def export_assemblies_to_stl(input_dir, output_dir):
|
def export_assemblies_to_stl(input_dir, output_dir, filter_name=None, minimized=False):
|
||||||
pythoncom.CoInitialize()
|
pythoncom.CoInitialize()
|
||||||
|
|
||||||
try:
|
try:
|
||||||
# Solid Edge starten oder verbinden
|
# Solid Edge starten oder verbinden
|
||||||
se_app = win32com.client.Dispatch("SolidEdge.Application")
|
se_app = win32com.client.Dispatch("SolidEdge.Application")
|
||||||
se_app.Visible = True
|
se_app.Visible = True
|
||||||
|
se_app.WindowState = 2 if minimized else 1
|
||||||
|
|
||||||
documents = se_app.Documents
|
documents = se_app.Documents
|
||||||
|
|
||||||
@@ -18,6 +19,8 @@ def export_assemblies_to_stl(input_dir, output_dir):
|
|||||||
|
|
||||||
for filename in os.listdir(input_dir):
|
for filename in os.listdir(input_dir):
|
||||||
if filename.lower().endswith(".asm"):
|
if filename.lower().endswith(".asm"):
|
||||||
|
if filter_name and filter_name.lower() not in filename.lower():
|
||||||
|
continue
|
||||||
asm_path = os.path.join(input_dir, filename)
|
asm_path = os.path.join(input_dir, filename)
|
||||||
stl_filename = os.path.splitext(filename)[0] + ".stl"
|
stl_filename = os.path.splitext(filename)[0] + ".stl"
|
||||||
stl_path = os.path.join(output_dir, stl_filename)
|
stl_path = os.path.join(output_dir, stl_filename)
|
||||||
@@ -29,7 +32,7 @@ def export_assemblies_to_stl(input_dir, output_dir):
|
|||||||
doc = documents.Open(asm_path)
|
doc = documents.Open(asm_path)
|
||||||
# STL exportieren in den Unterordner
|
# STL exportieren in den Unterordner
|
||||||
doc.SaveAs(stl_path)
|
doc.SaveAs(stl_path)
|
||||||
print(f"→ Exported to: {stl_path}")
|
print(f"-> Exported to: {stl_path}")
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
print(f"Error processing {filename}: {e}")
|
print(f"Error processing {filename}: {e}")
|
||||||
finally:
|
finally:
|
||||||
@@ -69,6 +72,8 @@ if __name__ == "__main__":
|
|||||||
parser = argparse.ArgumentParser(description="Exportiert alle .asm-Dateien in einem Ordner nach STL.")
|
parser = argparse.ArgumentParser(description="Exportiert alle .asm-Dateien in einem Ordner nach STL.")
|
||||||
parser.add_argument("--in", dest="input_dir", required=False, help="Ordner mit .asm-Dateien (Standard: WORK oder ../work)")
|
parser.add_argument("--in", dest="input_dir", required=False, help="Ordner mit .asm-Dateien (Standard: WORK oder ../work)")
|
||||||
parser.add_argument("--out", dest="output_dir", required=False, help="Zielordner für STL-Dateien (Standard: work/STL_Export)")
|
parser.add_argument("--out", dest="output_dir", required=False, help="Zielordner für STL-Dateien (Standard: work/STL_Export)")
|
||||||
|
parser.add_argument("--filter", dest="filter_name", required=False, help="Nur Dateien verarbeiten, deren Name diesen String enthält")
|
||||||
|
parser.add_argument("--se-minimized", dest="minimized", action="store_true", default=False, help="Solid Edge minimiert starten")
|
||||||
|
|
||||||
if len(sys.argv) == 2 and sys.argv[1] in ("-h", "--help"):
|
if len(sys.argv) == 2 and sys.argv[1] in ("-h", "--help"):
|
||||||
parser.print_help()
|
parser.print_help()
|
||||||
@@ -97,4 +102,7 @@ if __name__ == "__main__":
|
|||||||
print(f"Input folder not found: {input_dir}")
|
print(f"Input folder not found: {input_dir}")
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
|
|
||||||
export_assemblies_to_stl(input_dir, output_dir)
|
if args.filter_name:
|
||||||
|
print(f"Filtering files containing: '{args.filter_name}'\n")
|
||||||
|
|
||||||
|
export_assemblies_to_stl(input_dir, output_dir, args.filter_name, args.minimized)
|
||||||
|
|||||||
Reference in New Issue
Block a user