Browse Source

Amélioration du script d'export step

Youen 2 years ago
parent
commit
334b3c5762
  1. 2
      .gitignore
  2. 13
      tools/export-all-parts.py
  3. 10
      tools/export-all-parts.sh

2
.gitignore vendored

@ -1,3 +1,3 @@
*.FCStd1
_local
__pycache__/

13
tools/export-all-parts.py

@ -5,8 +5,6 @@ import FreeCAD as App
import Import
import ImportGui
#script_folder = os.path.dirname(__file__)
#project_folder = os.path.realpath(script_folder + '/..')
project_folder = os.getcwd()
output_folder = project_folder + '-STEP'
@ -56,6 +54,10 @@ def convert_file(file_name, output_format):
if not os.path.exists(output_dir):
os.makedirs(output_dir)
if output_format.lower() == 'stpz':
import stepZ
stepZ.export([main_object], output_path)
else:
Import.export([main_object], output_path)
# close all documents
@ -99,12 +101,17 @@ def convert_assembly(file_name, output_format):
if not os.path.exists(output_dir):
os.makedirs(output_dir)
if output_format.lower() == 'stpz':
import stepZ
stepZ.export([main_object], output_path)
else:
ImportGui.export([main_object], output_path)
# close all documents
while len(FreeCAD.listDocuments().values()) > 0:
FreeCAD.closeDocument(list(FreeCAD.listDocuments().values())[0].Name)
try:
folders = [
'chaudronnerie',
'tubes'
@ -119,6 +126,8 @@ for folder in folders:
convert_file(source_path, 'step')
convert_assembly('vheliotech.FCStd', 'step')
except:
pass
# exit FreeCAD
FreeCADGui.getMainWindow().close()

10
tools/export-all-parts.sh

@ -1,4 +1,12 @@
#!/bin/bash
set -e
SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )
cd $SCRIPT_DIR/..
~/dev/FreeCAD-asm3-Daily-Conda-Py3.10-20221128-glibc2.12-x86_64.AppImage tools/export-all-parts.py
# Check script syntax before starting freecad
python3 -m py_compile tools/export-all-parts.py
# Start freecad to run the script. We must start freecad with GUI (otherwise we can't export colors). We start it hidden in a virtual framebuffer (xvfb) so that it can run cleanly in the background.
xvfb-run ~/dev/FreeCAD-asm3-Daily-Conda-Py3.10-20221128-glibc2.12-x86_64.AppImage tools/export-all-parts.py

Loading…
Cancel
Save