From eceebf4d71b6f1540bcbbb49e5682a77fc8291b1 Mon Sep 17 00:00:00 2001 From: Yorik van Havre Date: Sat, 4 Jan 2014 11:30:15 -0200 Subject: [PATCH] Arch: Fixes to ifc importer to make it compatible with ifcopenshell 0.4 --- src/Mod/Arch/importIFC.py | 24 ++++++++++++++++-------- 1 file changed, 16 insertions(+), 8 deletions(-) diff --git a/src/Mod/Arch/importIFC.py b/src/Mod/Arch/importIFC.py index 13ca34350..325e13dd6 100644 --- a/src/Mod/Arch/importIFC.py +++ b/src/Mod/Arch/importIFC.py @@ -170,7 +170,10 @@ def read(filename): objparentid = int(str(getAttr(r,"RelatingBuildingElement")).split("=")[0].strip("#")) else: - obj = IfcImport.Get() + if hasattr(IfcImport, 'GetBrepData'): + obj = IfcImport.GetBrepData() + else: + obj = IfcImport.Get() objid = obj.id idx = objid objname = obj.name @@ -244,13 +247,18 @@ def read(filename): else: # treat as meshes - if DEBUG: print "Warning: Object without shape: ",objid, " ", objtype - me,pl = getMesh(obj) - nobj = FreeCAD.ActiveDocument.addObject("Mesh::Feature",n) - nobj.Label = n - nobj.Mesh = me - nobj.Placement = pl - + if DEBUG: print "Warning: Object without shape: ",objid, " ", objtype + if hasattr(obj,"mesh"): + if not hasattr(obj.mesh, 'verts'): + obj = IfcImport.Get() # Get triangulated rep of same product + me,pl = getMesh(obj) + nobj = FreeCAD.ActiveDocument.addObject("Mesh::Feature",n) + nobj.Label = n + nobj.Mesh = me + nobj.Placement = pl + else: + if DEBUG: print "Error: Skipping object without mesh: ",objid, " ", objtype + # registering object number and parent if objparentid > 0: ifcParents[objid] = [objparentid,not (objtype in subtractiveTypes)]