From 4bbee73f8ddf2371a0fa77514320238f26e58bce Mon Sep 17 00:00:00 2001 From: Yorik van Havre Date: Sat, 6 Jul 2019 13:51:11 -0300 Subject: [PATCH] Arch: Bugfixes in IFC exporter - Wrong colors of multi-solid cloned objects - Wrong geometry for multilayer walls based on single lines - Wrong geometry for rotated solids inside multi-solid objects --- src/Mod/Arch/importIFC.py | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/src/Mod/Arch/importIFC.py b/src/Mod/Arch/importIFC.py index 4b0ddda662..09676904ae 100644 --- a/src/Mod/Arch/importIFC.py +++ b/src/Mod/Arch/importIFC.py @@ -3040,7 +3040,7 @@ def getProfile(ifcfile,p): d = vec(p.Edges[0]) d.normalize() pxvc = ifcbin.createIfcDirection(tuple(d)) - povc = ifcbin.createIfcCartesianPoint((0.0,0.0)) + povc = ifcbin.createIfcCartesianPoint(tuple(p.CenterOfMass)) pt = ifcbin.createIfcAxis2Placement2D(povc,pxvc) #semiPerimeter = p.Length/2 #diff = math.sqrt(semiPerimeter**2 - 4*p.Area) @@ -3262,17 +3262,17 @@ def getRepresentation(ifcfile,context,obj,forcebrep=False,subtraction=False,tess # old method solids = [] + + # if this is a clone, place back the shape in null position + if tostore: + fcshape.Placement = FreeCAD.Placement() + if fcshape.Solids: dataset = fcshape.Solids else: dataset = fcshape.Shells #if DEBUG: print("Warning! object contains no solids") - # if this is a clone, place back the shapes in null position - if tostore: - for shape in dataset: - shape.Placement = FreeCAD.Placement() - for fcsolid in dataset: fcsolid.scale(0.001) # to meters faces = [] @@ -3357,6 +3357,7 @@ def getRepresentation(ifcfile,context,obj,forcebrep=False,subtraction=False,tess if shapes: + colorshapes = shapes # to keep track of individual shapes for coloring below if tostore: subrep = ifcfile.createIfcShapeRepresentation(context,'Body',solidType,shapes) xvc = ifcbin.createIfcDirection((1.0,0.0,0.0)) @@ -3376,6 +3377,7 @@ def getRepresentation(ifcfile,context,obj,forcebrep=False,subtraction=False,tess solidType = "MappedRepresentation" # set surface style + shapecolor = None diffusecolor = None transparency = 0.0 @@ -3396,18 +3398,18 @@ def getRepresentation(ifcfile,context,obj,forcebrep=False,subtraction=False,tess transparency = obj.ViewObject.Transparency/100.0 if hasattr(obj.ViewObject,"DiffuseColor"): diffusecolor = obj.ViewObject.DiffuseColor - if shapecolor: + if shapecolor and (shapetype != "clone"): # cloned objects are already colored key = None rgbt = [shapecolor+(transparency,) for shape in shapes] if diffusecolor \ and (len(diffusecolor) == len(obj.Shape.Faces)) \ - and (len(obj.Shape.Solids) == len(shapes)): + and (len(obj.Shape.Solids) == len(colorshapes)): i = 0 rgbt = [] for sol in obj.Shape.Solids: rgbt.append(diffusecolor[i]) i += len(sol.Faces) - for i,shape in enumerate(shapes): + for i,shape in enumerate(colorshapes): key = rgbt[i] #if hasattr(obj,"Material"): # if obj.Material: