Arch: option to save a list of exported objects together with an ifc file - fixes #1371

This commit is contained in:
Yorik van Havre 2014-02-10 12:54:27 -02:00
parent d81803de05
commit c260ede083
3 changed files with 58 additions and 3 deletions

File diff suppressed because one or more lines are too long

View File

@ -246,6 +246,26 @@
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_4">
<item>
<widget class="Gui::PrefCheckBox" name="gui::prefcheckbox_3">
<property name="toolTip">
<string>If this is checked, a text file will be exported together with the ifc file, containing the list of exported objects, for verification purposes.</string>
</property>
<property name="text">
<string>Save a list of exported objects</string>
</property>
<property name="prefEntry" stdset="0">
<cstring>IfcExportList</cstring>
</property>
<property name="prefPath" stdset="0">
<cstring>Mod/Arch</cstring>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</widget>
</item>

View File

@ -897,6 +897,7 @@ def export(exportList,filename):
ifcWriter.PRECISION = Draft.precision()
p = FreeCAD.ParamGet("User parameter:BaseApp/Preferences/Mod/Arch")
scaling = p.GetFloat("IfcScalingFactor",1.0)
exporttxt = p.GetBool("IfcExportList",False)
application = "FreeCAD"
ver = FreeCAD.Version()
version = ver[0]+"."+ver[1]+" build"+ver[2]
@ -904,6 +905,7 @@ def export(exportList,filename):
company = FreeCAD.ActiveDocument.Company
project = FreeCAD.ActiveDocument.Name
ifc = ifcWriter.IfcDocument(filename,project,owner,company,application,version)
txt = []
# get all children and reorder list to get buildings and floors processed first
objectslist = Draft.getGroupContents(exportList,walls=True,addgroups=True)
@ -935,6 +937,18 @@ def export(exportList,filename):
if obj.isDerivedFrom("Part::Feature"):
print "IFC export: error retrieving the shape of object ", obj.Name
continue
spacer = ""
for i in range(30-len(obj.Name)):
spacer += " "
if otype in ["Structure","Window"]:
if hasattr(obj,"Role"):
tp = obj.Role
else:
tp = otype
else:
tp = otype
txt.append(obj.Name + spacer + tp)
if otype == "Building":
ifc.addBuilding( name=name )
@ -997,6 +1011,27 @@ def export(exportList,filename):
ifc.write()
if exporttxt:
import time, os
txtstring = "List of objects exported by FreeCAD in file\n"
txtstring += filename + "\n"
txtstring += "On " + time.ctime() + "\n"
txtstring += "\n"
txtstring += str(len(txt)) + " objects exported:\n"
txtstring += "\n"
txtstring += "Nr Name Type\n"
txtstring += "\n"
for i in range(len(txt)):
idx = str(i+1)
sp = ""
for j in range(8-len(idx)):
sp += " "
txtstring += idx + sp + txt[i] + "\n"
txtfile = os.path.splitext(filename)[0]+".txt"
f = pyopen(txtfile,"wb")
f.write(txtstring)
f.close()
def explore(filename=None):
"explore the contents of an ifc file in a Qt dialog"