From e65a1650b3aa734c2ee34a8089aef6a8da1d0b25 Mon Sep 17 00:00:00 2001 From: DeepSOIC Date: Thu, 29 Oct 2015 23:12:48 +0300 Subject: [PATCH] ArrayFromShape: fix center of mass functionality --- latticeArrayFromShape.py | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/latticeArrayFromShape.py b/latticeArrayFromShape.py index 61123d3..ea15218 100644 --- a/latticeArrayFromShape.py +++ b/latticeArrayFromShape.py @@ -111,18 +111,18 @@ class LatticeArrayFromShape(latticeBaseFeature.LatticeFeature): "Face":"Area", "Shell":"Area", "Solid":"Volume", - "CompSolid":""} + "CompSolid":""}[leaves[0].ShapeType] #Center of mass of a compound is a weghted average of centers # of mass of individual objects. for leaf in leaves: w = 1.0 if not weightAttrib else (getattr(leaf, weightAttrib)) - if child.ShapeType == 'Vertex': - childCM = child.Point + if leaf.ShapeType == 'Vertex': + leafCM = leaf.Point #elif child.ShapeType == 'CompSolid': #todo else: - childCM = child.CenterOfMass - pos += childCM * w + leafCM = leaf.CenterOfMass + pos += leafCM * w totalW += w pos = pos * (1.0/totalW) elif posIsCenterBB: @@ -131,6 +131,7 @@ class LatticeArrayFromShape(latticeBaseFeature.LatticeFeature): pos = bb.Center elif posIsVertex: v = child.Vertexes[obj.TranslateElementIndex - 1] + pos = v.Point else: raise ValueError("latticePolarArrayFromShape: translation mode not implemented: "+obj.TranslateMode)