From f6aa227be6b5d45af585638ba978ea66fd2dc4ee Mon Sep 17 00:00:00 2001 From: Yorik van Havre Date: Tue, 31 Jul 2018 19:20:13 -0300 Subject: [PATCH] Arch: Fixed export to IFC of standalone axes --- src/Mod/Arch/importIFC.py | 50 ++++++++++++++++++++++++++------------- 1 file changed, 33 insertions(+), 17 deletions(-) diff --git a/src/Mod/Arch/importIFC.py b/src/Mod/Arch/importIFC.py index ce1291419c..fe0201949e 100644 --- a/src/Mod/Arch/importIFC.py +++ b/src/Mod/Arch/importIFC.py @@ -1430,7 +1430,7 @@ def export(exportList,filename): for obj in objectslist: if obj.isDerivedFrom("Part::Part2DObject"): annotations.append(obj) - elif obj.isDerivedFrom("App::Annotation"): + elif obj.isDerivedFrom("App::Annotation") or (Draft.getType(obj) == "DraftText"): annotations.append(obj) elif obj.isDerivedFrom("Part::Feature"): if obj.Shape: @@ -1519,10 +1519,25 @@ def export(exportList,filename): # export grids if ifctype in ["IfcAxis","IfcAxisSystem","IfcGrid"]: - ifctype = "IfcGrid" ifcaxes = [] ifcpols = [] - for axg in obj.Proxy.getAxisData(obj): + if ifctype == "IfcAxis": + # make sure this axis is not included in something else already + standalone = True + for p in obj.InList: + if hasattr(p,"Axes") and (obj in p.Axes): + if p in objectslist: + axgroups = [] + standalone = False + break + if standalone: + axgroups = [obj.Proxy.getAxisData(obj)] + else: + axgroups = obj.Proxy.getAxisData(obj) + if not axgroups: + continue + ifctype = "IfcGrid" + for axg in axgroups: ifcaxg = [] for ax in axg: p1 = ifcbin.createIfcCartesianPoint(tuple(FreeCAD.Vector(ax[0]).multiply(0.001))) @@ -1543,20 +1558,21 @@ def export(exportList,filename): if len(ifcaxes) > 1: v = ifcaxes[1] if len(ifcaxes) > 2: - v = ifcaxes[2] - if DEBUG: print(str(count).ljust(3)," : ", ifctype, " (",str(len(ifcpols)),"axes ) : ",name) - xvc = ifcbin.createIfcDirection((1.0,0.0,0.0)) - zvc = ifcbin.createIfcDirection((0.0,0.0,1.0)) - ovc = ifcbin.createIfcCartesianPoint((0.0,0.0,0.0)) - gpl = ifcbin.createIfcAxis2Placement3D(ovc,zvc,xvc) - plac = ifcbin.createIfcLocalPlacement(gpl) - cset = ifcfile.createIfcGeometricCurveSet(ifcpols) - #subc = ifcfile.createIfcGeometricRepresentationSubContext('FootPrint','Model',context,None,"MODEL_VIEW",None,None,None,None,None) - srep = ifcfile.createIfcShapeRepresentation(context,'FootPrint',"GeometricCurveSet",ifcpols) - pdef = ifcfile.createIfcProductDefinitionShape(None,None,[srep]) - grid = ifcfile.createIfcGrid(uid,history,name,description,None,plac,pdef,u,v,w) - products[obj.Name] = grid - count += 1 + w = ifcaxes[2] + if u and v: + if DEBUG: print(str(count).ljust(3)," : ", ifctype, " (",str(len(ifcpols)),"axes ) : ",name) + xvc = ifcbin.createIfcDirection((1.0,0.0,0.0)) + zvc = ifcbin.createIfcDirection((0.0,0.0,1.0)) + ovc = ifcbin.createIfcCartesianPoint((0.0,0.0,0.0)) + gpl = ifcbin.createIfcAxis2Placement3D(ovc,zvc,xvc) + plac = ifcbin.createIfcLocalPlacement(gpl) + cset = ifcfile.createIfcGeometricCurveSet(ifcpols) + #subc = ifcfile.createIfcGeometricRepresentationSubContext('FootPrint','Model',context,None,"MODEL_VIEW",None,None,None,None,None) + srep = ifcfile.createIfcShapeRepresentation(context,'FootPrint',"GeometricCurveSet",ifcpols) + pdef = ifcfile.createIfcProductDefinitionShape(None,None,[srep]) + grid = ifcfile.createIfcGrid(uid,history,name,description,None,plac,pdef,u,v,w) + products[obj.Name] = grid + count += 1 continue from ArchComponent import IFCTYPES