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 modal(self, context, event): if (is_one_of_lines(context.active_object) and context.active_object not in self._moving_contour and get_line_length(self._moving_line) == get_line_length( context.active_object)): self._target_line = context.active_object self._move(context) return {'FINISHED'} else: return {'PASS_THROUGH'}
def poll(cls, context): global FP_ID, CURRENT_INDEX cond = is_one_of_lines(context.active_object) and len(get_contours(context.active_object)) # True если выделена линия if cond: if FP_ID != context.active_object.fp_id: FP_ID = context.active_object.fp_id # ID выделенного объекта CURRENT_INDEX = 0 else: FP_ID = 0 CURRENT_INDEX = 0 return cond
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 modal(self, context, event): global TARGET_MONITOR if (is_one_of_lines(context.active_object) and context.active_object.fp_id not in MODELING_BUFFER and get_line_length(self._moving_line) == get_line_length( context.active_object)): self._target_line = context.active_object self._move() TARGET_MONITOR = False RESULTSET = {'FINISHED'} else: RESULTSET = {'PASS_THROUGH'} for obj in [ obj for obj in bpy.data.objects if obj.fp_id in MODELING_BUFFER ]: obj.select = True return RESULTSET
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 poll(cls, context): return (MODELING_MONITOR and is_one_of_lines(context.active_object))
def poll(cls, context): return selection_is_contour() and is_one_of_lines( context.active_object)
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) ]