Merge branch 'master' of https://git.vhelio.org/vhelio/vheliotech-freecad
This commit is contained in:
commit
99560dc7e8
2 changed files with 8 additions and 1 deletions
Binary file not shown.
|
|
@ -18,8 +18,10 @@ def convert_file(file_name, output_format):
|
||||||
root_objects = []
|
root_objects = []
|
||||||
main_object = None
|
main_object = None
|
||||||
|
|
||||||
|
#print("document: " + doc.Name)
|
||||||
for obj in doc.Objects:
|
for obj in doc.Objects:
|
||||||
if len(obj.Parents) == 0:
|
if len(obj.Parents) == 0:
|
||||||
|
#print(obj.Label)
|
||||||
root_objects.append(obj)
|
root_objects.append(obj)
|
||||||
if obj.Label == doc.Name:
|
if obj.Label == doc.Name:
|
||||||
main_object = obj
|
main_object = obj
|
||||||
|
|
@ -28,7 +30,7 @@ def convert_file(file_name, output_format):
|
||||||
main_object = root_objects[0]
|
main_object = root_objects[0]
|
||||||
|
|
||||||
if main_object is None:
|
if main_object is None:
|
||||||
raise Exception("Can't find main object in file " + file_name)
|
raise Exception("Can't find main object in file " + file_name + " (found " + str(len(root_objects)) + " root object(s), none named like the document " + doc.Name + ")")
|
||||||
|
|
||||||
secondary_objects = []
|
secondary_objects = []
|
||||||
code_obj = doc.getObjectsByLabel('Code_Tube_Draft')
|
code_obj = doc.getObjectsByLabel('Code_Tube_Draft')
|
||||||
|
|
@ -57,6 +59,10 @@ def convert_file(file_name, output_format):
|
||||||
os.makedirs(output_dir)
|
os.makedirs(output_dir)
|
||||||
|
|
||||||
Import.export([main_object], output_path)
|
Import.export([main_object], output_path)
|
||||||
|
|
||||||
|
# close all documents
|
||||||
|
while len(FreeCAD.listDocuments().values()) > 0:
|
||||||
|
FreeCAD.closeDocument(list(FreeCAD.listDocuments().values())[0].Name)
|
||||||
|
|
||||||
folders = [
|
folders = [
|
||||||
'chaudronnerie',
|
'chaudronnerie',
|
||||||
|
|
@ -66,6 +72,7 @@ folders = [
|
||||||
for folder in folders:
|
for folder in folders:
|
||||||
files = os.listdir(project_folder + '/' + folder)
|
files = os.listdir(project_folder + '/' + folder)
|
||||||
for source_file in files:
|
for source_file in files:
|
||||||
|
if not source_file.endswith('.FCStd'): continue
|
||||||
source_path = folder + '/' + source_file
|
source_path = folder + '/' + source_file
|
||||||
print(source_path)
|
print(source_path)
|
||||||
convert_file(source_path, 'step')
|
convert_file(source_path, 'step')
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue