Skip to content

Commit

Permalink
Arch: option to save a list of exported objects together with an ifc …
Browse files Browse the repository at this point in the history
…file - fixes #1371
  • Loading branch information
yorikvanhavre committed Feb 10, 2014
1 parent d81803d commit c260ede
Show file tree
Hide file tree
Showing 3 changed files with 58 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/Mod/Arch/Arch_rc.py

Large diffs are not rendered by default.

20 changes: 20 additions & 0 deletions src/Mod/Arch/Resources/ui/archprefs-import.ui
Expand Up @@ -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>
Expand Down
35 changes: 35 additions & 0 deletions src/Mod/Arch/importIFC.py
Expand Up @@ -897,13 +897,15 @@ 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]
owner = FreeCAD.ActiveDocument.CreatedBy
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)
Expand Down Expand Up @@ -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 )
Expand Down Expand Up @@ -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"
Expand Down

0 comments on commit c260ede

Please sign in to comment.