Ajout de code pour exporter des assemblages préconfigurés (basique, motorisée, solaire, intégrale)
This commit is contained in:
parent
334b3c5762
commit
dcfeabdb00
4 changed files with 41 additions and 11 deletions
1
.gitignore
vendored
1
.gitignore
vendored
|
|
@ -1,3 +1,4 @@
|
|||
*.FCStd1
|
||||
_local
|
||||
__pycache__/
|
||||
/dist/
|
||||
|
|
|
|||
|
|
@ -6,7 +6,12 @@ import Import
|
|||
import ImportGui
|
||||
|
||||
project_folder = os.getcwd()
|
||||
output_folder = project_folder + '-STEP'
|
||||
output_folder = project_folder + '/dist/STEP'
|
||||
assemblies_output_folder = project_folder + '/dist/FCStd'
|
||||
|
||||
def close_all_docs():
|
||||
while len(FreeCAD.listDocuments().values()) > 0:
|
||||
FreeCAD.closeDocument(list(FreeCAD.listDocuments().values())[0].Name)
|
||||
|
||||
def convert_file(file_name, output_format):
|
||||
doc = App.open(project_folder + '/' + file_name)
|
||||
|
|
@ -60,12 +65,10 @@ def convert_file(file_name, output_format):
|
|||
else:
|
||||
Import.export([main_object], output_path)
|
||||
|
||||
# close all documents
|
||||
while len(FreeCAD.listDocuments().values()) > 0:
|
||||
FreeCAD.closeDocument(list(FreeCAD.listDocuments().values())[0].Name)
|
||||
close_all_docs()
|
||||
|
||||
def convert_assembly(file_name, output_format):
|
||||
print(file_name)
|
||||
print("Exporting assembly " + file_name + "...")
|
||||
|
||||
doc = App.open(project_folder + '/' + file_name)
|
||||
|
||||
|
|
@ -107,9 +110,17 @@ def convert_assembly(file_name, output_format):
|
|||
else:
|
||||
ImportGui.export([main_object], output_path)
|
||||
|
||||
# close all documents
|
||||
while len(FreeCAD.listDocuments().values()) > 0:
|
||||
FreeCAD.closeDocument(list(FreeCAD.listDocuments().values())[0].Name)
|
||||
close_all_docs()
|
||||
|
||||
def export_configuration(doc, config_name, output_filename):
|
||||
print('Generating assembly for configuration '+config_name+'...')
|
||||
|
||||
Gui.Selection.clearSelection()
|
||||
Gui.Selection.addSelection('vheliotech','Model','Configurations.'+doc.getObjectsByLabel(config_name)[0].Name+'.')
|
||||
Gui.runCommand('Asm4_applyConfiguration')
|
||||
Gui.Selection.clearSelection()
|
||||
|
||||
doc.saveAs(assemblies_output_folder + '/' + output_filename + '.FCStd')
|
||||
|
||||
try:
|
||||
folders = [
|
||||
|
|
@ -126,9 +137,18 @@ try:
|
|||
convert_file(source_path, 'step')
|
||||
|
||||
convert_assembly('vheliotech.FCStd', 'step')
|
||||
except:
|
||||
pass
|
||||
|
||||
'''doc = App.open(project_folder + '/vheliotech.FCStd')
|
||||
export_configuration(doc, 'Config_Integrale', 'vheliotech-config-integrale')
|
||||
export_configuration(doc, 'Config_Solaire', 'vheliotech-config-solaire')
|
||||
export_configuration(doc, 'Config_Motorisee', 'vheliotech-config-motorisee')
|
||||
export_configuration(doc, 'Config_Basique', 'vheliotech-config-basique')
|
||||
close_all_docs()'''
|
||||
|
||||
except Exception as e:
|
||||
print(e)
|
||||
|
||||
# exit FreeCAD
|
||||
close_all_docs()
|
||||
FreeCADGui.getMainWindow().close()
|
||||
|
||||
|
|
|
|||
|
|
@ -2,11 +2,20 @@
|
|||
|
||||
set -e
|
||||
|
||||
# Set the path to your FreeCAD executable here
|
||||
FREECAD=~/dev/FreeCAD-asm3-Daily-Conda-Py3.10-20221128-glibc2.12-x86_64.AppImage
|
||||
|
||||
SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )
|
||||
cd $SCRIPT_DIR/..
|
||||
|
||||
rm -rf ./dist
|
||||
|
||||
# Check script syntax before starting freecad
|
||||
python3 -m py_compile tools/export-all-parts.py
|
||||
|
||||
# Export all versioned files
|
||||
mkdir -p dist/FCStd
|
||||
git archive HEAD . | tar -x -C dist/FCStd
|
||||
|
||||
# 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
|
||||
xvfb-run $FREECAD tools/export-all-parts.py
|
||||
|
|
|
|||
BIN
vheliotech.FCStd
BIN
vheliotech.FCStd
Binary file not shown.
Loading…
Add table
Add a link
Reference in a new issue