Skip to content

Commit

Permalink
Arch: stronger handling of errors in IFC export
Browse files Browse the repository at this point in the history
  • Loading branch information
yorikvanhavre committed May 17, 2014
1 parent 4906d89 commit 44e354b
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 11 deletions.
12 changes: 8 additions & 4 deletions src/Mod/Arch/ifcWriter.py
Expand Up @@ -470,10 +470,14 @@ def addProduct(self,elttype,shapes,storey=None,placement=None,name="Unnamed elem
elt = create(self._fileobject,elttype,[uid(),self._owner,name,description,None,placement,prd,None]+extra)
except:
print "unable to create an ",elttype, " with attributes: ",[uid(),self._owner,name,description,None,placement,prd,None]+extra
print "supported attributes are: "
o = IfcImport.Entity(elttype)
print getPropertyNames(o)
raise
try:
o = IfcImport.Entity(elttype)
print "supported attributes are: "
print getPropertyNames(o)
except:
print "unable to create an element of type '"+elttype+"'"
print "WARNING: skipping object '"+name+"' of type "+elttype
return None
self.BuildingProducts.append(elt)
if not storey:
if self.Storeys:
Expand Down
22 changes: 15 additions & 7 deletions src/Mod/Arch/importIFC.py
Expand Up @@ -969,6 +969,9 @@ def export(exportList,filename):
others.append(obj)
objectslist = buildings + floors + others
if DEBUG: print "adding ", len(objectslist), " objects"

global unprocessed
unprocessed = []

# process objects
for obj in objectslist:
Expand All @@ -995,12 +998,6 @@ def export(exportList,filename):
ifctype = "ReinforcingBar"

if DEBUG: print "adding " + obj.Label + " as Ifc" + ifctype

# writing text log
spacer = ""
for i in range(36-len(obj.Label)):
spacer += " "
txt.append(obj.Label + spacer + ifctype)

# writing IFC data
if obj.isDerivedFrom("App::DocumentObjectGroup"):
Expand Down Expand Up @@ -1074,7 +1071,15 @@ def export(exportList,filename):
if DEBUG: print " Type ",ifctype," is not supported by the current version of IfcOpenShell. Exporting as IfcBuildingElementProxy instead"
ifctype = "IfcBuildingElementProxy"
extra = ["ELEMENT"]
ifc.addProduct( ifctype, representation, storey=parent, placement=placement, name=name, description=descr, extra=extra )
p = ifc.addProduct( ifctype, representation, storey=parent, placement=placement, name=name, description=descr, extra=extra )
if p:
# writing text log
spacer = ""
for i in range(36-len(obj.Label)):
spacer += " "
txt.append(obj.Label + spacer + ifctype)
else:
unprocessed.append(obj)
else:
if DEBUG: print "IFC export: object type ", otype, " is not supported yet."

Expand Down Expand Up @@ -1103,6 +1108,9 @@ def export(exportList,filename):
f.close()

FreeCAD.ActiveDocument.recompute()

if unprocessed:
print "Some objects were not exported. See importIFC.unprocessed"


def explore(filename=None):
Expand Down

0 comments on commit 44e354b

Please sign in to comment.