From a698748ac62c5f001a7d1cf6021d9723cd005ec6 Mon Sep 17 00:00:00 2001 From: balrobs <73989799+balrobs@users.noreply.github.com> Date: Fri, 4 Jun 2021 01:20:17 +0200 Subject: [PATCH] [Arch] Fix errors when exporting struchtures to IFC2X3 format when trying to export structures to IFC2X3 there are some problems due to the fact, that the actual code uses functions not suitable for IFC2X3 this commit fixes this issues see forum post: https://forum.freecadweb.org/viewtopic.php?f=39&t=54286&start=30#p507877 --- src/Mod/Arch/exportIFCStructuralTools.py | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/src/Mod/Arch/exportIFCStructuralTools.py b/src/Mod/Arch/exportIFCStructuralTools.py index 06607daa28..b473afa751 100644 --- a/src/Mod/Arch/exportIFCStructuralTools.py +++ b/src/Mod/Arch/exportIFCStructuralTools.py @@ -44,12 +44,12 @@ def setup(ifcfile,ifcbin,scale): owh = ifcfile.by_type("IfcOwnerHistory")[0] prj = ifcfile.by_type("IfcProject")[0] ctx = createStructuralContext(ifcfile) - if ifcfile.wrapped_data.schema_name == "IFC2X3": + if ifcfile.wrapped_data.schema_name() == "IFC2X3": mod = ifcfile.createIfcStructuralAnalysisModel(uid(),owh,"Structural Analysis Model",None,None,"NOTDEFINED",None,None,None) else: pla = ifcbin.createIfcLocalPlacement() mod = ifcfile.createIfcStructuralAnalysisModel(uid(),owh,"Structural Analysis Model",None,None,"NOTDEFINED",None,None,None,pla) - rel = ifcfile.createIfcRelDeclares(uid(),owh,None,None,prj,[mod]) + rel = ifcfile.createIfcRelDeclares(uid(),owh,None,None,prj,[mod]) def createStructuralContext(ifcfile): @@ -89,7 +89,10 @@ def createStructuralNode(ifcfile,ifcbin,point): # for now we don't create any boundary condition cnd = None pla = ifcbin.createIfcLocalPlacement() - prd = ifcfile.createIfcStructuralPointConnection(uid(),owh,'Vertex',None,None,pla,psh,cnd,None) + if ifcfile.wrapped_data.schema_name() == "IFC2X3": + prd = ifcfile.createIfcStructuralPointConnection(uid(),owh,'Vertex',None,None,pla,psh,cnd) + else: + prd = ifcfile.createIfcStructuralPointConnection(uid(),owh,'Vertex',None,None,pla,psh,cnd,None) return prd @@ -137,25 +140,29 @@ def createStructuralMember(ifcfile,ifcbin,obj): v1 = edge.Vertexes[-1].Point.multiply(scaling) cp1 = ifcbin.createIfcCartesianPoint(tuple(v0)) cp2 = ifcbin.createIfcCartesianPoint(tuple(v1)) - upv = ifcbin.createIfcDirection((0,0,1)) pla = ifcbin.createIfcLocalPlacement() vp1 = ifcfile.createIfcVertexPoint(cp1) vp2 = ifcfile.createIfcVertexPoint(cp2) edg = ifcfile.createIfcEdge(vp1,vp2) rep = ifcfile.createIfcTopologyRepresentation(ctx,'Analysis','Edge',[edg]) psh = ifcfile.createIfcProductDefinitionShape(None,None,[rep]) - prd = ifcfile.createIfcStructuralCurveMember(uid(),owh,obj.Label,None,None,pla,psh,"RIGID_JOINED_MEMBER",upv) + if ifcfile.wrapped_data.schema_name() == "IFC2X3": + prd = ifcfile.createIfcStructuralCurveMember(uid(),owh,obj.Label,None,None,pla,psh,"RIGID_JOINED_MEMBER") + else: + upv = ifcbin.createIfcDirection((0,0,1)) + prd = ifcfile.createIfcStructuralCurveMember(uid(),owh,obj.Label,None,None,pla,psh,"RIGID_JOINED_MEMBER",upv) # check for existing connection nodes for v in [v0,v1]: vk = tuple(v) if vk in structural_nodes: if structural_nodes[vk]: + # there is already another member using this point n = structural_nodes[vk] else: # there is another member with same point, create a new node n = createStructuralNode(ifcfile,ifcbin,v) structural_nodes[vk] = n - ifcfile.createIfcRelConnectsStructuralMember(uid(),None,None,None,prd,n,None,None,None,None); + ifcfile.createIfcRelConnectsStructuralMember(uid(),owh,None,None,prd,n,None,None,None,None) else: # just add the point, no other member using it yet structural_nodes[vk] = None