@ -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 ( )