def process(self): if not any(o.is_linked for o in self.outputs): return sync_pointer_and_stored_name(self, "file_pointer", "filename") profile = self.load_profile() optional_inputs = self.get_optional_inputs(profile) var_names = self.get_variables() self.debug("Var_names: %s; optional: %s", var_names, optional_inputs) inputs = self.get_input() result_vertices = [] result_edges = [] result_knots = [] result_names = [] result_curves = [] if var_names: input_values = [] for name in var_names: try: input_values.append(inputs[name]) except KeyError as e: name = e.args[0] if name not in optional_inputs: if name in self.inputs: raise SvNoDataError(self.inputs[name]) else: self.adjust_sockets() raise SvNoDataError(self.inputs[name]) else: input_values.append([None]) parameters = match_long_repeat(input_values) else: parameters = [[[]]] input_names = [ socket.name for socket in self.inputs if socket.is_linked ] for values in zip(*parameters): variables = dict(zip(var_names, values)) interpreter = Interpreter(self, input_names) interpreter.interpret(profile, variables) verts = self.extend_out_verts(interpreter.vertices) result_vertices.append(verts) result_edges.append(interpreter.edges) knots = self.extend_out_verts(interpreter.knots) result_knots.append(knots) result_names.append([[name] for name in interpreter.knotnames]) result_curves.append(interpreter.curves) self.outputs['Vertices'].sv_set(result_vertices) self.outputs['Edges'].sv_set(result_edges) self.outputs['Knots'].sv_set(result_knots) self.outputs['KnotNames'].sv_set(result_names) if 'Curve' in self.outputs: self.outputs['Curve'].sv_set(result_curves)
def process(self): if not self.outputs[0].is_linked: return sync_pointer_and_stored_name(self, "file_pointer", "filename") var_names = self.get_variables() inputs = self.get_input() result_vertices = [] result_edges = [] result_faces = [] result_vertex_data = [] result_face_data = [] result_masks_dict = {} template = self.load_json() if var_names: input_values = [inputs[name] for name in var_names] parameters = match_long_repeat(input_values) else: parameters = [[[]]] for values in zip(*parameters): variables = dict(zip(var_names, values)) json, groups = evaluate(template, variables) verts = json['vertices'] result_vertices.append(verts) result_edges.append(json['edges']) result_faces.append(json['faces']) result_vertex_data.append(json.get('vertexdata', [])) result_face_data.append(json.get('facedata', [])) masks = self.groups_to_masks(groups, len(verts)) for name in masks.keys(): if name in result_masks_dict: result_masks_dict[name].append(masks[name]) else: result_masks_dict[name] = [masks[name]] self.outputs['Vertices'].sv_set(result_vertices) self.outputs['Edges'].sv_set(result_edges) self.outputs['Faces'].sv_set(result_faces) if 'VertexData' in self.outputs: self.outputs['VertexData'].sv_set(result_vertex_data) if 'FaceData' in self.outputs: self.outputs['FaceData'].sv_set(result_face_data) for name in result_masks_dict.keys(): self.outputs[name].sv_set(result_masks_dict[name])
def process(self): # upgrades older versions of ProfileMK3 to the version that has self.file_pointer if self.filename and not self.file_pointer: text = self.get_bpy_data_from_name(self.filename, bpy.data.texts) if text: self.file_pointer = text if not any(o.is_linked for o in self.outputs): return sync_pointer_and_stored_name(self, "file_pointer", "filename") profile = self.load_profile() optional_inputs = self.get_optional_inputs(profile) var_names = self.get_variables() self.debug("Var_names: %s; optional: %s", var_names, optional_inputs) inputs = self.get_input() result_vertices = [] result_edges = [] result_knots = [] result_names = [] result_curves = [] if var_names: input_values = [] for name in var_names: try: input_values.append(inputs[name]) except KeyError as e: name = e.args[0] if name not in optional_inputs: if name in self.inputs: raise SvNoDataError(self.inputs[name]) else: self.adjust_sockets() raise SvNoDataError(self.inputs[name]) else: input_values.append([None]) parameters = match_long_repeat(input_values) else: parameters = [[[]]] input_names = [ socket.name for socket in self.inputs if socket.is_linked ] for values in zip(*parameters): variables = dict(zip(var_names, values)) curves_form = Interpreter.NURBS if self.nurbs_out else None interpreter = Interpreter(self, input_names, curves_form=curves_form, z_axis=self.selected_axis) interpreter.interpret(profile, variables) verts = self.extend_out_verts(interpreter.vertices) result_vertices.append(verts) result_edges.append(interpreter.edges) knots = self.extend_out_verts(interpreter.knots) result_knots.append(knots) result_names.append([[name] for name in interpreter.knotnames]) all_curves = interpreter.curves if self.concat_curves: new_curves = [] for curves in self.group_curves(all_curves): if self.nurbs_out: curves = unify_curves_degree(curves) curve = concatenate_curves(curves) new_curves.append(curve) result_curves.append(new_curves) else: result_curves.append(all_curves) self.outputs['Vertices'].sv_set(result_vertices) self.outputs['Edges'].sv_set(result_edges) self.outputs['Knots'].sv_set(result_knots) self.outputs['KnotNames'].sv_set(result_names) if 'Curve' in self.outputs: self.outputs['Curve'].sv_set(result_curves)