def update(self): if 'Size' in self.inputs and self.inputs['Size'].links: size = SvGetSocketAnyType(self, self.inputs['Size'])[0] else: size = [self.Size] if 'Divx' in self.inputs and self.inputs['Divx'].links: divx = int(SvGetSocketAnyType(self, self.inputs['Divx'])[0][0]) else: divx = self.Divx if 'Divy' in self.inputs and self.inputs['Divy'].links: divy = int(SvGetSocketAnyType(self, self.inputs['Divy'])[0][0]) else: divy = self.Divy if 'Divz' in self.inputs and self.inputs['Divz'].links: divz = int(SvGetSocketAnyType(self, self.inputs['Divz'])[0][0]) else: divz = self.Divz out = [a for a in (zip(*[self.makecube(s, divx, divy, divz) for s in size]))] # outputs if 'Vers' in self.outputs and self.outputs['Vers'].links: SvSetSocketAnyType(self, 'Vers', out[0]) if 'Edgs' in self.outputs and self.outputs['Edgs'].links: SvSetSocketAnyType(self, 'Edgs', out[1]) if 'Pols' in self.outputs and self.outputs['Pols'].links: SvSetSocketAnyType(self, 'Pols', out[2])
def process(self): segments, longest = self.get_input() if longest < 1: print('logic error, longest < 1') return self.homogenize_input(segments, longest) full_result_verts = [] full_result_edges = [] for idx in range(longest): path_object = PathParser(self, segments, idx) vertices, edges = path_object.get_geometry() axis_fill = { 'X': lambda coords: (0, coords[0], coords[1]), 'Y': lambda coords: (coords[0], 0, coords[1]), 'Z': lambda coords: (coords[0], coords[1], 0) }.get(self.current_axis) vertices = list(map(axis_fill, vertices)) full_result_verts.append(vertices) full_result_edges.append(edges) if full_result_verts: SvSetSocketAnyType(self, 'Verts', full_result_verts) if self.outputs['Edges'].links: SvSetSocketAnyType(self, 'Edges', full_result_edges)
def update(self): if 'Matrix' in self.inputs and self.inputs['Matrix'].links: matrixes_ = SvGetSocketAnyType(self, self.inputs['Matrix']) matrixes = Matrix_generate(matrixes_) if 'Location' in self.outputs and self.outputs['Location'].links: locs = Matrix_location(matrixes, list=True) SvSetSocketAnyType(self, 'Location', locs) if 'Scale' in self.outputs and self.outputs['Scale'].links: locs = Matrix_scale(matrixes, list=True) SvSetSocketAnyType(self, 'Scale', locs) if ('Rotation' in self.outputs and self.outputs['Rotation'].links) \ or ('Angle' in self.outputs and self.outputs['Angle'].links): 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 update(self): # inputs if 'vertices' in self.outputs and self.outputs['vertices'].links or \ 'edg_pol' in self.outputs and self.outputs['edg_pol'].links: if 'vertices' in self.inputs and self.inputs['vertices'].links and \ 'edg_pol' in self.inputs and self.inputs['edg_pol'].links: 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'].links: SvSetSocketAnyType(self, 'vertices', vert_out) if 'edg_pol' in self.outputs and self.outputs['edg_pol'].links: SvSetSocketAnyType(self, 'edg_pol', edpo_out)
def update(self): # inputs if 'Vertices' in self.inputs and self.inputs['Vertices'].links: Vertices = SvGetSocketAnyType(self, self.inputs['Vertices']) else: Vertices = [] if 'Vert A' in self.inputs and self.inputs['Vert A'].links: 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'].links: 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'].links: Plane = SvGetSocketAnyType(self, self.inputs['Plane']) else: Plane = [Matrix()] # outputs if 'Vertices' in self.outputs and self.outputs['Vertices'].links: 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 update(self): # inputs if 'Radius' in self.inputs and self.inputs['Radius'].links: Radius = SvGetSocketAnyType(self, self.inputs['Radius'])[0] else: Radius = [self.rad_] if 'Nº Vertices' in self.inputs and 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 'Degrees' in self.inputs and self.inputs['Degrees'].links: 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 'Vertices' in self.outputs and self.outputs['Vertices'].links: points = [self.make_verts(a, v, r) for a, v, r in zip(*parameters)] SvSetSocketAnyType(self, 'Vertices', points) if 'Edges' in self.outputs and self.outputs['Edges'].links: edg = [self.make_edges(v, a) for a, v, r in zip(*parameters)] SvSetSocketAnyType(self, 'Edges', edg) if 'Polygons' in self.outputs and self.outputs['Polygons'].links: plg = [self.make_faces(a, v) for a, v, r in zip(*parameters)] SvSetSocketAnyType(self, 'Polygons', plg)
def update(self): if 'Vertices' in self.inputs and self.inputs['Vertices'].links and \ 'PolyEdge' in self.inputs and self.inputs['PolyEdge'].links: verts = SvGetSocketAnyType(self, self.inputs['Vertices']) poly_edge = SvGetSocketAnyType(self, self.inputs['PolyEdge']) verts_out = [] poly_edge_out = [] offset = 0 for obj in zip(verts, poly_edge): verts_out.extend(obj[0]) if offset: res = [ list(map(lambda x: operator.add(offset, x), ep)) for ep in obj[1] ] poly_edge_out.extend(res) else: poly_edge_out.extend(obj[1]) offset += len(obj[0]) if 'Vertices' in self.outputs and self.outputs['Vertices'].links: SvSetSocketAnyType(self, 'Vertices', [verts_out]) if 'PolyEdge' in self.outputs and self.outputs['PolyEdge'].links: SvSetSocketAnyType(self, 'PolyEdge', [poly_edge_out])
def update(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'].links: 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'].links: edg = [[[i - 1, i] for i in range(1, Count)]] SvSetSocketAnyType(self, 'Edges', edg)
def update(self): if 'polygons' not in self.outputs: return if 'vertices' in self.inputs and self.inputs['vertices'].links and \ 'edges' in self.inputs and self.inputs['edges'].links: 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'].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)
def update(self): if 'Data' in self.inputs and len(self.inputs['Data'].links) > 0: inputsocketname = 'Data' outputsocketname = ['Item', 'Other'] changable_sockets(self, inputsocketname, outputsocketname) if 'Item' in self.outputs and self.outputs['Item'].links or \ 'Other' in self.outputs and self.outputs['Other'].links: if 'Data' in self.inputs and self.inputs['Data'].links: data = SvGetSocketAnyType(self, self.inputs['Data']) if 'Item' in self.inputs and self.inputs['Item'].links: items = SvGetSocketAnyType(self, self.inputs['Item']) else: items = [[self.item]] if 'Item' in self.outputs and self.outputs['Item'].links: 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'].links: 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 update(self): for name in ['vertices1', 'vertices2', 'matrix1', 'matrix2']: if name not in self.inputs: return if self.inputs['vertices1'].links and self.inputs['vertices2'].links: prop1_ = SvGetSocketAnyType(self, self.inputs['vertices1']) prop1 = Vector_generate(prop1_) prop2_ = SvGetSocketAnyType(self, self.inputs['vertices2']) prop2 = Vector_generate(prop2_) elif self.inputs['matrix1'].links and self.inputs['matrix2'].links: 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'].links: #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 update(self): if self.inputs['Data'].links: # адаптивный сокет inputsocketname = 'Data' outputsocketname = ["Middl", 'First', 'Last'] changable_sockets(self, inputsocketname, outputsocketname) if 'First' in self.outputs and self.outputs['First'].links or \ 'Last' in self.outputs and self.outputs['Last'].links or \ 'Middl' in self.outputs and self.outputs['Middl'].links: data = SvGetSocketAnyType(self, self.inputs['Data']) # blocking too height values of levels, reduce levels = levelsOflist(data) - 2 if levels >= self.level: levels = self.level - 1 elif levels < 1: levels = 1 # assign out if self.outputs['First'].links: out = self.count(data, levels, 0) SvSetSocketAnyType(self, 'First', out) if self.outputs['Middl'].links: out = self.count(data, levels, 1) SvSetSocketAnyType(self, 'Middl', out) if self.outputs['Last'].links: out = self.count(data, levels, 2) SvSetSocketAnyType(self, 'Last', out)
def update(self): if not ('Edges' in self.outputs): return # inputs if self.outputs['Edges'].links or self.outputs['Vertices'].links: if self.inputs['Level'].links: Integer = int( SvGetSocketAnyType(self, self.inputs['Level'])[0][0]) else: Integer = self.level_ if self.inputs['Size'].links: Step = SvGetSocketAnyType(self, self.inputs['Size'])[0][0] else: Step = self.size_ # outputs if self.outputs['Vertices'].links: verts = self.hilbert(Step, Integer) SvSetSocketAnyType(self, 'Vertices', verts) if self.outputs['Edges'].links: listEdg = [] r = len(verts[0]) - 1 for i in range(r): listEdg.append((i, i + 1)) edg = list(listEdg) SvSetSocketAnyType(self, 'Edges', [edg])
def update(self): if 'Polygons' not in self.outputs: return # 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'].links: 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'].links: edges = [cylinder_edges(s, v) for s, v, h, rb, rt in zip(*params)] SvSetSocketAnyType(self, 'Edges', edges) if self.outputs['Polygons'].links: faces = [ cylinder_faces(s, v, self.cap_) for s, v, h, rb, rt in zip(*params) ] SvSetSocketAnyType(self, 'Polygons', faces)
def update(self): if not self.noise_dict: self.noise_dict = { t[0]: t[1] for t in inspect.getmembers(noise.types) if isinstance(t[1], int) } if self.outputs and not self.outputs[0].links: return if 'Vertices' in self.inputs and self.inputs['Vertices'].links: verts = Vector_generate( SvGetSocketAnyType(self, self.inputs['Vertices'])) out = [] n_t = self.noise_dict[self.noise_type] n_f = self.noise_f[self.out_mode] for obj in verts: out.append([n_f(v, n_t) for v in obj]) if 'Noise V' in self.outputs and self.outputs['Noise V'].links: SvSetSocketAnyType(self, 'Noise V', Vector_degenerate(out)) if 'Noise S' in self.outputs and self.outputs['Noise S'].links: SvSetSocketAnyType(self, 'Noise S', out) return SvSetSocketAnyType(self, self.outputs[0].name, [[]])
def update(self): if not 'Edges' in self.outputs: return if not all((s.links for s in self.inputs)): return if not any((s.links 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'].links: SvSetSocketAnyType(self, 'Vertices', verts_out) if 'Edges' in self.outputs and self.outputs['Edges'].links: SvSetSocketAnyType(self, 'Edges', edges_out)
def update(self): # outputs if 'Current Frame' in self.outputs and self.outputs[ 'Current Frame'].links: SvSetSocketAnyType(self, 'Current Frame', [[bpy.context.scene.frame_current]]) if 'Start Frame' in self.outputs and self.outputs['Start Frame'].links: SvSetSocketAnyType(self, 'Start Frame', [[bpy.context.scene.frame_start]]) if 'End Frame' in self.outputs and self.outputs['End Frame'].links: SvSetSocketAnyType(self, 'End Frame', [[bpy.context.scene.frame_end]])
def update(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 update(self): if any((n in self.outputs for n in ['List', 'Vector List'])) and self.outputs[0].links: if self.mode == 'int_list': SvSetSocketAnyType(self, "List", [list(self.int_list[:self.int_])]) elif self.mode == 'float_list': SvSetSocketAnyType(self, "List", [list(self.float_list[:self.int_])]) elif self.mode == 'vector': c = self.v_int * 3 v_l = list(self.vector_list) out = list(zip(v_l[0:c:3], v_l[1:c:3], v_l[2:c:3])) SvSetSocketAnyType(self, "Vector List", [out])
def update(self): # changable types sockets in output # you need the next: # typ - needed self value # newsocket - needed self value # inputsocketname to get one socket to define type # outputsocketname to get list of outputs, that will be changed inputsocketname = 'data' outputsocketname = ['dataTrue', 'dataFalse'] changable_sockets(self, inputsocketname, outputsocketname) # input sockets if 'data' not in self.inputs: return False data = [[]] mask = [[1, 0]] if self.inputs['data'].links: data = SvGetSocketAnyType(self, self.inputs['data']) if self.inputs['mask'].links and \ type(self.inputs['mask'].links[0].from_socket) == StringsSocket: mask = SvGetSocketAnyType(self, self.inputs['mask']) result = self.getMask(data, mask, self.Level) # outupy sockets data if 'dataTrue' in self.outputs and self.outputs['dataTrue'].is_linked: SvSetSocketAnyType(self, 'dataTrue', result[0]) else: SvSetSocketAnyType(self, 'dataTrue', [[]]) # print ('всё',result) if 'dataFalse' in self.outputs and self.outputs['dataFalse'].is_linked: SvSetSocketAnyType(self, 'dataFalse', result[1]) else: SvSetSocketAnyType(self, 'dataFalse', [[]]) if 'mask' in self.outputs and self.outputs['mask'].is_linked: SvSetSocketAnyType(self, 'mask', result[2]) else: SvSetSocketAnyType(self, 'mask', [[]]) if 'ind_true' in self.outputs and self.outputs['ind_true'].is_linked: SvSetSocketAnyType(self, 'ind_true', result[3]) else: SvSetSocketAnyType(self, 'ind_true', [[]]) if 'ind_false' in self.outputs and self.outputs['ind_false'].is_linked: SvSetSocketAnyType(self, 'ind_false', result[4]) else: SvSetSocketAnyType(self, 'ind_false', [[]])
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 update(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 update(self): # inputs if 'Vectors' in self.outputs and len( self.outputs['Vectors'].links) > 0: if self.inputs['Vectors'].links and \ type(self.inputs['Vectors'].links[0].from_socket) == VerticesSocket \ and self.inputs['Matrixes'] and \ type(self.inputs['Matrixes'].links[0].from_socket) == MatrixSocket: vecs_ = SvGetSocketAnyType(self, self.inputs['Vectors']) vecs = Vector_generate(vecs_) #print (vecs) mats_ = dataCorrect( SvGetSocketAnyType(self, self.inputs['Matrixes'])) mats = Matrix_generate(mats_) else: vecs = [[]] mats = [Matrix()] # outputs vectors_ = self.vecscorrect(vecs, mats) vectors = Vector_degenerate(vectors_) SvSetSocketAnyType(self, 'Vectors', vectors)
def update(self): # inputs nrInputs = 1 if self.items_ in self.constant: nrInputs = 0 elif self.items_ in self.fx: nrInputs = 1 elif self.items_ in self.fxy: nrInputs = 2 # ugly hack to verify int property, should be improved. if self.items_ == 'ROUND-N': if 'Y' in self.inputs: self.inputs['Y'].prop_name = 'i_y' self.set_inputs(nrInputs) if 'X' in self.inputs: x = self.inputs['X'].sv_get(deepcopy=False) if 'Y' in self.inputs: y = self.inputs['Y'].sv_get(deepcopy=False) # outputs if 'float' in self.outputs and self.outputs['float'].links: result = [] if nrInputs == 0: result = [[self.constant[self.items_]]] elif nrInputs == 1: result = self.recurse_fx(x, self.fx[self.items_]) elif nrInputs == 2: result = self.recurse_fxy(x, y, self.fxy[self.items_]) SvSetSocketAnyType(self, 'float', result)
def update(self): # достаём два слота - вершины и полики if 'Data' in self.inputs and self.inputs['Data'].links: inputsocketname = 'Data' outputsocketname = [ 'Data', ] changable_sockets(self, inputsocketname, outputsocketname) data = SvGetSocketAnyType(self, self.inputs['Data']) if 'Number' in self.inputs and self.inputs['Number'].links: tmp = SvGetSocketAnyType(self, self.inputs['Number']) Number = tmp[0] else: Number = [self.number] if 'Data' in self.outputs and self.outputs['Data'].links: out_ = self.count(data, self.level, Number) if self.unwrap: if len(out_) > 0: out = [] for o in out_: out.extend(o) else: out = out_ SvSetSocketAnyType(self, 'Data', out)
def update(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 update(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 update(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 update(self): if 'Vertices' not in self.outputs: return if not any((s.links for s in self.outputs)): return if self.inputs['Vertices'].links: verts = SvGetSocketAnyType(self, self.inputs['Vertices']) verts = dataCorrect(verts) t_ins = self.inputs['Interval'].sv_get() verts_out = [] for v, t_in in zip(verts, repeat_last(t_ins)): pts = np.array(v).T tmp = np.apply_along_axis(np.linalg.norm, 0, pts[:, :-1] - pts[:, 1:]) t = np.insert(tmp, 0, 0).cumsum() t = t / t[-1] t_corr = [min(1, max(t_c, 0)) for t_c in t_in] # this should also be numpy if self.mode == 'LIN': out = [np.interp(t_corr, t, pts[i]) for i in range(3)] verts_out.append(list(zip(*out))) else: # SPL spl = cubic_spline(v, t) out = eval_spline(spl, t, t_corr) verts_out.append(out) if 'Vertices' in self.outputs and self.outputs['Vertices'].links: SvSetSocketAnyType(self, 'Vertices', verts_out)
def update(self): # inputs multi_socket(self, min=1) if 'data' in self.inputs and len(self.inputs['data'].links) > 0: inputsocketname = 'data' outputsocketname = ['data'] changable_sockets(self, inputsocketname, outputsocketname) if 'data' in self.outputs and self.outputs['data'].links: slots = [] for socket in self.inputs: if socket.links: slots.append(SvGetSocketAnyType(self, socket)) if len(slots) == 0: return list_result = joiner(slots, self.JoinLevel) result = list_result.copy() if self.mix_check: list_mix = myZip_2(slots, self.JoinLevel) result = list_mix.copy() if self.wrap_check: list_wrap = wrapper_2(slots, list_result, self.JoinLevel) result = list_wrap.copy() if self.mix_check: list_wrap_mix = wrapper_2(slots, list_mix, self.JoinLevel) result = list_wrap_mix.copy() SvSetSocketAnyType(self, 'data', result)