From aa01be8d9e54f21c27280f3b45e3bde18889063b Mon Sep 17 00:00:00 2001 From: Jeremy Mack Wright Date: Fri, 18 Sep 2015 08:21:33 -0400 Subject: [PATCH] Fixed Shape.Center when called on a compound with multiple solids. --- CadQuery/Libs/cadquery/freecad_impl/shapes.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/CadQuery/Libs/cadquery/freecad_impl/shapes.py b/CadQuery/Libs/cadquery/freecad_impl/shapes.py index ff56de4..b870271 100644 --- a/CadQuery/Libs/cadquery/freecad_impl/shapes.py +++ b/CadQuery/Libs/cadquery/freecad_impl/shapes.py @@ -190,9 +190,10 @@ class Shape(object): # If there are no Solids, we're probably dealing with a Face or something similar if len(self.Solids()) == 0: return Vector(self.wrapped.CenterOfMass) - else: - # TODO: compute the weighted average instead of using the first solid + elif len(self.Solids()) == 1: return Vector(self.Solids()[0].wrapped.CenterOfMass) + elif len(self.Solids()) > 1: + return self.CombinedCenter(self.Solids()) elif isinstance(self.wrapped, FreeCADPart.Solid): return Vector(self.wrapped.CenterOfMass) else: