ArrayFromShape: fix center of mass functionality
This commit is contained in:
parent
0b54ac30dc
commit
e65a1650b3
|
@ -111,18 +111,18 @@ class LatticeArrayFromShape(latticeBaseFeature.LatticeFeature):
|
||||||
"Face":"Area",
|
"Face":"Area",
|
||||||
"Shell":"Area",
|
"Shell":"Area",
|
||||||
"Solid":"Volume",
|
"Solid":"Volume",
|
||||||
"CompSolid":""}
|
"CompSolid":""}[leaves[0].ShapeType]
|
||||||
#Center of mass of a compound is a weghted average of centers
|
#Center of mass of a compound is a weghted average of centers
|
||||||
# of mass of individual objects.
|
# of mass of individual objects.
|
||||||
for leaf in leaves:
|
for leaf in leaves:
|
||||||
w = 1.0 if not weightAttrib else (getattr(leaf, weightAttrib))
|
w = 1.0 if not weightAttrib else (getattr(leaf, weightAttrib))
|
||||||
if child.ShapeType == 'Vertex':
|
if leaf.ShapeType == 'Vertex':
|
||||||
childCM = child.Point
|
leafCM = leaf.Point
|
||||||
#elif child.ShapeType == 'CompSolid':
|
#elif child.ShapeType == 'CompSolid':
|
||||||
#todo
|
#todo
|
||||||
else:
|
else:
|
||||||
childCM = child.CenterOfMass
|
leafCM = leaf.CenterOfMass
|
||||||
pos += childCM * w
|
pos += leafCM * w
|
||||||
totalW += w
|
totalW += w
|
||||||
pos = pos * (1.0/totalW)
|
pos = pos * (1.0/totalW)
|
||||||
elif posIsCenterBB:
|
elif posIsCenterBB:
|
||||||
|
@ -131,6 +131,7 @@ class LatticeArrayFromShape(latticeBaseFeature.LatticeFeature):
|
||||||
pos = bb.Center
|
pos = bb.Center
|
||||||
elif posIsVertex:
|
elif posIsVertex:
|
||||||
v = child.Vertexes[obj.TranslateElementIndex - 1]
|
v = child.Vertexes[obj.TranslateElementIndex - 1]
|
||||||
|
pos = v.Point
|
||||||
else:
|
else:
|
||||||
raise ValueError("latticePolarArrayFromShape: translation mode not implemented: "+obj.TranslateMode)
|
raise ValueError("latticePolarArrayFromShape: translation mode not implemented: "+obj.TranslateMode)
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user