def process(self): if not self.inputs['Vertices'].is_linked: return if not any([s.is_linked for s in self.outputs]): return has_mat_out = bool(self.outputs['Center'].is_linked) has_mean = bool(self.outputs['Mean'].is_linked) has_vert_out = bool(self.outputs['Vertices'].is_linked) vert = SvGetSocketAnyType(self, self.inputs['Vertices']) vert = dataCorrect(vert, nominal_dept=2) if vert: verts_out = [] edges_out = [] edges = [ (0, 1), (1, 3), (3, 2), (2, 0), # bottom edges (4, 5), (5, 7), (7, 6), (6, 4), # top edges (0, 4), (1, 5), (2, 6), (3, 7) # sides ] mat_out = [] mean_out = [] for v in vert: if has_mat_out or has_vert_out: maxmin = list(zip(map(max, *v), map(min, *v))) out = list(product(*reversed(maxmin))) verts_out.append([l[::-1] for l in out[::-1]]) edges_out.append(edges) if has_mat_out: center = [(u + v) * .5 for u, v in maxmin] mat = Matrix.Translation(center) scale = [(u - v) * .5 for u, v in maxmin] for i, s in enumerate(scale): mat[i][i] = s mat_out.append(mat) if has_mean: avr = list(map(sum, zip(*v))) avr = [n / len(v) for n in avr] mean_out.append([avr]) if self.outputs['Vertices'].is_linked: SvSetSocketAnyType(self, 'Vertices', verts_out) if self.outputs['Edges'].is_linked: SvSetSocketAnyType(self, 'Edges', edges_out) if self.outputs['Mean'].is_linked: SvSetSocketAnyType(self, 'Mean', mean_out) if self.outputs['Center'].is_linked: SvSetSocketAnyType(self, 'Center', Matrix_listing(mat_out))
def process(self): # inputs if 'vertices' in self.outputs and self.outputs['vertices'].is_linked or \ 'edg_pol' in self.outputs and self.outputs['edg_pol'].is_linked: if 'vertices' in self.inputs and self.inputs['vertices'].is_linked and \ 'edg_pol' in self.inputs and self.inputs['edg_pol'].is_linked: vertices = SvGetSocketAnyType(self, self.inputs['vertices']) edgs_pols = SvGetSocketAnyType(self, self.inputs['edg_pol']) else: return vert_out = [] edpo_out = [] for k, ob in enumerate(edgs_pols): for ep in ob: new_vers = [] new_edpo = [] for i, index in enumerate(ep): new_vers.append(vertices[k][index]) new_edpo.append(i) vert_out.append(new_vers) edpo_out.append([new_edpo]) if 'vertices' in self.outputs and self.outputs[ 'vertices'].is_linked: SvSetSocketAnyType(self, 'vertices', vert_out) if 'edg_pol' in self.outputs and self.outputs['edg_pol'].is_linked: SvSetSocketAnyType(self, 'edg_pol', edpo_out)
def process(self): if self.inputs['vertices1'].is_linked and self.inputs[ 'vertices2'].is_linked: prop1_ = SvGetSocketAnyType(self, self.inputs['vertices1']) prop1 = Vector_generate(prop1_) prop2_ = SvGetSocketAnyType(self, self.inputs['vertices2']) prop2 = Vector_generate(prop2_) elif self.inputs['matrix1'].is_linked and self.inputs[ 'matrix2'].is_linked: propa = SvGetSocketAnyType(self, self.inputs['matrix1']) prop1 = Matrix_location(Matrix_generate(propa)) propb = SvGetSocketAnyType(self, self.inputs['matrix2']) prop2 = Matrix_location(Matrix_generate(propb)) else: prop1, prop2 = [], [] if prop1 and prop2: if self.outputs['distances'].is_linked: #print ('distances input', str(prop1), str(prop2)) if self.Cross_dist: output = self.calcM(prop1, prop2) else: output = self.calcV(prop1, prop2) SvSetSocketAnyType(self, 'distances', output) #print ('distances out' , str(output)) else: SvSetSocketAnyType(self, 'distances', [])
def process(self): if 'vertices' in self.inputs and self.inputs['vertices'].is_linked and \ 'edges' in self.inputs and self.inputs['edges'].is_linked: verts = dataCorrect( SvGetSocketAnyType(self, self.inputs['vertices'])) edges = dataCorrect(SvGetSocketAnyType(self, self.inputs['edges'])) sides = repeat_last(self.inputs['Sides'].sv_get()[0]) verts_out = [] edges_out = [] polys_out = [] for v, e, s in zip(verts, edges, sides): res = fill_holes(v, e, int(s)) if not res: return verts_out.append(res[0]) edges_out.append(res[1]) polys_out.append(res[2]) if 'vertices' in self.outputs and self.outputs[ 'vertices'].is_linked: SvSetSocketAnyType(self, 'vertices', verts_out) if 'edges' in self.outputs and self.outputs['edges'].is_linked: SvSetSocketAnyType(self, 'edges', edges_out) if 'polygons' in self.outputs and self.outputs[ 'polygons'].is_linked: SvSetSocketAnyType(self, 'polygons', polys_out)
def process(self): if not ('Edges' in self.outputs): return # inputs if self.outputs['Edges'].is_linked or self.outputs['Vertices'].is_linked: if self.inputs['Level'].is_linked: Integer = int(SvGetSocketAnyType(self, self.inputs['Level'])[0][0]) else: Integer = self.level_ if self.inputs['Size'].is_linked: Step = SvGetSocketAnyType(self, self.inputs['Size'])[0][0] else: Step = self.size_ # outputs if self.outputs['Vertices'].is_linked: verts = self.hilbert(Step, Integer) SvSetSocketAnyType(self, 'Vertices', verts) if self.outputs['Edges'].is_linked: listEdg = [] r = len(verts[0])-1 for i in range(r): listEdg.append((i, i+1)) edg = list(listEdg) SvSetSocketAnyType(self, 'Edges', [edg])
def process(self): if self.outputs['vertices'].is_linked or self.outputs['data'].is_linked: slots = [] for socket in self.inputs: if socket.is_linked: slots.append(socket.sv_get()) if len(slots) == 0: return lol = levelsOflist(slots) if lol == 4: result = self.connect(slots, self.dir_check, self.cicl_check_U, self.cicl_check_V, lol, self.polygons, self.slice_check, self.cup_U, self.cup_V) elif lol == 5: one = [] two = [] for slo in slots: for s in slo: result = self.connect([s], self.dir_check, self.cicl_check_U, self.cicl_check_V, lol, self.polygons, self.slice_check, self.cup_U, self.cup_V) one.extend(result[0]) two.extend(result[1]) result = (one, two) if self.outputs['vertices'].is_linked: SvSetSocketAnyType(self, 'vertices', result[0]) if self.outputs['data'].is_linked: SvSetSocketAnyType(self, 'data', result[1])
def process(self): if 'Item' in self.outputs and self.outputs['Item'].is_linked or \ 'Other' in self.outputs and self.outputs['Other'].is_linked: if 'Data' in self.inputs and self.inputs['Data'].is_linked: data = SvGetSocketAnyType(self, self.inputs['Data']) if 'Item' in self.inputs and self.inputs['Item'].is_linked: items = SvGetSocketAnyType(self, self.inputs['Item']) else: items = [[self.item]] if 'Item' in self.outputs and self.outputs['Item'].is_linked: if self.level - 1: out = self.get(data, self.level - 1, items, self.get_items) else: out = self.get_items(data, items[0]) SvSetSocketAnyType(self, 'Item', out) if 'Other' in self.outputs and self.outputs['Other'].is_linked: if self.level - 1: out = self.get(data, self.level - 1, items, self.get_other) else: out = self.get_other(data, items[0]) SvSetSocketAnyType(self, 'Other', out)
def process(self): # inputs if 'Polygons' not in self.outputs: return Radius = self.inputs['Radius'].sv_get()[0] U = [max(int(u), 3) for u in self.inputs['U'].sv_get()[0]] V = [max(int(v), 3) for v in self.inputs['V'].sv_get()[0]] params = match_long_repeat([U, V, Radius]) # outputs if self.outputs['Vertices'].is_linked: verts = [ sphere_verts(u, v, r, self.Separate) for u, v, r in zip(*params) ] SvSetSocketAnyType(self, 'Vertices', verts) if self.outputs['Edges'].is_linked: edges = [sphere_edges(u, v) for u, v, r in zip(*params)] SvSetSocketAnyType(self, 'Edges', edges) if self.outputs['Polygons'].is_linked: faces = [sphere_faces(u, v) for u, v, r in zip(*params)] SvSetSocketAnyType(self, 'Polygons', faces)
def process(self): # inputs if 'Vertices' in self.inputs and self.inputs['Vertices'].is_linked: Vertices = SvGetSocketAnyType(self, self.inputs['Vertices']) else: Vertices = [] if 'Vert A' in self.inputs and self.inputs['Vert A'].is_linked: Vert_A = SvGetSocketAnyType(self, self.inputs['Vert A'])[0] else: Vert_A = [[0.0, 0.0, 0.0]] if 'Vert B' in self.inputs and self.inputs['Vert B'].is_linked: Vert_B = SvGetSocketAnyType(self, self.inputs['Vert B'])[0] else: Vert_B = [[1.0, 0.0, 0.0]] if 'Plane' in self.inputs and self.inputs['Plane'].is_linked: Plane = SvGetSocketAnyType(self, self.inputs['Plane']) else: Plane = [Matrix()] # outputs if 'Vertices' in self.outputs and self.outputs['Vertices'].is_linked: if self.mode == 'VERTEX': parameters = match_long_repeat([Vertices, Vert_A]) points = [mirrorPoint(v, a) for v, a in zip(*parameters)] SvSetSocketAnyType(self, 'Vertices', points) elif self.mode == 'AXIS': parameters = match_long_repeat([Vertices, Vert_A, Vert_B]) points = [mirrorAxis(v, a, b) for v, a, b in zip(*parameters)] SvSetSocketAnyType(self, 'Vertices', points) elif self.mode == 'PLANE': parameters = match_long_repeat([Vertices, Plane]) points = [mirrorPlane(v, p) for v, p in zip(*parameters)] SvSetSocketAnyType(self, 'Vertices', points)
def process(self): # inputs Count = self.inputs['Count'].sv_get()[0][0] Scale = self.inputs['Scale'].sv_get()[0][0] SP1 = self.inputs['XX'].sv_get()[0][0] SP2 = self.inputs['YY'].sv_get()[0][0] SP3 = self.inputs['ZZ'].sv_get()[0][0] #print(self.formula, self.XX_YY, self.i_override) # outputs if self.outputs['Verts'].is_linked: try: out = self.makeverts(Count, Scale, SP1, SP2, SP3, self.formulaX, self.formulaY, self.formulaZ, self.X_X, self.Y_Y, self.Z_Z, self.i_override) SvSetSocketAnyType(self, 'Verts', out) except: print('Cannot calculate, formula generator') out = sv_no_ve edg = sv_no_ed SvSetSocketAnyType(self, 'Verts', sv_no_ve) SvSetSocketAnyType(self, 'Edges', sv_no_ed) return if self.outputs['Edges'].is_linked: edg = [[[i - 1, i] for i in range(1, Count)]] SvSetSocketAnyType(self, 'Edges', edg)
def process(self): if not self.outputs['Polygons'].is_linked: return verts = Vector_generate( SvGetSocketAnyType(self, self.inputs['Vertices'])) faces = self.inputs['Polygons'].sv_get() if not (len(verts) == len(faces)): return verts_out = [] polys_out = [] for v_obj, f_obj in zip(verts, faces): res = join_tris(v_obj, f_obj, self.limit) if not res: return verts_out.append(res[0]) polys_out.append(res[1]) if self.outputs['Vertices'].is_linked: SvSetSocketAnyType(self, 'Vertices', verts_out) SvSetSocketAnyType(self, 'Polygons', polys_out)
def process(self): # inputs if self.inputs['Radius'].is_linked: Radius = SvGetSocketAnyType(self, self.inputs['Radius'])[0] else: Radius = [self.rad_] if self.inputs['Nº Vertices'].is_linked: Vertices = SvGetSocketAnyType(self, self.inputs['Nº Vertices'])[0] Vertices = list(map(lambda x: max(3, int(x)), Vertices)) else: Vertices = [self.vert_] if self.inputs['Degrees'].is_linked: Angle = SvGetSocketAnyType(self, self.inputs['Degrees'])[0] Angle = list(map(lambda x: min(360, max(0, x)), Angle)) else: # okay this is silly but since the rest was written before this gave degrees. Angle = [degrees(self.degr_)] parameters = match_long_repeat([Angle, Vertices, Radius]) # outputs if self.outputs['Vertices'].is_linked: points = [self.make_verts(a, v, r) for a, v, r in zip(*parameters)] SvSetSocketAnyType(self, 'Vertices', points) if self.outputs['Edges'].is_linked: edg = [self.make_edges(v, a) for a, v, r in zip(*parameters)] SvSetSocketAnyType(self, 'Edges', edg) if self.outputs['Polygons'].is_linked: plg = [self.make_faces(a, v) for a, v, r in zip(*parameters)] SvSetSocketAnyType(self, 'Polygons', plg)
def update_csv(self): n_id = node_id(self) if self.reload_on_update: self.reload_csv() if self.current_text and n_id not in self.csv_data: self.reload_csv() if n_id not in self.csv_data: print("CSV auto reload failed, press update") self.use_custom_color = True self.color = FAIL_COLOR return self.use_custom_color = True self.color = READY_COLOR csv_data = self.csv_data[n_id] if not self.one_sock: for name in csv_data.keys(): if name in self.outputs and self.outputs[name].links: SvSetSocketAnyType(self, name, [csv_data[name]]) else: name = 'one_sock' SvSetSocketAnyType(self, 'one_sock', list(csv_data.values()))
def process(self): # inputs if self.inputs['Radius'].links: Radius = SvGetSocketAnyType(self, self.inputs['Radius'])[0] else: Radius = [self.rad_] if self.inputs['Nº Vertices'].links: Vertices = SvGetSocketAnyType(self, self.inputs['Nº Vertices'])[0] Vertices = list(map(lambda x: max(3, int(x)), Vertices)) else: Vertices = [self.vert_] if self.inputs['Degrees'].links: Angle = SvGetSocketAnyType(self, self.inputs['Degrees'])[0] Angle = list(map(lambda x: min(360, max(0, x)), Angle)) else: Angle = [self.degr_] parameters = match_long_repeat([Angle, Vertices, Radius]) if self.outputs['Vertices'].links: points = [self.make_verts(a, v, r) for a, v, r in zip(*parameters)] SvSetSocketAnyType(self, 'Vertices', points) if self.outputs['Edges'].links: edg = [self.make_edges(v, a) for a, v, r in zip(*parameters)] SvSetSocketAnyType(self, 'Edges', edg) if self.outputs['Polygons'].links: plg = [self.make_faces(a, v) for a, v, r in zip(*parameters)] SvSetSocketAnyType(self, 'Polygons', plg)
def process(self): # inputs inputs = self.inputs RadiusTop = inputs['RadTop'].sv_get()[0] RadiusBot = inputs['RadBot'].sv_get()[0] Vertices = [max(int(v), 3) for v in inputs['Vertices'].sv_get()[0]] Height = inputs['Height'].sv_get()[0] Sub = [max(int(s), 0) for s in inputs['Subdivisions'].sv_get()[0]] params = match_long_repeat([Sub, Vertices, Height, RadiusBot, RadiusTop]) # outputs if self.outputs['Vertices'].is_linked: points = [cylinder_vertices(s, v, h, rb, rt, self.Separate) for s, v, h, rb, rt in zip(*params)] SvSetSocketAnyType(self, 'Vertices', points) if self.outputs['Edges'].is_linked: edges = [cylinder_edges(s, v) for s, v, h, rb, rt in zip(*params)] SvSetSocketAnyType(self, 'Edges', edges) if self.outputs['Polygons'].is_linked: faces = [cylinder_faces(s, v, self.cap_) for s, v, h, rb, rt in zip(*params)] SvSetSocketAnyType(self, 'Polygons', faces)
def process(self): if 'Matrix' in self.inputs and self.inputs['Matrix'].is_linked: matrixes_ = SvGetSocketAnyType(self, self.inputs['Matrix']) matrixes = Matrix_generate(matrixes_) if 'Location' in self.outputs and self.outputs[ 'Location'].is_linked: locs = Matrix_location(matrixes, list=True) SvSetSocketAnyType(self, 'Location', locs) if 'Scale' in self.outputs and self.outputs['Scale'].is_linked: locs = Matrix_scale(matrixes, list=True) SvSetSocketAnyType(self, 'Scale', locs) if ('Rotation' in self.outputs and self.outputs['Rotation'].is_linked) \ or ('Angle' in self.outputs and self.outputs['Angle'].is_linked): locs = Matrix_rotation(matrixes, list=True) rots = [] angles = [] for lists in locs: rots.append([pair[0] for pair in lists]) for pair in lists: angles.append(degrees(pair[1])) SvSetSocketAnyType(self, 'Rotation', rots) SvSetSocketAnyType(self, 'Angle', [angles]) else: matrixes = [[]]
def process(self): if not all((s.is_linked for s in self.inputs)): return if not any((s.is_linked for s in self.outputs)): return versR = Vector_generate(SvGetSocketAnyType(self, self.inputs['VersR'])) versD = Vector_generate(SvGetSocketAnyType(self, self.inputs['VersD'])) edgeR = SvGetSocketAnyType(self, self.inputs['EdgeR']) edgeD = SvGetSocketAnyType(self, self.inputs['EdgeD']) verts_out = [] edges_out = [] mesh_join = self.mesh_join # only first obj verD = [v - versD[0][0] for v in versD[0]] edgD = edgeD[0] d_vector = verD[-1].copy() d_scale = d_vector.length d_vector.normalize() for vc, edg in zip(versR, edgeR): if mesh_join: v_out = [] v_out_app = v_out.append e_out = [] e_out_app = e_out.append for e in edg: if not mesh_join: v_out = [] v_out_app = v_out.append e_vector = vc[e[1]] - vc[e[0]] e_scale = e_vector.length e_vector.normalize() q1 = d_vector.rotation_difference(e_vector) mat_s = Matrix.Scale(e_scale / d_scale, 4) mat_r = Matrix.Rotation(q1.angle, 4, q1.axis) mat_l = Matrix.Translation(vc[e[0]]) mat = mat_l * mat_r * mat_s offset = len(v_out) for v in verD: v_out_app((mat * v)[:]) if mesh_join: for edge in edgD: e_out_app([i + offset for i in edge]) else: verts_out.append(v_out) edges_out.append(edgD) if mesh_join: verts_out.append(v_out) edges_out.append(e_out) if 'Vertices' in self.outputs and self.outputs['Vertices'].is_linked: SvSetSocketAnyType(self, 'Vertices', verts_out) if 'Edges' in self.outputs and self.outputs['Edges'].is_linked: SvSetSocketAnyType(self, 'Edges', edges_out)
def process(self): self.read_xml() self.make_sockets() self.xml_text_format() if not hasattr(self, 'xml_tree'): return if any(output.is_linked for output in self.outputs): lsys = LSystem(self.xml_tree, self.maxmats) shapes = lsys.evaluate(seed=self.rseed) mat_sublist = [] edges_out = [] verts_out = [] faces_out = [] # make last entry in shapes None # to allow make tube to finish last tube if shapes[-1]: shapes.append(None) # dictionary for matrix lists shape_names = set([ x.attrib.get('shape') for x in self.xml_tree.iter('instance') ]) mat_dict = {s: [] for s in shape_names} if self.inputs['Vertices'].is_linked: verts = Vector_generate( SvGetSocketAnyType(self, self.inputs['Vertices'])) for i, shape in enumerate(shapes): if shape: mat_sublist.append(shape[1]) mat_dict[shape[0]].append(shape[1]) else: if len(mat_sublist) > 0: if self.inputs['Vertices'].is_linked: v, e, f = lsys.make_tube(mat_sublist, verts) if v: verts_out.append(v) edges_out.append(e) faces_out.append(f) mat_sublist = [] if self.outputs['Vertices'].is_linked: SvSetSocketAnyType(self, 'Vertices', verts_out) if self.outputs['Edges'].is_linked: SvSetSocketAnyType(self, 'Edges', edges_out) if self.outputs['Faces'].is_linked: SvSetSocketAnyType(self, 'Faces', faces_out) for shape in shape_names: if self.outputs[shape].is_linked: SvSetSocketAnyType(self, shape, Matrix_listing(mat_dict[shape]))
def process(self): # outputs if self.outputs['Current Frame'].is_linked: SvSetSocketAnyType(self, 'Current Frame', [[bpy.context.scene.frame_current]]) if self.outputs['Start Frame'].is_linked: SvSetSocketAnyType(self, 'Start Frame', [[bpy.context.scene.frame_start]]) if self.outputs['End Frame'].is_linked: SvSetSocketAnyType(self, 'End Frame', [[bpy.context.scene.frame_end]])
def process(self): if 'vertices' in self.inputs and self.inputs['vertices'].links \ and self.inputs['edg_pol'].links \ and self.inputs['cut_matrix'].links: verts_ob = Vector_generate( SvGetSocketAnyType(self, self.inputs['vertices'])) edg_pols_ob = SvGetSocketAnyType(self, self.inputs['edg_pol']) if self.inputs['matrix'].links: matrixs = SvGetSocketAnyType(self, self.inputs['matrix']) else: matrixs = [] for le in verts_ob: matrixs.append(Matrix()) cut_mats = SvGetSocketAnyType(self, self.inputs['cut_matrix']) verts_out = [] edges_out = [] for cut_mat in cut_mats: cut_mat = Matrix(cut_mat) pp = Vector((0.0, 0.0, 0.0)) * cut_mat.transposed() pno = Vector((0.0, 0.0, 1.0)) * cut_mat.to_3x3().transposed() verts_pre_out = [] edges_pre_out = [] for idx_mob, matrix in enumerate(matrixs): idx_vob = min(idx_mob, len(verts_ob) - 1) idx_epob = min(idx_mob, len(edg_pols_ob) - 1) matrix = Matrix(matrix) x_me = section(verts_ob[idx_vob], edg_pols_ob[idx_epob], matrix, pp, pno, self.fill_check, self.tri) if x_me: verts_pre_out.append(x_me['Verts']) edges_pre_out.append(x_me['Edges']) if verts_pre_out: verts_out.extend(verts_pre_out) edges_out.extend(edges_pre_out) if 'vertices' in self.outputs and self.outputs['vertices'].links: output = Vector_degenerate(verts_out) SvSetSocketAnyType(self, 'vertices', output) if 'edges' in self.outputs and self.outputs['edges'].links: SvSetSocketAnyType(self, 'edges', edges_out) else: pass
def process(self): if 'Vertices' in self.inputs and self.inputs['Vertices'].is_linked and \ 'PolyEdge' in self.inputs and self.inputs['PolyEdge'].is_linked: verts = SvGetSocketAnyType(self, self.inputs['Vertices']) poly_edge = SvGetSocketAnyType(self, self.inputs['PolyEdge']) verts_out = [] poly_edge_out = [] for ve, pe in zip(verts, poly_edge): # trying to remove indeces of polygons that more that length of # vertices list. But it doing wrong, ideces not mutch vertices... # what am i doing wrong? # i guess, i didn't understood this iterations at all delp = [] for p in pe: deli = [] for i in p: if i >= len(ve): deli.append(i) if deli and (len(p) - len(deli)) >= 2: print(deli) for k in deli: p.remove(k) elif (len(p) - len(deli)) <= 1: delp.append(p) if delp: for d in delp: pe.remove(d) indx = set(chain.from_iterable(pe)) verts_out.append([v for i, v in enumerate(ve) if i in indx]) v_index = dict([(j, i) for i, j in enumerate(sorted(indx))]) poly_edge_out.append( [list(map(lambda n: v_index[n], p)) for p in pe]) if 'Vertices' in self.outputs and self.outputs[ 'Vertices'].is_linked: SvSetSocketAnyType(self, 'Vertices', verts_out) if 'PolyEdge' in self.outputs and self.outputs[ 'PolyEdge'].is_linked: if poly_edge_out: SvSetSocketAnyType(self, 'PolyEdge', poly_edge_out) else: SvSetSocketAnyType(self, 'PolyEdge', [[[]]])
def process(self): if self.inputs['data'].is_linked and self.outputs['data'].is_linked: outEval = SvGetSocketAnyType(self, self.inputs['data']) #outCorr = dataCorrect(outEval) # this is bullshit, as max 3 in levels levels = self.level - 1 out = flip(outEval, levels) SvSetSocketAnyType(self, 'data', out)
def process(self): # inputs if 'Start' in self.inputs and self.inputs['Start'].links: tmp = SvGetSocketAnyType(self, self.inputs['Start']) Start = tmp[0][0] else: Start = self.start_ if 'Stop' in self.inputs and self.inputs['Stop'].links: tmp = SvGetSocketAnyType(self, self.inputs['Stop']) Stop = tmp[0][0] else: Stop = self.stop_ if 'Divisions' in self.inputs and self.inputs['Divisions'].links: tmp = SvGetSocketAnyType(self, self.inputs['Divisions']) Divisions = tmp[0][0] else: Divisions = self.divisions_ # outputs if 'Range' in self.outputs and self.outputs['Range'].links: if Divisions < 2: Divisions = 2 Range = [Start] if Divisions > 2: Range.extend([c for c in self.xfrange(Start, Stop, Divisions)]) Range.append(Stop) SvSetSocketAnyType(self, 'Range', [Range])
def process(self): # inputs Float = min(max(float(self.inputs[0].sv_get()[0][0]), self.minim), self.maxim) # outputs if self.outputs['Float'].is_linked: SvSetSocketAnyType(self, 'Float', [[Float]])
def process(self): # достаём два слота - вершины и полики if 'Centers' in self.outputs and self.outputs[ 'Centers'].links or self.outputs['Normals'].links: if 'Polygons' in self.inputs and 'Vertices' in self.inputs and self.inputs[ 'Polygons'].links and self.inputs['Vertices'].links: #if type(self.inputs['Poligons'].links[0].from_socket) == StringsSocket: pols = SvGetSocketAnyType(self, self.inputs['Polygons']) #if type(self.inputs['Vertices'].links[0].from_socket) == VerticesSocket: vers = SvGetSocketAnyType(self, self.inputs['Vertices']) normalsFORout = [] for i, obj in enumerate(vers): mesh_temp = bpy.data.meshes.new('temp') mesh_temp.from_pydata(obj, [], pols[i]) mesh_temp.update(calc_edges=True) tempobj = [] for v in mesh_temp.vertices: tempobj.append(v.normal[:]) normalsFORout.append(tempobj) bpy.data.meshes.remove(mesh_temp) #print (normalsFORout) if 'Normals' in self.outputs and self.outputs['Normals'].links: SvSetSocketAnyType(self, 'Normals', normalsFORout)
def process(self): # inputs if 'vertices' in self.inputs and self.inputs['vertices'].links and \ type(self.inputs['vertices'].links[0].from_socket) == VerticesSocket: vers_ = SvGetSocketAnyType(self, self.inputs['vertices']) vers = Vector_generate(vers_) else: vers = [] if 'vectors' in self.inputs and self.inputs['vectors'].links and \ type(self.inputs['vectors'].links[0].from_socket) == VerticesSocket: vecs_ = SvGetSocketAnyType(self, self.inputs['vectors']) vecs = Vector_generate(vecs_) else: vecs = [] if 'multiplier' in self.inputs and self.inputs['multiplier'].links and \ type(self.inputs['multiplier'].links[0].from_socket) == StringsSocket: mult = SvGetSocketAnyType(self, self.inputs['multiplier']) else: mult = [[self.mult_]] # outputs if 'vertices' in self.outputs and self.outputs['vertices'].links: mov = self.moved(vers, vecs, mult) SvSetSocketAnyType(self, 'vertices', mov)
def output_mode(self): outputs = self.outputs if (len(outputs) == 0) or (not outputs[0].links): print('has no link!') return prop_to_eval = self.eval_str.strip() macro = prop_to_eval.split("(")[0] tvar = None if macro in ['eval_text', 'read_text']: tvar = process_macro(self, macro, prop_to_eval) else: tvar = process_prop_string(self, prop_to_eval) # explicit None must be caught. not 0 or False if tvar is None: return if not (self.previous_eval_str == self.eval_str): print("tvar: ", tvar) self.morph_output_socket_type(tvar) # finally we can set this. data = wrap_output_data(tvar) SvSetSocketAnyType(self, 0, data) self.previous_eval_str = self.eval_str
def process(self): # inputs if 'Start' in self.inputs and self.inputs['Start'].links: tmp = SvGetSocketAnyType(self, self.inputs['Start']) Start = tmp[0][0] else: Start = self.start_ if 'Stop' in self.inputs and self.inputs['Stop'].links: tmp = SvGetSocketAnyType(self, self.inputs['Stop']) Stop = tmp[0][0] else: Stop = self.stop_ if 'Step' in self.inputs and self.inputs['Step'].links: tmp = SvGetSocketAnyType(self, self.inputs['Step']) Step = tmp[0][0] else: Step = self.step_ # outputs if 'Series' in self.outputs and len(self.outputs['Series'].links) > 0: #print (Start, Stop, Step) if Step < 0: Step = 1 if Stop < Start: Stop = Start + 1 series = [c for c in self.xfrange(Start, Stop, Step)] SvSetSocketAnyType(self, 'Series', [series])
def process(self): # check inputs and that there is at least one output func_dict = { 'SHORT': match_short, 'CYCLE': match_long_cycle, 'REPEAT': match_long_repeat, 'XREF': match_cross2 } count_inputs = sum(s.is_linked for s in self.inputs) count_outputs = sum(s.is_linked for s in self.outputs) if count_inputs == len(self.inputs) - 1 and count_outputs: out = [] lsts = [] # get data for socket in self.inputs: if socket.is_linked: lsts.append(SvGetSocketAnyType(self, socket)) out = self.match(lsts, self.level, func_dict[self.mode], func_dict[self.mode_final]) # output into linked sockets s for i, socket in enumerate(self.outputs): if i == len(out): # never write to last socket break if socket.is_linked: SvSetSocketAnyType(self, socket.name, out[i])
def process(self): if not self.outputs['Matrix'].is_linked: return loc_ = self.inputs['Location'].sv_get() loc = Vector_generate(loc_) scale_ = self.inputs['Scale'].sv_get() scale = Vector_generate(scale_) rot_ = self.inputs['Rotation'].sv_get() rot = Vector_generate(rot_) rotA = [[]] angle = [[0.0]] # it isn't a good idea to hide things like this if self.inputs['Angle'].is_linked: other = get_other_socket(self.inputs['Angle']) if isinstance(other, StringsSocket): angle = self.inputs['Angle'].sv_get() elif isinstance(other, VerticesSocket): rotA_ = self.inputs['Angle'].sv_get() rotA = Vector_generate(rotA_) max_l = max(len(loc[0]), len(scale[0]), len(rot[0]), len(angle[0]), len(rotA[0])) orig = [] for l in range(max_l): M = mathutils.Matrix() orig.append(M) matrixes_ = matrixdef(orig, loc, scale, rot, angle, rotA) matrixes = Matrix_listing(matrixes_) SvSetSocketAnyType(self, 'Matrix', matrixes)