Example #1
0
    def process(self):

        color_input = self.inputs['Colors']
        if color_input.is_linked:
            abc = self.inputs['Colors'].sv_get()
            data = dataCorrect_np(abc)
        else:
            data = [[self.unit_color[:]]]

        if self.output_numpy:
            unpack_func = unpack_np if isinstance(
                data[0], ndarray) else unpack_list_to_np
        else:
            unpack_func = unpack_list

        if self.selected_mode == 'HSV':
            transform_func = rgb_to_hsv
        elif self.selected_mode == 'HSL':
            transform_func = rgb_to_hsl

        out = [[] for s in self.outputs]
        for obj in data:
            if not self.selected_mode == 'RGB':
                cols = transform_func(array(obj))
                obj_cols = unpack_func(cols)
            else:
                obj_cols = unpack_func(obj)
            for i, col in enumerate(obj_cols):
                out[i].append(col)

        for i, socket in enumerate(self.outputs[:len(data[0][0])]):
            self.outputs[socket.name].sv_set(out[i])
Example #2
0
    def execute(self, context):

        node_group = bpy.data.node_groups[self.idtree]
        node = node_group.nodes[self.idname]
        nid = node_id(node)

        if not node.inputs[0].is_linked:
            self.report({"WARNING"},
                        "Vertex socket of Draw node must be connected")
            return {'CANCELLED'}

        fill_cache_from_node_reference(node)
        matrix_cache = cache_viewer_baker[nid + 'm']
        vertex_cache = cache_viewer_baker[nid + 'v']
        edg_cache = cache_viewer_baker[nid + 'e']
        pol_cache = cache_viewer_baker[nid + 'p']

        if matrix_cache and not vertex_cache:
            return {'CANCELLED'}

        v = dataCorrect_np(vertex_cache)
        e = self.dataCorrect3(edg_cache)
        p = self.dataCorrect3(pol_cache)
        m = self.dataCorrect2(matrix_cache, v)
        self.config = node
        self.makeobjects(v, e, p, m)
        return {'FINISHED'}
Example #3
0
    def process(self):
        if not self.outputs[0].is_linked:
            return

        polygons_ = self.inputs['pols'].sv_get(deepcopy=False)
        polygons = dataCorrect_np(polygons_)

        self.outputs['edgs'].sv_set(polygons_to_edges_np(polygons, self.unique_edges, self.output_numpy))
Example #4
0
    def process(self):
        if not self.outputs[0].is_linked:
            return

        polygons_ = self.inputs['pols'].sv_get(deepcopy=False)
        polygons = dataCorrect_np(polygons_)

        if self.output_numpy or isinstance(polygons[0], ndarray) or self.regular_pols:
            result = polygons_to_edges_np(polygons, self.unique_edges, self.output_numpy)
        else:
            result = polygons_to_edges(polygons, self.unique_edges)

        self.outputs['edgs'].sv_set(result)
Example #5
0
    def process(self):
        if not (self.inputs['Vectors'].is_linked
                and any(s.is_linked for s in self.outputs)):
            return

        vectors = self.inputs['Vectors'].sv_get(deepcopy=False)

        if self.correct_output == 'FLAT':
            data = dataCorrect_np(vectors)
            xyz = unpack(data, self.output_numpy)
        else:
            input_level = levels_of_list_or_np(vectors)
            xyz = unpack_multilevel(vectors, input_level, self.output_numpy)

        for i, name in enumerate(['X', 'Y', 'Z']):
            if self.outputs[name].is_linked:
                self.outputs[name].sv_set(xyz[i])
Example #6
0
    def process(self):
        if self.inputs['Vectors'].is_linked and any(s.is_linked for s in self.outputs):
            xyz = self.inputs['Vectors'].sv_get(deepcopy=False)

            data = dataCorrect_np(xyz)
            X, Y, Z = [], [], []
            if self.output_numpy:
                unpack_func = unpack_np if isinstance(data[0], ndarray) else unpack_list_to_np
            else:
                unpack_func = unpack_list
            for obj in data:
                x_, y_, z_ = unpack_func(obj)
                X.append(x_)
                Y.append(y_)
                Z.append(z_)
            for i, name in enumerate(['X', 'Y', 'Z']):
                if self.outputs[name].is_linked:
                    self.outputs[name].sv_set([X, Y, Z][i])
Example #7
0
 def get(socket_name):
     data = self.inputs[socket_name].sv_get(default=[])
     return dataCorrect_np(data)