def centerOf(obj): if obj is None: return FreeCAD.Vector() elif isDerivedFrom(obj, "Part::Feature"): return Shapes.center(obj.Shape) elif isDerivedFrom(obj, "Mesh::Feature"): return Meshes.center(obj.Mesh) else: raise TypeError
def execute(self, obj): if obj.Origin is None: obj.Shape = Part.Shape() return if isDerivedFrom(obj.Origin, "Part::Compound"): ftrs = obj.Origin.Links elif isDerivedFrom(obj.Origin, Compound): ftrs = obj.Origin.Sources else: raise TypeError if isDerivedFrom(obj, "Part::FeaturePython"): shapes = [] for ftr in ftrs: shape = Shapes.reshape(ftr.Shape) center = Shapes.center(shape) if center is None: R = FreeCAD.Vector(0,0,0) else: R = center - obj.Base shift = R*obj.Ratio - R shape.Placement = FreeCAD.Placement(shift, FreeCAD.Rotation()) shapes.append(shape) obj.Shape = Shapes.compound(shapes) obj.Outfaces = trace(obj) if P.autotrace else [] elif isDerivedFrom(obj, "Mesh::FeaturePython"): meshes = [] for ftr in ftrs: mesh = meshOf(ftr, remeshed=True) center = Meshes.center(mesh) if center is None: R = FreeCAD.Vector(0,0,0) else: R = center - obj.Base shift = R*obj.Ratio - R mesh.translate(*shift) meshes.append(mesh) obj.Mesh = Meshes.compound(meshes) else: raise TypeError