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_countur(self, objects): lines = [ob for ob in objects if is_one_of_lines(ob)] # points = [ob for ob in objects if is_one_of_points(ob)] arcs = [ob for ob in objects if is_one_of_arc(ob)] curves = [ob for ob in objects if is_one_of_bezier_curve(ob)] objs = [ob for ob in objects if not is_one_of_points(ob)] for o in objects: self.find_ob_ends(o) ob = objs[0] for o in range(0, len(objs) - 1): self.coords_for_bezier(ob) self.USEDPOINTS.append(ob.fp_id) point1 = ob.end1 point2 = ob.end2 ob = self.find_line_for_point(ob, objects, ob.end2) if (o == len(objects) - 2): self.coords_for_bezier(ob) if (Vector(ob.end1) == Vector(point2)): point1 = Vector(ob.end1) point2 = Vector(ob.end2) if (is_one_of_arc(ob)): ob.order = 0 else: point1 = Vector(ob.end2) point2 = Vector(ob.end1) if (is_one_of_arc(ob)): ob.order = 1 ob.end1 = Vector(point1) ob.end2 = Vector(point2)
def selection_is_contour(): selection = bpy.context.selected_objects if (not all( is_one_of_lines(obj) or is_one_of_bezier_curve(obj) for obj in selection) or len(selection) < 2): return False else: return True
def poll(self, context): ''' Нужны две выделенных фигуры. ''' return (len(context.selected_objects) == 2 and ( (all(is_one_of_lines(item) for item in context.selected_objects)) or (all(is_one_of_arc(item) for item in context.selected_objects)) or (all( is_one_of_bezier_curve(item) for item in context.selected_objects)) or ((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]))) or ((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]))) or ((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])))))
def find_ob_ends(self, obj): if (is_one_of_arc(obj)): coordsmas = get_arc_ends_coords(obj) obj.end1 = Vector(coordsmas[0]) obj.end2 = Vector(coordsmas[1]) elif (is_one_of_lines(obj)): coords = get_line_ends(obj) x = coords[0] y = coords[1] obj.end1 = Vector(x) obj.end2 = Vector(y) elif (is_one_of_bezier_curve(obj)): coords = get_curve_ends(obj) x = coords[0] y = coords[1] obj.end1 = Vector(x) obj.end2 = Vector(y)
def coords_for_bezier(self, obj): if (is_one_of_arc(obj)): coords1 = obj.end1 coords2 = obj.end2 pointX = self.check_points(coords1, obj.fp_id) pointY = self.check_points(coords2, obj.fp_id) pointX.fp_angles = obj.fp_angles pointY.fp_angles = obj.fp_angles self.make_line_new_type(obj, pointX, pointY, "arc") elif (is_one_of_lines(obj)): x = obj.end1 y = obj.end2 nx = self.check_points(x, obj.fp_id) ny = self.check_points(y, obj.fp_id) self.make_line_new_type(obj, nx, ny, "line") elif (is_one_of_bezier_curve(obj)): x = obj.end1 y = obj.end2 nx = self.check_points(x, obj.fp_id) ny = self.check_points(y, obj.fp_id) self.make_line_new_type(obj, nx, ny, "curve") else: pass
def get_all_obj(): # возвращает все линии и кривые на сцене return [ item for item in bpy.data.objects if is_one_of_lines(item) or is_one_of_bezier_curve(item) ]
def poll(self, context): return (context.active_object and is_one_of_bezier_curve(context.active_object))