Пример #1
0
def sv_main(p=[], m=[]):

    in_sockets = [['s', 'p', p], ['s', 'm', m]]
    if not m:
        out_sockets = [
            ['s', 'out', []],
            ['s', 'out_not', p],
        ]

        return in_sockets, out_sockets

    out = []
    out_not = []
    for opol, omas in zip(p, m):
        fullList(omas, len(opol))
        for mas, pol in zip(omas, opol):
            if set(mas).intersection(pol):
                out.append(pol)
            else:
                out_not.append(pol)

    out_sockets = [
        ['s', 'out', [out]],
        ['s', 'out_not', [out_not]],
    ]

    return in_sockets, out_sockets
Пример #2
0
    def process(self):
        mverts, *mrest = self.get_geometry_from_sockets()

        def get_edges_faces_matrices(obj_index):
            for geom in mrest:
                yield self.get_structure(geom, obj_index)

        # extend all non empty lists to longest of mverts or *mrest
        maxlen = max(len(mverts), *(map(len, mrest)))
        fullList(mverts, maxlen)
        for idx in range(3):
            if mrest[idx]:
                fullList(mrest[idx], maxlen)

        for obj_index, Verts in enumerate(mverts):
            if not Verts:
                continue

            data = get_edges_faces_matrices(obj_index)
            mesh_name = self.basemesh_name + "_" + str(obj_index)
            make_bmesh_geometry(self, bpy.context, mesh_name, Verts, *data)

        self.remove_non_updated_objects(obj_index)
        objs = self.get_children()

        if self.grouping:
            self.to_group(objs)

        # truthy if self.material is in .materials
        if bpy.data.materials.get(self.material):
            self.set_corresponding_materials(objs)

        if self.autosmooth:
            self.set_autosmooth(objs)
Пример #3
0
def sv_main(p=[],m=[]):

    in_sockets = [
        ['s', 'p', p],
        ['s', 'm', m]]
    if not m:
        out_sockets = [
        ['s', 'out', []],
        ['s', 'out_not', p],
        ]
        
        return in_sockets, out_sockets

    out = []
    out_not = []
    for opol,omas in zip(p,m):
        fullList(omas, len(opol))
        for mas, pol in zip(omas, opol):
            if set(mas).intersection(pol):
                out.append(pol)
            else:
                out_not.append(pol)
                
    
    out_sockets = [
        ['s', 'out', [out]],
        ['s', 'out_not', [out_not]],
    ]

    return in_sockets, out_sockets
Пример #4
0
 def homogenize_input(self, segments, longest):
     '''
     edit segments in place, extend all to match length of longest
     '''
     for letter, letter_dict in segments.items():
         if letter_dict['length'] < longest:
             fullList(letter_dict['data'], longest)
Пример #5
0
 def f(self, x, socket):
     out = []
     fullList(x, len(socket))
     for i, obj in enumerate(socket):
         if type(obj) not in [int, float]:
             out.append(self.f(x[i], obj))
         else:
             out.append(obj+x[i])
     return out
Пример #6
0
 def f(self, x, socket):
     out = []
     fullList(x, len(socket))
     for i, obj in enumerate(socket):
         if type(obj) not in [int, float]:
             out.append(self.f(x[i], obj))
         else:
             out.append(obj + x[i])
     return out
Пример #7
0
def make_plane(int_x, int_y, step_x, step_y, separate):
    vertices = [(0.0, 0.0, 0.0)]
    vertices_S = []
    int_x = [int(int_x) if type(int_x) is not list else int(int_x[0])]
    int_y = [int(int_y) if type(int_y) is not list else int(int_y[0])]

    if type(step_x) is not list:
        step_x = [step_x]
    if type(step_y) is not list:
        step_y = [step_y]
    fullList(step_x, int_x[0])
    fullList(step_y, int_y[0])

    for i in range(int_x[0]-1):
        v = Vector(vertices[i]) + Vector((step_x[i], 0.0, 0.0))
        vertices.append(v[:])

    a = [int_y[0] if separate else int_y[0]-1]
    for i in range(a[0]):
        out = []
        for j in range(int_x[0]):
            out.append(vertices[j+int_x[0]*i])
        for j in out:
            v = Vector(j) + Vector((0.0, step_y[i], 0.0))
            vertices.append(v[:])
        if separate:
            vertices_S.append(out)

    edges = []
    edges_S = []

    for i in range(int_y[0]):
        for j in range(int_x[0]-1):
            edges.append((int_x[0]*i+j, int_x[0]*i+j+1))

    if separate:
        out = []
        for i in range(int_x[0]-1):
            out.append(edges[i])
        edges_S.append(out)
        for i in range(int_y[0]-1):
            edges_S.append(edges_S[0])
    else:
        for i in range(int_x[0]):
            for j in range(int_y[0]-1):
                edges.append((int_x[0]*j+i, int_x[0]*j+i+int_x[0]))

    polygons = []
    for i in range(int_x[0]-1):
        for j in range(int_y[0]-1):
            polygons.append((int_x[0]*j+i, int_x[0]*j+i+1, int_x[0]*j+i+int_x[0]+1, int_x[0]*j+i+int_x[0]))

    if separate:
        return vertices_S, edges_S, []
    else:
        return vertices, edges, polygons
Пример #8
0
 def f(self, x, socket):
     ''' this makes sum of units for every socket and object '''
     out = []
     fullList(x, len(socket))
     for i, obj in enumerate(socket):
         if type(obj) not in [int, float]:
             out.append(self.f(x[i], obj))
         else:
             out.append(obj + x[i])
     return out
Пример #9
0
 def f(self, x, socket):
     ''' this makes sum of units for every socket and object '''
     out = []
     fullList(x, len(socket))
     for i, obj in enumerate(socket):
         if type(obj) not in [int, float]:
             out.append(self.f(x[i], obj))
         else:
             out.append(obj+x[i])
     return out
Пример #10
0
    def update(self):
        # inputs
        if 'vecs X' in self.inputs and self.inputs['vecs X'].links:
            IntegerX = min(int(SvGetSocketAnyType(self, self.inputs['vecs X'])[0][0]), 100)
        else:
            IntegerX = int(self.Xvecs)

        if 'vecs Y' in self.inputs and self.inputs['vecs Y'].links:
            IntegerY = min(int(SvGetSocketAnyType(self, self.inputs['vecs Y'])[0][0]), 100)
        else:
            IntegerY = int(self.Yvecs)

        if 'Step X' in self.inputs and self.inputs['Step X'].links:
            StepX = SvGetSocketAnyType(self, self.inputs['Step X'])[0]
            fullList(StepX, IntegerX)

        else:
            StepX = [self.Xstep]
            fullList(StepX, IntegerX)

        if 'Step Y' in self.inputs and self.inputs['Step Y'].links:
            StepY = SvGetSocketAnyType(self, self.inputs['Step Y'])[0]
            fullList(StepY, IntegerY)

        else:
            StepY = [self.Ystep]
            fullList(StepY, IntegerY)

        # outputs
        if 'vecs' in self.outputs and self.outputs['vecs'].links:
            out = self.make_vertices(IntegerX-1, IntegerY-1, StepX, StepY, self.name_image)
            SvSetSocketAnyType(self, 'vecs', [out])
        else:
            SvSetSocketAnyType(self, 'vecs', [[[]]])

        if 'edgs' in self.outputs and len(self.outputs['edgs'].links) > 0:

            listEdg = []
            for i in range(IntegerY):
                for j in range(IntegerX-1):
                    listEdg.append((IntegerX*i+j, IntegerX*i+j+1))
            for i in range(IntegerX):
                for j in range(IntegerY-1):
                    listEdg.append((IntegerX*j+i, IntegerX*j+i+IntegerX))

            edg = list(listEdg)
            SvSetSocketAnyType(self, 'edgs', [edg])
        else:
            SvSetSocketAnyType(self, 'edgs', [[[]]])

        if 'pols' in self.outputs and self.outputs['pols'].links:

            listPlg = []
            for i in range(IntegerX-1):
                for j in range(IntegerY-1):
                    listPlg.append((IntegerX*j+i, IntegerX*j+i+1, IntegerX*j+i+IntegerX+1, IntegerX*j+i+IntegerX))
            plg = list(listPlg)
            SvSetSocketAnyType(self, 'pols', [plg])
        else:
            SvSetSocketAnyType(self, 'pols', [[[]]])
Пример #11
0
    def update(self):
        # inputs
        factor1 = []
        factor2 = []
        if 'Factor1' in self.inputs and self.inputs['Factor1'].links and \
           type(self.inputs['Factor1'].links[0].from_socket) == StringsSocket:

            factor1 = SvGetSocketAnyType(self, self.inputs['Factor1'])
        if not factor1:
            factor1 = [[self.factor1_]]

        if 'Factor2' in self.inputs and self.inputs['Factor2'].links and \
           type(self.inputs['Factor2'].links[0].from_socket) == StringsSocket:

            factor2 = SvGetSocketAnyType(self, self.inputs['Factor2'])
        if not factor2:
            factor2 = [[self.factor2_]]

        # outputs
        if 'Matrix' in self.outputs and self.outputs['Matrix'].links:

            max_l = max(len(factor1), len(factor2))
            fullList(factor1, max_l)
            fullList(factor2, max_l)
            matrixes_ = []
            for i in range(max_l):
                max_inner = max(len(factor1[i]), len(factor2[i]))
                fullList(factor1[i], max_inner)
                fullList(factor2[i], max_inner)
                for j in range(max_inner):
                    matrixes_.append(Matrix.Shear(self.plane_, 4, (factor1[i][j], factor2[i][j])))

            matrixes = Matrix_listing(matrixes_)
            SvSetSocketAnyType(self, 'Matrix', matrixes)
Пример #12
0
    def update(self):
        # inputs
        VerticesA = []
        VerticesB = []
        factor = []

        if 'Vertice A' in self.inputs and self.inputs['Vertice A'].links:
            VerticesA = SvGetSocketAnyType(self, self.inputs['Vertice A'])

        if 'Vertice B' in self.inputs and self.inputs['Vertice B'].links:
            VerticesB = SvGetSocketAnyType(self, self.inputs['Vertice B'])

        if 'Factor' in self.inputs and self.inputs['Factor'].links:
            factor = SvGetSocketAnyType(self, self.inputs['Factor'])

        if not (VerticesA and VerticesB):
            return

        if not factor:
            factor = [[self.factor_]]

        # outputs
        if 'EvPoint' in self.outputs and self.outputs['EvPoint'].links:
            points = []

# match inputs using fullList, longest list matching on A and B
# extend factor list if necessary, it should not control length of output

            max_obj = max(len(VerticesA), len(VerticesB))
            fullList(VerticesA, max_obj)
            fullList(VerticesB, max_obj)
            if len(factor) < max_obj:
                fullList(factor, max_obj)

            for i in range(max_obj):
                points_ = []
                max_l = max(len(VerticesA[i]), len(VerticesB[i]))
                fullList(VerticesA[i], max_l)
                fullList(VerticesB[i], max_l)
                for j in range(max_l):
                    tmp_pts = [(Vector(VerticesA[i][j]).lerp(VerticesB[i][j], factor[i][k]))[:]
                               for k in range(len(factor[i]))]
                    points_.extend(tmp_pts)
                points.append(points_)
            if not points:
                return

            SvSetSocketAnyType(self, 'EvPoint', points)
Пример #13
0
def make_line(integer, step):
    vertices = [(0.0, 0.0, 0.0)]
    integer = [int(integer) if type(integer) is not list else int(integer[0])]

    if type(step) is not list:
        step = [step]
    fullList(step, integer[0])

    for i in range(integer[0]-1):
        v = Vector(vertices[i]) + Vector((step[i], 0.0, 0.0))
        vertices.append(v[:])

    edges = []
    for i in range(integer[0]-1):
        edges.append((i, i+1))

    return vertices, edges
Пример #14
0
def make_line(integer, step):
    vertices = [(0.0, 0.0, 0.0)]
    integer = [int(integer) if type(integer) is not list else int(integer[0])]

    if type(step) is not list:
        step = [step]
    fullList(step, integer[0])

    for i in range(integer[0] - 1):
        v = Vector(vertices[i]) + Vector((step[i], 0.0, 0.0))
        vertices.append(v[:])

    edges = []
    for i in range(integer[0] - 1):
        edges.append((i, i + 1))

    return vertices, edges
Пример #15
0
    def update(self):
        if not 'polygons' in self.outputs:
            return
        if not any((s.links for s in self.outputs)):
            return

        if 'vertices' in self.inputs and self.inputs['vertices'].links and \
           'polygons' in self.inputs and self.inputs['polygons'].links:

            verts = Vector_generate(
                SvGetSocketAnyType(self, self.inputs['vertices']))
            polys = SvGetSocketAnyType(self, self.inputs['polygons'])
            if 'thickness' in self.inputs:
                thickness = self.inputs['thickness'].sv_get()
            else:
                thickness = [[self.thickness]]

            #print (verts,polys)

            verts_out = []
            edges_out = []
            polys_out = []
            newpo_out = []
            fullList(thickness, len(verts))
            for v, p, t in zip(verts, polys, thickness):
                verlen = set(range(len(v)))
                res = soldify(v, p, t, verlen)

                if not res:
                    return
                verts_out.append(res[0])
                edges_out.append(res[1])
                polys_out.append(res[2])
                newpo_out.append(res[3])

            if 'vertices' in self.outputs and self.outputs['vertices'].links:
                SvSetSocketAnyType(self, 'vertices', verts_out)

            if 'edges' in self.outputs and self.outputs['edges'].links:
                SvSetSocketAnyType(self, 'edges', edges_out)

            if 'polygons' in self.outputs and self.outputs['polygons'].links:
                SvSetSocketAnyType(self, 'polygons', polys_out)

            if 'newpols' in self.outputs and self.outputs['newpols'].links:
                SvSetSocketAnyType(self, 'newpols', newpo_out)
Пример #16
0
    def update(self):
        if not 'polygons' in self.outputs:
            return
        if not any((s.links for s in self.outputs)):
            return

        if 'vertices' in self.inputs and self.inputs['vertices'].links and \
           'polygons' in self.inputs and self.inputs['polygons'].links:

            verts = Vector_generate(SvGetSocketAnyType(self, self.inputs['vertices']))
            polys = SvGetSocketAnyType(self, self.inputs['polygons'])
            if 'thickness' in self.inputs:
                thickness = self.inputs['thickness'].sv_get()
            else:
                thickness = [[self.thickness]]

            #print (verts,polys)

            verts_out = []
            edges_out = []
            polys_out = []
            newpo_out = []
            fullList(thickness, len(verts))
            for v, p, t in zip(verts, polys, thickness):
                verlen = set(range(len(v)))
                res = soldify(v, p, t, verlen)
            
                if not res:
                    return
                verts_out.append(res[0])
                edges_out.append(res[1])
                polys_out.append(res[2])
                newpo_out.append(res[3])
            
            if 'vertices' in self.outputs and self.outputs['vertices'].links:
                SvSetSocketAnyType(self, 'vertices', verts_out)
            
            if 'edges' in self.outputs and self.outputs['edges'].links:
                SvSetSocketAnyType(self, 'edges', edges_out)
            
            if 'polygons' in self.outputs and self.outputs['polygons'].links:
                SvSetSocketAnyType(self, 'polygons', polys_out)
                
            if 'newpols' in self.outputs and self.outputs['newpols'].links:
                SvSetSocketAnyType(self, 'newpols', newpo_out)
Пример #17
0
    def process(self):

        inputs = self.inputs
        outputs = self.outputs

        sizes = SvGetSocketAnyType(self, inputs['vector_size'])[0]
        if not sizes:
            return

        # sizes determines FullLength
        num_boxes = len(sizes)

        radii = inputs['radius'].sv_get()[0]
        arc_divs = inputs['arcdiv'].sv_get()[0]
        lin_divs = inputs['lindiv'].sv_get()[0]
        div_types = inputs['div_type'].sv_get()[0]
        axis_aligns = inputs['odd_axis_align'].sv_get()[0]

        fullList(radii, num_boxes)
        fullList(arc_divs, num_boxes)
        fullList(lin_divs, num_boxes)
        fullList(div_types, num_boxes)
        fullList(axis_aligns, num_boxes)

        multi_dict = []
        for i, args in enumerate(sizes):
            multi_dict.append({
                'radius': radii[i],
                'arcdiv': arc_divs[i],
                'lindiv': lin_divs[i],
                'size': args,
                'div_type': div_types[i],
                'odd_axis_align': axis_aligns[i]
            })
            # print(multi_dict[i])

        out = list(zip(*[round_cube(**kwargs) for kwargs in multi_dict]))

        if outputs['Vers'].links:
            SvSetSocketAnyType(self, 'Vers', out[0])
        if outputs['Pols'].links:
            SvSetSocketAnyType(self, 'Pols', out[1])
Пример #18
0
    def process(self, n_id, IV):
        inputs = self.inputs
        iv_links = inputs['vertices'].links
        im_links = inputs['matrix'].links

        draw_verts, draw_matrix = [], []
        text = ''

        # gather vertices from input
        if isinstance(iv_links[0].from_socket, VerticesSocket):
            propv = SvGetSocketAnyType(self, inputs['vertices'])
            draw_verts = dataCorrect(propv)

        # idea to make text in 3d
        if inputs['text'].links:
            text_so = SvGetSocketAnyType(self, inputs['text'])
            text = dataCorrect(text_so)
            fullList(text, len(draw_verts))
            for i, t in enumerate(text):
                fullList(text[i], len(draw_verts[i]))

        if im_links and isinstance(im_links[0].from_socket, MatrixSocket):
            propm = SvGetSocketAnyType(self, inputs['matrix'])
            draw_matrix = dataCorrect(propm)

        data_feind = []
        for socket in ['edges', 'faces']:
            try:
                propm = SvGetSocketAnyType(self, inputs[socket])
                input_stream = dataCorrect(propm)
            except:
                input_stream = []
            finally:
                data_feind.append(input_stream)

        draw_edges, draw_faces = data_feind

        bg = self.draw_bg
        settings = self.get_settings()
        IV.callback_enable(
            n_id, draw_verts, draw_edges, draw_faces,
            draw_matrix, bg, settings.copy(), text)
Пример #19
0
    def process(self, n_id, IV):
        inputs = self.inputs
        iv_links = inputs['vertices'].links
        im_links = inputs['matrix'].links

        draw_verts, draw_matrix = [], []
        text = ''

        # gather vertices from input
        if isinstance(iv_links[0].from_socket, VerticesSocket):
            propv = SvGetSocketAnyType(self, inputs['vertices'])
            draw_verts = dataCorrect(propv)

        # idea to make text in 3d
        if inputs['text'].links:
            text_so = SvGetSocketAnyType(self, inputs['text'])
            text = dataCorrect(text_so)
            fullList(text, len(draw_verts))
            for i, t in enumerate(text):
                fullList(text[i], len(draw_verts[i]))

        if im_links and isinstance(im_links[0].from_socket, MatrixSocket):
            propm = SvGetSocketAnyType(self, inputs['matrix'])
            draw_matrix = dataCorrect(propm)

        data_feind = []
        for socket in ['edges', 'faces']:
            try:
                propm = SvGetSocketAnyType(self, inputs[socket])
                input_stream = dataCorrect(propm)
            except:
                input_stream = []
            finally:
                data_feind.append(input_stream)

        draw_edges, draw_faces = data_feind

        bg = self.draw_bg
        settings = self.get_settings()
        IV.callback_enable(n_id, draw_verts, draw_edges, draw_faces,
                           draw_matrix, bg, settings.copy(), text)
Пример #20
0
    def make_verts(self, Angle, Vertices, Radius):
        if Angle < 360:
            theta = Angle / (Vertices - 1)
        else:
            theta = Angle / Vertices
        listVertX = []
        listVertY = []
        for i in range(Vertices):
            listVertX.append(Radius * cos(radians(theta * i)))
            listVertY.append(Radius * sin(radians(theta * i)))

        if Angle < 360 and self.mode_ == 0:
            sigma = radians(Angle)
            listVertX[-1] = Radius * cos(sigma)
            listVertY[-1] = Radius * sin(sigma)
        elif Angle < 360 and self.mode_ == 1:
            listVertX.append(0.0)
            listVertY.append(0.0)

        X = listVertX
        Y = listVertY
        Z = [0.0]

        max_num = max(len(X), len(Y), len(Z))

        fullList(X, max_num)
        fullList(Y, max_num)
        fullList(Z, max_num)

        points = list(zip(X, Y, Z))
        return points
Пример #21
0
    def update(self):

        # startup safety net
        try:
            l = bpy.data.node_groups[self.id_data.name]
        except Exception as e:
            print(self.name, "cannot run during startup, press update.")
            return

        # regular code from this point
        inputs = self.inputs
        if self.activate and 'vertices' in inputs and inputs['vertices'].links:
            self.use_custom_color = True
            self.color = (1, 0.3, 0)
            C = bpy.context
            mverts, *mrest = self.get_geometry_from_sockets()

            def get_edges_faces_matrices(obj_index):
                for geom in mrest:
                    yield self.get_structure(geom, obj_index)

            # matrices need to define count of objects. paradigma
            maxlen = max(len(mverts), len(mrest[0]), len(mrest[1]),
                         len(mrest[2]))
            fullList(mverts, maxlen)
            if mrest[0]:
                fullList(mrest[0], maxlen)
            if mrest[1]:
                fullList(mrest[1], maxlen)
            if mrest[2]:
                fullList(mrest[2], maxlen)

            for obj_index, Verts in enumerate(mverts):
                if not Verts:
                    continue

                data = get_edges_faces_matrices(obj_index)
                mesh_name = self.basemesh_name + "_" + str(obj_index)
                make_bmesh_geometry(C, mesh_name, Verts, *data)

            self.remove_non_updated_objects(obj_index, self.basemesh_name)
            self.set_corresponding_materials()
            if self.inputs['vertices'].links:
                if self.grouping:
                    self.to_group()
                if self.material:
                    self.set_corresponding_materials()
        else:
            self.use_custom_color = True
            self.color = (0.1, 0.05, 0)
Пример #22
0
    def make_verts(self, Angle, Vertices, Radius):
        if Angle < 360:
            theta = Angle/(Vertices-1)
        else:
            theta = Angle/Vertices
        listVertX = []
        listVertY = []
        for i in range(Vertices):
            listVertX.append(Radius*cos(radians(theta*i)))
            listVertY.append(Radius*sin(radians(theta*i)))

        if Angle < 360 and self.mode_ == 0:
            sigma = radians(Angle)
            listVertX[-1] = Radius*cos(sigma)
            listVertY[-1] = Radius*sin(sigma)
        elif Angle < 360 and self.mode_ == 1:
            listVertX.append(0.0)
            listVertY.append(0.0)

        X = listVertX
        Y = listVertY
        Z = [0.0]

        max_num = max(len(X), len(Y), len(Z))

        fullList(X, max_num)
        fullList(Y, max_num)
        fullList(Z, max_num)

        points = list(zip(X, Y, Z))
        return points
Пример #23
0
    def update(self):

        # startup safety net
        try:
            l = bpy.data.node_groups[self.id_data.name]
        except Exception as e:
            print(self.name, "cannot run during startup, press update.")
            return

        # regular code from this point
        inputs = self.inputs
        if self.activate and 'vertices' in inputs and inputs['vertices'].links:
            self.use_custom_color = True
            self.color = (1, 0.3, 0)
            C = bpy.context
            mverts, *mrest = self.get_geometry_from_sockets()

            def get_edges_faces_matrices(obj_index):
                for geom in mrest:
                    yield self.get_structure(geom, obj_index)

            # matrices need to define count of objects. paradigma
            maxlen = max(len(mverts), len(mrest[0]), len(mrest[1]), len(mrest[2]))
            fullList(mverts, maxlen)
            if mrest[0]:
                fullList(mrest[0], maxlen)
            if mrest[1]:
                fullList(mrest[1], maxlen)
            if mrest[2]:
                fullList(mrest[2], maxlen)

            for obj_index, Verts in enumerate(mverts):
                if not Verts:
                    continue

                data = get_edges_faces_matrices(obj_index)
                mesh_name = self.basemesh_name + "_" + str(obj_index)
                make_bmesh_geometry(C, mesh_name, Verts, *data)

            self.remove_non_updated_objects(obj_index, self.basemesh_name)
            self.set_corresponding_materials()
            if self.inputs['vertices'].links:
                if self.grouping:
                    self.to_group()
                if self.material:
                    self.set_corresponding_materials()
        else:
            self.use_custom_color = True
            self.color = (0.1, 0.05, 0)
Пример #24
0
    def update(self):

        if self.outputs['Vers'].links and self.inputs['Vers'].links:
            vertices = Vector_generate(
                SvGetSocketAnyType(self, self.inputs['Vers']))
            faces = SvGetSocketAnyType(self, self.inputs['Pols'])
            offset = self.inputs['Offset'].sv_get()[0]
            nsides = self.inputs['N sides'].sv_get()[0][0]
            radius = self.inputs['Radius'].sv_get()[0]
            #print(radius,nsides,offset)
            outv = []
            oute = []
            outo = []
            outn = []
            for verts_obj, faces_obj in zip(vertices, faces):
                # this is for one object
                fullList(offset, len(faces_obj))
                fullList(radius, len(faces_obj))
                verlen = set(range(len(verts_obj)))
                bme = bmesh_from_pydata(verts_obj, [], faces_obj)
                geom_in = bme.verts[:] + bme.edges[:] + bme.faces[:]
                bmesh.ops.recalc_face_normals(bme, faces=bme.faces[:])
                list_0 = [f.index for f in bme.faces]
                # calculation itself
                result = \
                    self.Offset_pols(bme, list_0, offset, radius, nsides, verlen)
                outv.append(result[0])
                oute.append(result[1])
                outo.append(result[2])
                outn.append(result[3])
            if self.outputs['Vers'].links:
                SvSetSocketAnyType(self, 'Vers', outv)
            if self.outputs['Edgs'].links:
                SvSetSocketAnyType(self, 'Edgs', oute)
            if self.outputs['OutPols'].links:
                SvSetSocketAnyType(self, 'OutPols', outo)
            if self.outputs['InPols'].links:
                SvSetSocketAnyType(self, 'InPols', outn)
Пример #25
0
 def update(self):
     
     if self.outputs['Vers'].links and self.inputs['Vers'].links:
             vertices = Vector_generate(SvGetSocketAnyType(self, self.inputs['Vers']))
             faces = SvGetSocketAnyType(self, self.inputs['Pols'])
             offset = self.inputs['Offset'].sv_get()[0]
             nsides = self.inputs['N sides'].sv_get()[0][0]
             radius = self.inputs['Radius'].sv_get()[0]
             #print(radius,nsides,offset)
             outv = []
             oute = []
             outo = []
             outn = []
             for verts_obj, faces_obj in zip(vertices, faces):
                 # this is for one object
                 fullList(offset, len(faces_obj))
                 fullList(radius, len(faces_obj))
                 verlen = set(range(len(verts_obj)))
                 bme = bmesh_from_pydata(verts_obj, [], faces_obj)
                 geom_in = bme.verts[:]+bme.edges[:]+bme.faces[:]
                 bmesh.ops.recalc_face_normals(bme, faces=bme.faces[:])
                 list_0 = [ f.index for f in bme.faces ]
                 # calculation itself
                 result = \
                     self.Offset_pols(bme, list_0, offset, radius, nsides, verlen)
                 outv.append(result[0])
                 oute.append(result[1])
                 outo.append(result[2])
                 outn.append(result[3])
             if self.outputs['Vers'].links:
                 SvSetSocketAnyType(self, 'Vers', outv)
             if self.outputs['Edgs'].links:
                 SvSetSocketAnyType(self, 'Edgs', oute)
             if self.outputs['OutPols'].links:
                 SvSetSocketAnyType(self, 'OutPols', outo)
             if self.outputs['InPols'].links:
                 SvSetSocketAnyType(self, 'InPols', outn)
Пример #26
0
    def update(self):
        # inputs
        A = []
        B = []
        factor = []  # 0 is valid value so I use [] as placeholder

        if 'A' in self.inputs and self.inputs['A'].links and \
           type(self.inputs['A'].links[0].from_socket) == MatrixSocket:

            A = Matrix_generate(SvGetSocketAnyType(self, self.inputs['A']))
        if not A:
            A = [Matrix.Identity(4)]

        if 'B' in self.inputs and self.inputs['B'].links and \
           type(self.inputs['B'].links[0].from_socket) == MatrixSocket:

            B = Matrix_generate(SvGetSocketAnyType(self, self.inputs['B']))
        if not B:
            B = [Matrix.Identity(4)]

        if 'Factor' in self.inputs and self.inputs['Factor'].links and \
           type(self.inputs['Factor'].links[0].from_socket) == StringsSocket:

            factor = SvGetSocketAnyType(self, self.inputs['Factor'])

        if not factor:
            factor = [[self.factor_]]

        if 'C' in self.outputs and self.outputs['C'].links:

            matrixes_ = []
            # match inputs, first matrix A and B using fullList
            # then extend the factor list if necessary,
            # A and B should control length of list, not interpolation lists
            max_l = max(len(A), len(B))
            fullList(A, max_l)
            fullList(B, max_l)
            if len(factor) < max_l:
                fullList(factor, max_l)
            for i in range(max_l):
                for k in range(len(factor[i])):
                    matrixes_.append(A[i].lerp(B[i], factor[i][k]))

            if not matrixes_:
                return

            matrixes = Matrix_listing(matrixes_)
            SvSetSocketAnyType(self, 'C', matrixes)
Пример #27
0
    def update(self):
        # inputs
        A = []
        B = []
        factor = []  # 0 is valid value so I use [] as placeholder

        if 'A' in self.inputs and self.inputs['A'].links and \
           type(self.inputs['A'].links[0].from_socket) == MatrixSocket:

            A = Matrix_generate(SvGetSocketAnyType(self, self.inputs['A']))
        if not A:
            A = [Matrix.Identity(4)]

        if 'B' in self.inputs and self.inputs['B'].links and \
           type(self.inputs['B'].links[0].from_socket) == MatrixSocket:

            B = Matrix_generate(SvGetSocketAnyType(self, self.inputs['B']))
        if not B:
            B = [Matrix.Identity(4)]

        if 'Factor' in self.inputs and self.inputs['Factor'].links and \
           type(self.inputs['Factor'].links[0].from_socket) == StringsSocket:

            factor = SvGetSocketAnyType(self, self.inputs['Factor'])

        if not factor:
            factor = [[self.factor_]]

        if 'C' in self.outputs and self.outputs['C'].links:

            matrixes_ = []
            # match inputs, first matrix A and B using fullList
            # then extend the factor list if necessary,
            # A and B should control length of list, not interpolation lists
            max_l = max(len(A), len(B))
            fullList(A, max_l)
            fullList(B, max_l)
            if len(factor) < max_l:
                fullList(factor, max_l)
            for i in range(max_l):
                for k in range(len(factor[i])):
                    matrixes_.append(A[i].lerp(B[i], factor[i][k]))

            if not matrixes_:
                return

            matrixes = Matrix_listing(matrixes_)
            SvSetSocketAnyType(self, 'C', matrixes)
Пример #28
0
    def update(self):
        # inputs
        if 'Nº Vertices' in self.inputs and self.inputs['Nº Vertices'].links:
            Integer_ = SvGetSocketAnyType(self,self.inputs['Nº Vertices'])[0]
        else:
            Integer_ = [self.int_]

        if 'Step' in self.inputs and self.inputs['Step'].links:
            Step_ = SvGetSocketAnyType(self,self.inputs['Step'])[0]
            
            if len(Integer_) > len(Step_):
                fullList(Step_, len(Integer_))
            X=[]
            for j, k in enumerate(Integer_):
                listVert = []
                for i in range(k):
                    listVert.append(i*Step_[j])
                X.append(listVert)

        else:
            Step = self.step_
            X = [[Step*(i) for i in range(Integer)] for Integer in Integer_]
            
        # outputs
        if 'Vertices' in self.outputs and self.outputs['Vertices'].links:

            points = []
            for X_obj in X:
                Y = [0.0]
                Z = [0.0]
                max_num = len(X_obj)
                fullList(Y,max_num)
                fullList(Z,max_num)
                points.append(list(zip(X_obj,Y,Z)))
            SvSetSocketAnyType(self, 'Vertices',points)

        if 'Edges' in self.outputs and self.outputs['Edges'].links:

            edg = []
            for Integer in Integer_:
                listEdg_obj = []
                for i in range(Integer-1):
                    listEdg_obj.append((i, i+1))
                edg.append(list(listEdg_obj))

            SvSetSocketAnyType(self, 'Edges',edg)
Пример #29
0
    def update(self):
        # inputs
        factor1 = []
        factor2 = []
        if 'Factor1' in self.inputs and self.inputs['Factor1'].links and \
           type(self.inputs['Factor1'].links[0].from_socket) == StringsSocket:

            factor1 = SvGetSocketAnyType(self, self.inputs['Factor1'])
        if not factor1:
            factor1 = [[self.factor1_]]

        if 'Factor2' in self.inputs and self.inputs['Factor2'].links and \
           type(self.inputs['Factor2'].links[0].from_socket) == StringsSocket:

            factor2 = SvGetSocketAnyType(self, self.inputs['Factor2'])
        if not factor2:
            factor2 = [[self.factor2_]]

        # outputs
        if 'Matrix' in self.outputs and self.outputs['Matrix'].links:

            max_l = max(len(factor1), len(factor2))
            fullList(factor1, max_l)
            fullList(factor2, max_l)
            matrixes_ = []
            for i in range(max_l):
                max_inner = max(len(factor1[i]), len(factor2[i]))
                fullList(factor1[i], max_inner)
                fullList(factor2[i], max_inner)
                for j in range(max_inner):
                    matrixes_.append(
                        Matrix.Shear(self.plane_, 4,
                                     (factor1[i][j], factor2[i][j])))

            matrixes = Matrix_listing(matrixes_)
            SvSetSocketAnyType(self, 'Matrix', matrixes)
Пример #30
0
    def update(self):
        # inputs
        if 'X' in self.inputs and self.inputs['X'].links and \
           type(self.inputs['X'].links[0].from_socket) == StringsSocket:
            X_ = SvGetSocketAnyType(self, self.inputs['X'])
        else:
            X_ = [[self.x_]]

        if 'Y' in self.inputs and self.inputs['Y'].links and \
           type(self.inputs['Y'].links[0].from_socket) == StringsSocket:
            Y_ = SvGetSocketAnyType(self, self.inputs['Y'])
        else:
            Y_ = [[self.y_]]

        if 'Z' in self.inputs and self.inputs['Z'].links and \
           type(self.inputs['Z'].links[0].from_socket) == StringsSocket:
            Z_ = SvGetSocketAnyType(self, self.inputs['Z'])
        else:
            Z_ = [[self.z_]]

        # outputs
        if 'Vectors' in self.outputs and self.outputs['Vectors'].links:

            max_obj = max(len(X_), len(Y_), len(Z_))
            self.fullList(X_, max_obj)
            self.fullList(Y_, max_obj)
            self.fullList(Z_, max_obj)

            series_vec = []
            for i in range(max_obj):
                X = X_[i]
                Y = Y_[i]
                Z = Z_[i]

                max_num = max(len(X), len(Y), len(Z))

                fullList(X, max_num)
                fullList(Y, max_num)
                fullList(Z, max_num)

                series_vec.append(list(zip(X, Y, Z)))

            SvSetSocketAnyType(self, 'Vectors', series_vec)
Пример #31
0
    def update(self):
        # inputs
        if 'X' in self.inputs and self.inputs['X'].links and \
           type(self.inputs['X'].links[0].from_socket) == StringsSocket:
            X_ = SvGetSocketAnyType(self, self.inputs['X'])
        else:
            X_ = [[self.x_]]

        if 'Y' in self.inputs and self.inputs['Y'].links and \
           type(self.inputs['Y'].links[0].from_socket) == StringsSocket:
            Y_ = SvGetSocketAnyType(self, self.inputs['Y'])
        else:
            Y_ = [[self.y_]]

        if 'Z' in self.inputs and self.inputs['Z'].links and \
           type(self.inputs['Z'].links[0].from_socket) == StringsSocket:
            Z_ = SvGetSocketAnyType(self, self.inputs['Z'])
        else:
            Z_ = [[self.z_]]

        # outputs
        if 'Vectors' in self.outputs and self.outputs['Vectors'].links:

            max_obj = max(len(X_), len(Y_), len(Z_))
            self.fullList(X_, max_obj)
            self.fullList(Y_, max_obj)
            self.fullList(Z_, max_obj)

            series_vec = []
            for i in range(max_obj):
                X = X_[i]
                Y = Y_[i]
                Z = Z_[i]

                max_num = max(len(X), len(Y), len(Z))

                fullList(X, max_num)
                fullList(Y, max_num)
                fullList(Z, max_num)

                series_vec.append(list(zip(X, Y, Z)))

            SvSetSocketAnyType(self, 'Vectors', series_vec)
Пример #32
0
    def update(self):
        inputs = self.inputs
        text=''

        # if you change this change in free() also
        n_id = node_id(self)
        # end early
        if not ('vertices' in inputs) and not ('matrix' in inputs):
            IV.callback_disable(n_id)
            return
        # end if tree status is set to not show
        if not self.id_data.sv_show:
            IV.callback_disable(n_id)
            return

        # alias in case it is present
        iv_links = inputs['vertices'].links

        if self.activate and iv_links:
            IV.callback_disable(n_id)
            draw_verts, draw_matrix = [], []

            # gather vertices from input
            if isinstance(iv_links[0].from_socket, VerticesSocket):
                propv = SvGetSocketAnyType(self, inputs['vertices'])
                draw_verts = dataCorrect(propv)
            
            # idea to make text in 3d
            if 'text' in inputs and inputs['text'].links:
                text_so = SvGetSocketAnyType(self, inputs['text'])
                text = dataCorrect(text_so)
                fullList(text, len(draw_verts))
                for i, t in enumerate(text):
                    fullList(text[i], len(draw_verts[i]))
                
            # matrix might be operating on vertices, check and act on.
            if 'matrix' in inputs:
                im_links = inputs['matrix'].links

                # end early, skips to drwa vertex indices without matrix
                if im_links and isinstance(im_links[0].from_socket, MatrixSocket):
                    propm = SvGetSocketAnyType(self, inputs['matrix'])
                    draw_matrix = dataCorrect(propm)

            data_feind = []
            for socket in ['edges', 'faces']:
                try:
                    propm = SvGetSocketAnyType(self, inputs[socket])
                    input_stream = dataCorrect(propm)
                except:
                    input_stream = []
                finally:
                    data_feind.append(input_stream)

            draw_edges, draw_faces = data_feind

            bg = self.draw_bg
            settings = self.get_settings()
            IV.callback_enable(
                n_id, draw_verts, draw_edges, draw_faces, draw_matrix, bg, settings.copy(), text)
            self.use_custom_color = True
            self.color = READY_COLOR
        else:
            IV.callback_disable(n_id)
            self.use_custom_color = True
            self.color = FAIL_COLOR
Пример #33
0
    def update(self):
        # inputs
        if 'Nº Vertices X' in self.inputs and self.inputs['Nº Vertices X'].links:
            IntegerX = int(SvGetSocketAnyType(self, self.inputs['Nº Vertices X'])[0][0])
        else:
            IntegerX = self.int_X

        if 'Nº Vertices Y' in self.inputs and self.inputs['Nº Vertices Y'].links:
            IntegerY = int(SvGetSocketAnyType(self, self.inputs['Nº Vertices Y'])[0][0])
        else:
            IntegerY = self.int_Y

        if 'Step X' in self.inputs and self.inputs['Step X'].links:
            StepX = SvGetSocketAnyType(self, self.inputs['Step X'])[0]

            listVertX = []
            fullList(StepX, IntegerX)
            for i in range(IntegerY):
                listVertX.append(0.0)
                for j in range(IntegerX-1):
                    listVertX.append(listVertX[j]+StepX[j])

        else:
            StepX = self.step_X
            listVertX = []
            for i in range(IntegerY):
                for j in range(IntegerX):
                    listVertX.append(0.0+j)
            listVertX = [StepX*i for i in listVertX]

        if 'Step Y' in self.inputs and self.inputs['Step Y'].links:
            StepY = SvGetSocketAnyType(self, self.inputs['Step Y'])[0]

            listVertY = []
            fullList(StepY, IntegerY)
            for i in range(IntegerX):
                listVertY.append(0.0)
            for i in range(IntegerY-1):
                for j in range(IntegerX):
                    listVertY.append(listVertY[IntegerX*i]+StepY[i])
        else:
            StepY = self.step_Y
            listVertY = []
            for i in range(IntegerY):
                for j in range(IntegerX):
                    listVertY.append(0.0+i)
            listVertY = [StepY*i for i in listVertY]

        # outputs
        if 'Vertices' in self.outputs and self.outputs['Vertices'].links:

            X = listVertX
            Y = listVertY
            Z = [0.0]

            max_num = max(len(X), len(Y), len(Z))

            fullList(X, max_num)
            fullList(Y, max_num)
            fullList(Z, max_num)

            points = list(sv_zip(X, Y, Z))
            if self.Separate:
                out = []
                for y in range(IntegerY):
                    out_ = []
                    for x in range(IntegerX):
                        out_.append(points[IntegerX*y+x])
                    out.append(out_)
                SvSetSocketAnyType(self, 'Vertices', [out])
            else:
                SvSetSocketAnyType(self, 'Vertices', [points])

        if 'Edges' in self.outputs and self.outputs['Edges'].links:
            listEdg = []
            for i in range(IntegerY):
                for j in range(IntegerX-1):
                    listEdg.append((IntegerX*i+j, IntegerX*i+j+1))
            for i in range(IntegerX):
                for j in range(IntegerY-1):
                    listEdg.append((IntegerX*j+i, IntegerX*j+i+IntegerX))

            edg = list(listEdg)
            SvSetSocketAnyType(self, 'Edges', [edg])

        if 'Polygons' in self.outputs and self.outputs['Polygons'].links:
            listPlg = []
            for i in range(IntegerX-1):
                for j in range(IntegerY-1):
                    listPlg.append((IntegerX*j+i, IntegerX*j+i+1, IntegerX*j+i+IntegerX+1, IntegerX*j+i+IntegerX))
            plg = list(listPlg)
            SvSetSocketAnyType(self, 'Polygons', [plg])
Пример #34
0
    def update(self):
        # inputs
        if 'vecs X' in self.inputs and self.inputs['vecs X'].links:
            IntegerX = min(
                int(SvGetSocketAnyType(self, self.inputs['vecs X'])[0][0]),
                100)
        else:
            IntegerX = int(self.Xvecs)

        if 'vecs Y' in self.inputs and self.inputs['vecs Y'].links:
            IntegerY = min(
                int(SvGetSocketAnyType(self, self.inputs['vecs Y'])[0][0]),
                100)
        else:
            IntegerY = int(self.Yvecs)

        if 'Step X' in self.inputs and self.inputs['Step X'].links:
            StepX = SvGetSocketAnyType(self, self.inputs['Step X'])[0]
            fullList(StepX, IntegerX)

        else:
            StepX = [self.Xstep]
            fullList(StepX, IntegerX)

        if 'Step Y' in self.inputs and self.inputs['Step Y'].links:
            StepY = SvGetSocketAnyType(self, self.inputs['Step Y'])[0]
            fullList(StepY, IntegerY)

        else:
            StepY = [self.Ystep]
            fullList(StepY, IntegerY)

        # outputs
        if 'vecs' in self.outputs and self.outputs['vecs'].links:
            out = self.make_vertices(IntegerX - 1, IntegerY - 1, StepX, StepY,
                                     self.name_image)
            SvSetSocketAnyType(self, 'vecs', [out])
        else:
            SvSetSocketAnyType(self, 'vecs', [[[]]])

        if 'edgs' in self.outputs and len(self.outputs['edgs'].links) > 0:

            listEdg = []
            for i in range(IntegerY):
                for j in range(IntegerX - 1):
                    listEdg.append((IntegerX * i + j, IntegerX * i + j + 1))
            for i in range(IntegerX):
                for j in range(IntegerY - 1):
                    listEdg.append(
                        (IntegerX * j + i, IntegerX * j + i + IntegerX))

            edg = list(listEdg)
            SvSetSocketAnyType(self, 'edgs', [edg])
        else:
            SvSetSocketAnyType(self, 'edgs', [[[]]])

        if 'pols' in self.outputs and self.outputs['pols'].links:

            listPlg = []
            for i in range(IntegerX - 1):
                for j in range(IntegerY - 1):
                    listPlg.append((IntegerX * j + i, IntegerX * j + i + 1,
                                    IntegerX * j + i + IntegerX + 1,
                                    IntegerX * j + i + IntegerX))
            plg = list(listPlg)
            SvSetSocketAnyType(self, 'pols', [plg])
        else:
            SvSetSocketAnyType(self, 'pols', [[[]]])
Пример #35
0
 def joinvers(ver):
     joinvers = []
     for ob in ver:
         fullList(list(ob), ml)
         joinvers.extend(ob)
     return joinvers