def create(self, context): parent = None if context.active_object and is_one_of_points(context.active_object): parent = context.active_object if len(context.selected_objects ) == 1 and context.selected_objects[0].fp_type == self.FP_TYPE: parent = context.selected_objects[0] bpy.ops.mesh.primitive_plane_add(radius=self.POINT_RADIUS) obj = bpy.context.object Counter.register(obj, self.FP_TYPE) obj.name = self.BASE_NAME + '.' + Counter.get_counter_suffix(obj) if parent: obj.parent = parent obj.fp_expression = self.DEFAULT_EXPRESSION obj.fp_angle = self.DEFAULT_ANGLE obj.fp_count = self.COUNT obj.lock_location = (True, True, True) obj.show_name = True obj.select = False mat = bpy.data.materials.new('ЗаливкаТочки') mat.diffuse_color = self.FILL_COLOR obj.data.materials.append(mat) return obj
def create(self, context): parent = context.active_object dep_id = tuple([ d.fp_id for d in context.selected_objects if not d.fp_id == parent.fp_id ] + [0]) bpy.ops.mesh.primitive_plane_add(radius=self.POINT_RADIUS) obj = context.object Counter.register(obj, self.FP_TYPE) obj.name = self.BASE_NAME + '.' + Counter.get_counter_suffix(obj) obj.parent = parent obj.fp_deps = dep_id obj.fp_expression = self.DEFAULT_EXPRESSION obj.lock_location = (True, True, True) obj.show_name = True obj.select = False mat = bpy.data.materials.new('ЗаливкаТочкиОтражениеЛинии') mat.diffuse_color = self.FILL_COLOR obj.data.materials.append(mat) draw_line = Line() parent.select = True obj.select = True draw_line.create(context)
def create(self, context): parent = context.active_object dep_id = tuple(parent.fp_deps30) bpy.ops.mesh.primitive_plane_add(radius=self.POINT_RADIUS) line_length = [0] * 29 obj = bpy.context.object Counter.register(obj, self.FP_TYPE) obj.name = self.BASE_NAME + '.' + Counter.get_counter_suffix(obj) obj.fp_deps30 = dep_id obj.parent = parent obj.fp_expression = self.DEFAULT_EXPRESSION obj.lock_location = (True, True, True) obj.show_name = True obj.select = False obj.fp_line_length = line_length mat = bpy.data.materials.new('ЗаливкаТочкиРазделениеСложнойКривой') mat.diffuse_color = self.FILL_COLOR obj.data.materials.append(mat)
def create(self, context): parent = context.active_object points_parent = [ obj for obj in bpy.data.objects if obj.fp_id > 0 and obj.fp_id in parent.fp_deps ] dep_id = tuple([d.fp_id for d in points_parent] + [0]) bpy.ops.mesh.primitive_plane_add(radius=self.POINT_RADIUS) obj = bpy.context.object Counter.register(obj, self.FP_TYPE) obj.name = self.BASE_NAME + '.' + Counter.get_counter_suffix(obj) obj.fp_deps = dep_id obj.parent = parent obj.fp_expression = self.DEFAULT_EXPRESSION obj.lock_location = (True, True, True) obj.show_name = True obj.select = False mat = bpy.data.materials.new('ЗаливкаТочкиРазделениеКривойБезье') mat.diffuse_color = self.FILL_COLOR obj.data.materials.append(mat)
def create(self, context): if all(is_one_of_arc(item) for item in context.selected_objects): count_create_point = 2 elif all( is_one_of_bezier_curve(item) for item in context.selected_objects): count_create_point = 9 elif all(is_one_of_lines(item) for item in context.selected_objects): count_create_point = 1 elif ((is_one_of_lines(context.selected_objects[0]) and is_one_of_bezier_curve(context.selected_objects[1])) or (is_one_of_lines(context.selected_objects[1]) and is_one_of_bezier_curve(context.selected_objects[0]))): count_create_point = 3 elif ((is_one_of_lines(context.selected_objects[0]) and is_one_of_arc(context.selected_objects[1])) or (is_one_of_lines(context.selected_objects[1]) and is_one_of_arc(context.selected_objects[0]))): count_create_point = 2 elif ((is_one_of_arc(context.selected_objects[0]) and is_one_of_bezier_curve(context.selected_objects[1])) or (is_one_of_arc(context.selected_objects[1]) and is_one_of_bezier_curve(context.selected_objects[0]))): count_create_point = 6 parents = [ obj for obj in bpy.data.objects if obj.fp_id > 0 and ( obj.fp_id == context.selected_objects[0].fp_id or obj.fp_id == context.selected_objects[1].fp_id) ] dep_id = tuple([parents[0].fp_id] + [parents[1].fp_id] + [0]) count = 0 while count < count_create_point: bpy.ops.mesh.primitive_plane_add(radius=self.POINT_RADIUS) obj = context.object Counter.register(obj, self.FP_TYPE) obj.name = self.BASE_NAME + '.' + Counter.get_counter_suffix(obj) obj.fp_deps = dep_id obj.fp_number = count obj.lock_location = (True, True, True) obj.show_name = True obj.select = False mat = bpy.data.materials.new('ЗаливкаТочкиПересеченияФигур') mat.diffuse_color = self.FILL_COLOR obj.data.materials.append(mat) count += 1
def create(self, context): dep_id = tuple([d.fp_id for d in context.selected_objects] + [0]) bpy.ops.mesh.primitive_plane_add(radius=self.POINT_RADIUS) obj = context.object Counter.register(obj, self.FP_TYPE) obj.name = self.BASE_NAME + '.' + Counter.get_counter_suffix(obj) obj.fp_deps = dep_id obj.lock_location = (True, True, True) obj.show_name = True obj.select = False mat = bpy.data.materials.new('ЗаливкаТочкиПересеченияЛинииОси') mat.diffuse_color = self.FILL_COLOR obj.data.materials.append(mat) obj.location = self.DEFAULT_LOCATION
def create(self, context): dep_id = tuple([d.fp_id for d in context.selected_objects] + [0]) line1_points = [ obj for obj in bpy.data.objects if obj.fp_id > 0 and obj.fp_id in context.selected_objects[0].fp_deps ] line2_points = [ obj for obj in bpy.data.objects if obj.fp_id > 0 and obj.fp_id in context.selected_objects[1].fp_deps ] locations1 = [get_point_abs_location(point) for point in line1_points] locations2 = [get_point_abs_location(point) for point in line2_points] center = line_to_line({ "x": locations1[0][0], "y": locations1[0][1] }, { "x": locations1[1][0], "y": locations1[1][1] }, { "x": locations2[0][0], "y": locations2[0][1] }, { "x": locations2[1][0], "y": locations2[1][1] }) bpy.ops.mesh.primitive_plane_add(radius=self.POINT_RADIUS) obj = context.object obj.fp_deps = dep_id Counter.register(obj, self.FP_TYPE) obj.name = self.BASE_NAME + '.' + Counter.get_counter_suffix(obj) obj.location = (center["points"][0]["x"], center["points"][0]["y"], 0) obj.lock_location = (True, True, True) obj.show_name = True mat = bpy.data.materials.new('ЗаливкаТочки') mat.diffuse_color = self.FILL_COLOR obj.data.materials.append(mat) return obj
def create(self, context, source_points=None): if not source_points: source_points = context.selected_objects locations = tuple( get_point_abs_location(point) for point in source_points) center = ((locations[1][0] - locations[0][0]) / 2 + locations[0][0], (locations[1][1] - locations[0][1]) / 2 + locations[0][1], 0.0) vectors = [Vector(location) for location in locations] curvedata = bpy.data.curves.new(name='Curve', type='CURVE') curvedata.dimensions = self.CURVE_DIMS curvedata.bevel_depth = self.CURVE_BEVEL_DEPTH curvedata.fill_mode = self.CURVE_FILL_MODE line_mat = bpy.data.materials.new('ОбводкаЛинии') line_mat.diffuse_color = self.STROKE_COLOR curvedata.materials.append(line_mat) objectdata = bpy.data.objects.new(self.BASE_NAME, curvedata) Counter.register(objectdata, self.FP_TYPE) objectdata.name = self.BASE_NAME + '.' + Counter.get_counter_suffix( objectdata) objectdata.fp_deps = tuple([so.fp_id for so in source_points] + [0]) objectdata.location = center objectdata.lock_location = (True, True, True) objectdata.show_name = True bpy.context.scene.objects.link(objectdata) polyline = curvedata.splines.new("POLY") polyline.points.add(len(vectors) - 1) for num in range(len(vectors)): x, y, z = vectors[num] polyline.points[num].co = (x - center[0], y - center[1], 0, 0.001) objectdata.fp_count = self.COUNT return objectdata
def create(self, count, context): number = 1 parent = context.active_object parent = [ obj for obj in bpy.data.objects if obj.fp_id > 0 and obj.fp_id in parent.fp_deps ] dep_id = tuple([parent[1].fp_id] + [0, 0]) nameParent = parent[0].name nameSelect = parent[1].name while number <= expression_to_value(count): bpy.data.objects[nameSelect].select = True bpy.data.objects[nameParent].select = True bpy.ops.mesh.primitive_plane_add(radius=self.POINT_RADIUS) obj = context.object Counter.register(obj, self.FP_TYPE) obj.name = self.BASE_NAME + '.' + Counter.get_counter_suffix(obj) obj.parent = parent[0] obj.fp_deps = dep_id obj.fp_expression = count obj.fp_number = number number += 1 obj.lock_location = (True, True, True) obj.show_name = True obj.select = False mat = bpy.data.materials.new('ЗаливкаТочкиРазделениеЛинии') mat.diffuse_color = self.FILL_COLOR obj.data.materials.append(mat)
def create(self, context): parent = context.active_object dep_id = tuple([ d.fp_id for d in context.selected_objects if not d.fp_id == parent.fp_id ] + [0, 0]) dep = [ d for d in context.selected_objects if not d.fp_id == parent.fp_id ] distance = get_distance( get_point_abs_location(context.selected_objects[0]), get_point_abs_location(context.selected_objects[1])) bpy.ops.mesh.primitive_plane_add(radius=self.POINT_RADIUS) obj = context.object Counter.register(obj, self.FP_TYPE) obj.name = self.BASE_NAME + '.' + Counter.get_counter_suffix(obj) obj.parent = parent obj.fp_deps = dep_id obj.fp_expression = self.DEFAULT_EXPRESSION obj.lock_location = (True, True, True) obj.show_name = True # obj.select = False id_dart = obj.fp_id p_a_location = get_point_abs_location(obj.parent) d_a_location = get_point_abs_location([ d for d in bpy.data.objects if d.fp_id == obj.fp_deps[0] and d.fp_id > 0 ][0]) pd_dif = (p_a_location[0] - d_a_location[0], p_a_location[1] - d_a_location[1], 0.0) pd_hyp = sqrt(pd_dif[0]**2 + pd_dif[1]**2) op_hyp = expression_to_value(obj.fp_expression) proportion = op_hyp / pd_hyp if pd_hyp else 0 op_x = pd_dif[0] * proportion op_y = pd_dif[1] * proportion obj.location = (-op_x, -op_y, 0.0) print("parent 1 = ", obj.parent) obj.fp_angle = get_angle(get_point_abs_location(obj), get_point_abs_location(dep[0])) draw_line = Line() parent.select = True draw_line.create(context) mat = bpy.data.materials.new('ЗаливкаТочкиДляВытачки') mat.diffuse_color = self.FILL_COLOR obj.data.materials.append(mat) bpy.ops.mesh.primitive_plane_add(radius=self.POINT_RADIUS) obj = context.object Counter.register(obj, self.FP_TYPE) obj.name = self.BASE_NAME + '.' + Counter.get_counter_suffix(obj) obj.parent = dep[0] obj.fp_deps = tuple([parent.fp_id] + [0, 0]) obj.fp_expression = str(distance - expression_to_value(self.DEFAULT_EXPRESSION)) obj.lock_location = (True, True, True) obj.show_name = True obj.fp_dart = id_dart # obj.select = False p_a_location = get_point_abs_location(obj.parent) d_a_location = get_point_abs_location([ d for d in bpy.data.objects if d.fp_id == obj.fp_deps[0] and d.fp_id > 0 ][0]) pd_dif = (p_a_location[0] - d_a_location[0], p_a_location[1] - d_a_location[1], 0.0) pd_hyp = sqrt(pd_dif[0]**2 + pd_dif[1]**2) op_hyp = expression_to_value(obj.fp_expression) proportion = op_hyp / pd_hyp if pd_hyp else 0 op_x = pd_dif[0] * proportion op_y = pd_dif[1] * proportion obj.location = (-op_x, -op_y, 0.0) print("parent 2 = ", obj.parent) obj.fp_angle = get_angle(get_point_abs_location(obj), get_point_abs_location(parent)) draw_line = Line() dep[0].select = True draw_line.create(context) mat = bpy.data.materials.new('ЗаливкаТочкиДляВытачки') mat.diffuse_color = self.FILL_COLOR obj.data.materials.append(mat) for obj in bpy.data.objects: obj.select = False for line in bpy.data.objects: if line.fp_type == Line.FP_TYPE and ( (line.fp_deps[0] == parent.fp_id and line.fp_deps[1] == dep[0].fp_id) or (line.fp_deps[0] == dep[0].fp_id and line.fp_deps[1] == parent.fp_id)): line.select = True bpy.ops.object.delete() break