Amélioration du script d'export step
This commit is contained in:
parent
05e6e4e590
commit
334b3c5762
3 changed files with 35 additions and 18 deletions
|
|
@ -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,7 +54,11 @@ def convert_file(file_name, output_format):
|
|||
if not os.path.exists(output_dir):
|
||||
os.makedirs(output_dir)
|
||||
|
||||
Import.export([main_object], output_path)
|
||||
if output_format.lower() == 'stpz':
|
||||
import stepZ
|
||||
stepZ.export([main_object], output_path)
|
||||
else:
|
||||
Import.export([main_object], output_path)
|
||||
|
||||
# close all documents
|
||||
while len(FreeCAD.listDocuments().values()) > 0:
|
||||
|
|
@ -99,26 +101,33 @@ def convert_assembly(file_name, output_format):
|
|||
if not os.path.exists(output_dir):
|
||||
os.makedirs(output_dir)
|
||||
|
||||
ImportGui.export([main_object], output_path)
|
||||
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)
|
||||
|
||||
folders = [
|
||||
'chaudronnerie',
|
||||
'tubes'
|
||||
]
|
||||
try:
|
||||
folders = [
|
||||
'chaudronnerie',
|
||||
'tubes'
|
||||
]
|
||||
|
||||
for folder in folders:
|
||||
files = os.listdir(project_folder + '/' + folder)
|
||||
for source_file in files:
|
||||
if not source_file.endswith('.FCStd'): continue
|
||||
source_path = folder + '/' + source_file
|
||||
print(source_path)
|
||||
convert_file(source_path, 'step')
|
||||
for folder in folders:
|
||||
files = os.listdir(project_folder + '/' + folder)
|
||||
for source_file in files:
|
||||
if not source_file.endswith('.FCStd'): continue
|
||||
source_path = folder + '/' + source_file
|
||||
print(source_path)
|
||||
convert_file(source_path, 'step')
|
||||
|
||||
convert_assembly('vheliotech.FCStd', 'step')
|
||||
convert_assembly('vheliotech.FCStd', 'step')
|
||||
except:
|
||||
pass
|
||||
|
||||
# exit FreeCAD
|
||||
FreeCADGui.getMainWindow().close()
|
||||
|
|
|
|||
|
|
@ -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…
Add table
Add a link
Reference in a new issue