示例#1
0
    def process(self):
        if not any(socket.is_linked for socket in self.outputs):
            return

        solids_in = self.inputs['Solid'].sv_get()

        def check(solid):
            return solid.isClosed()

        closed_out = map_recursive(check, solids_in, data_types=(Part.Shape, ))

        self.outputs['IsClosed'].sv_set(closed_out)
示例#2
0
    def process(self):
        if not any(socket.is_linked for socket in self.outputs):
            return

        solids_in = self.inputs['Solid'].sv_get()

        def refine(solid):
            return solid.removeSplitter()

        solids_out = map_recursive(refine,
                                   solids_in,
                                   data_types=(Part.Shape, ))

        self.outputs['Solid'].sv_set(solids_out)
示例#3
0
    def process(self):
        if not any(socket.is_linked for socket in self.outputs):
            return

        solids_in = self.inputs['Solid'].sv_get()

        def calc(solid):
            if not isinstance(solid, Part.Solid):
                solid = Part.makeSolid(solid)
            c = solid.Area
            return [c]

        area_out = map_recursive(calc, solids_in, data_types=(Part.Shape, ))

        self.outputs['Area'].sv_set(area_out)
示例#4
0
    def process(self):
        if not any(socket.is_linked for socket in self.outputs):
            return

        faces_in = self.inputs['SolidFace'].sv_get()

        def calc(face_surface):
            if not is_solid_face_surface(face_surface):
                face_surface = surface_to_freecad(face_surface, make_face=True)
            a = face_surface.face.Area
            return [a]

        area_out = map_recursive(calc, faces_in, data_types=(SvSurface, ))

        self.outputs['Area'].sv_set(area_out)
示例#5
0
    def process(self):
        if not any(socket.is_linked for socket in self.outputs):
            return

        solids_in = self.inputs['Solid'].sv_get()

        def calc(solid):
            if not isinstance(solid, Part.Solid):
                solid = Part.makeSolid(solid)
            c = solid.CenterOfMass
            return tuple(c)

        centers_out = map_recursive(calc, solids_in, data_types=(Part.Shape, ))

        self.outputs['Center'].sv_set(centers_out)
示例#6
0
    def process(self):
        if not any(s.is_linked for s in self.outputs):
            return

        solids_in = self.inputs['Solid'].sv_get()

        def calc_bbox(solid):
            if self.optimal:
                return solid.optimalBoundingBox(False)
            else:
                return solid.BoundBox

        def get_verts(box):
            pts = [box.getPoint(i) for i in range(8)]
            return [(p.x, p.y, p.z) for p in pts]

        def get_center(box):
            p = box.Center
            return (p.x, p.y, p.z)

        def make_box(box):
            origin = Base.Vector(box.XMin, box.YMin, box.ZMin)
            return Part.makeBox(box.XLength, box.YLength, box.ZLength, origin)

        def to_dict(box):
            return dict(XMin=[box.XMin],
                        XMax=[box.XMax],
                        XSize=[box.XLength],
                        YMin=[box.YMin],
                        YMax=[box.YMax],
                        YSize=[box.YLength],
                        ZMin=[box.ZMin],
                        ZMax=[box.ZMax],
                        ZSize=[box.ZLength],
                        Center=get_center(box),
                        Vertices=get_verts(box),
                        Box=make_box(box))

        results = map_recursive(calc_bbox,
                                solids_in,
                                data_types=(Part.Shape, ))
        bboxes = unzip_dict_recursive(results,
                                      item_type=Base.BoundBox,
                                      to_dict=to_dict)

        for key in bboxes:
            self.outputs[key].sv_set(bboxes[key])
示例#7
0
def to_solid_recursive(data):
    return map_recursive(to_solid,
                         data,
                         data_types=(SvCurve, SvSurface, Part.Shape))