From 23f1a0ea6859d3567c2b571db332050a3cd1d6a6 Mon Sep 17 00:00:00 2001 From: Jeremy Mack Wright Date: Thu, 17 Sep 2015 18:17:22 -0400 Subject: [PATCH] Fixed Center function to handle multiple solids correctly. --- cadquery/freecad_impl/shapes.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/cadquery/freecad_impl/shapes.py b/cadquery/freecad_impl/shapes.py index ff56de4..26ead3d 100644 --- a/cadquery/freecad_impl/shapes.py +++ b/cadquery/freecad_impl/shapes.py @@ -190,9 +190,11 @@ 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: