def update(self, obj, context): p_a_location = get_point_abs_location(obj.parent) collection_of_d_a_location = ([ d for d in bpy.data.objects if (d.fp_id == obj.fp_deps[0] or d.fp_id == obj.fp_deps[1]) and d.fp_id > 0 ]) d_a_location = [ get_point_abs_location(x) for x in collection_of_d_a_location ] d1d2_dif = (d_a_location[0][0] - d_a_location[1][0], d_a_location[0][1] - d_a_location[1][1], 0.0) d1d2_hyp = sqrt(d1d2_dif[0]**2 + d1d2_dif[1]**2) d1d3_hyp = d1d2_hyp / 2 dirX = d1d2_dif[0] / d1d2_hyp dirY = d1d2_dif[1] / d1d2_hyp dirX *= d1d3_hyp dirY *= d1d3_hyp op_x = dirX + d_a_location[1][0] op_y = dirY + d_a_location[1][1] pd3_dif = (op_x - p_a_location[0], op_y - p_a_location[1], 0.0) pd3_hyp = sqrt(pd3_dif[0]**2 + pd3_dif[1]**2) dirX = pd3_dif[0] / pd3_hyp dirY = pd3_dif[1] / pd3_hyp op_hyp = expression_to_value(obj.fp_expression) dirX *= op_hyp dirY *= op_hyp op_x = dirX op_y = dirY obj.location = (op_x, op_y, 0.0)
def update(self, obj, context): self._radius = expression_to_value(obj.fp_expression) if self._radius == 0: return angle_diff_deg = -sub(*obj.fp_angles) if angle_diff_deg < 0: obj.fp_angles = (obj.fp_angles[1], obj.fp_angles[1]) return if angle_diff_deg > 360: obj.fp_angles = (obj.fp_angles[0], obj.fp_angles[0] + 360.0) return counter = 0 part = 360.0 / self._splines rng = int(angle_diff_deg // part) for i in range(rng): if i < self._splines: counter += 1 self._draw_spline(obj.data.splines[i], (obj.fp_angles[0] + i * part, obj.fp_angles[0] + counter * part)) if counter < self._splines: self._draw_spline( obj.data.splines[counter], (obj.fp_angles[0] + counter * part, obj.fp_angles[1])) counter += 1 for i in range(self._splines - counter): self._draw_collapsed_spline(obj.data.splines[counter + i])
def update(self, obj, context): expression = expression_to_value(obj.fp_expression) alfa = (180 * expression) / (pi * expression_to_value( obj.parent.fp_expression)) + obj.parent.fp_angles[0] b = (180 - alfa) / 2 rad = 57.2958 k1 = tan(alfa / rad) k2 = tan((180 - b) / rad) location_o = get_point_abs_location(obj.parent.parent) b1 = -k1 * location_o[0] + location_o[1] b2 = -k2 * (location_o[0] + expression_to_value( obj.parent.fp_expression)) + location_o[1] op_x = (b2 - b1) / (k1 - k2) op_y = k1 * op_x + b1 op_x -= location_o[0] op_y -= location_o[1] obj.location = (op_x, op_y, 0.0)
def update(self, obj, context): 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) a_hyp = expression_to_value(obj.fp_expression) if fabs(p_a_location[0] - d_a_location[0]) < 0.0000001: if pd_dif[1] > 0: op_x = -a_hyp else: op_x = a_hyp op_y = 0 elif fabs(p_a_location[1] - d_a_location[1]) < 0.0000001: if pd_dif[0] > 0: op_y = a_hyp else: op_y = -a_hyp op_x = 0 else: k = (p_a_location[1] - d_a_location[1]) / ( p_a_location[0] - d_a_location[0]) if (p_a_location[0] - d_a_location[0]) else 0 _k = -1 / k b = -_k * p_a_location[0] + p_a_location[1] if k == 0: op_x = 0 if pd_dif[0] > 0: op_y = a_hyp else: op_y = -a_hyp else: if k < 0: if pd_dif[0] < 0: op_x = -100 else: op_x = 100 else: if pd_dif[0] < 0: op_x = 100 else: op_x = -100 op_y = _k * op_x + b d1d2_dif = (op_x - p_a_location[0], op_y - p_a_location[1], 0.0) d1d2_hyp = sqrt(d1d2_dif[0]**2 + d1d2_dif[1]**2) proportion = a_hyp / d1d2_hyp op_x = d1d2_dif[0] * proportion op_y = d1d2_dif[1] * proportion obj.location = (op_x, op_y, 0.0)
def execute(self, context): obj = context.active_object d_point = Point() d_line = Line() points = d_point.get_all() children = [p for p in points if p.parent == obj] for nx in children: rm = obj rm_a = rm.fp_angle rm_l = expression_to_value(rm.fp_expression) nx_a = nx.fp_angle nx_l = expression_to_value(nx.fp_expression) _a = 360 - (180 - rm_a + nx_a) new_l = sqrt(rm_l**2 + nx_l**2 - 2 * rm_l * nx_l * cos(radians(_a))) dx = nx.location[0] + rm.location[0] dy = nx.location[1] + rm.location[1] new_a = degrees(asin(dy / new_l)) new_a = new_a if dx > 0 else 180 - new_a if obj.parent: nx.parent = obj.parent nx.fp_expression = str(new_l) nx.fp_angle = new_a lines = tuple(l for l in bpy.data.objects if l.fp_type == Line.FP_TYPE and obj.fp_id in l.fp_deps) for ln in lines: bpy.context.scene.objects.unlink(ln) bpy.data.objects.remove(ln) bpy.ops.object.delete() return {'FINISHED'}
def update(self, obj, context): 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)
def update(self, obj): collection_of_d_a_location = ([ d for d in bpy.data.objects if (d.fp_id == obj.fp_deps[0] or d.fp_id == obj.fp_deps[1]) and d.fp_id > 0 ]) points_parent = [ get_point_abs_location(x) for x in collection_of_d_a_location ] handle_right = ( obj.parent.data.splines[0].bezier_points[0].handle_right[0] - obj.parent.data.splines[0].bezier_points[0].co[0] + points_parent[0][0], obj.parent.data.splines[0].bezier_points[0].handle_right[1] - obj.parent.data.splines[0].bezier_points[0].co[1] + points_parent[0][1], 0.0) handle_left = ( obj.parent.data.splines[0].bezier_points[1].handle_left[0] - obj.parent.data.splines[0].bezier_points[1].co[0] + points_parent[1][0], obj.parent.data.splines[0].bezier_points[1].handle_left[1] - obj.parent.data.splines[0].bezier_points[1].co[1] + points_parent[1][1], 0.0) bezier_t = 0.0 bezier_l = 0.0 step_t = 0.001 x = 0.0 y = 0.0 previous_x = points_parent[0][0] previous_y = points_parent[0][1] while bezier_t <= 1.0: x = ((1 - bezier_t)**3) * points_parent[0][0] + 3 * bezier_t * ( (1 - bezier_t)**2) * handle_right[0] + 3 * (bezier_t**2) * ( 1 - bezier_t) * handle_left[0] + (bezier_t** 3) * points_parent[1][0] y = ((1 - bezier_t)**3) * points_parent[0][1] + 3 * bezier_t * ( (1 - bezier_t)**2) * handle_right[1] + 3 * (bezier_t**2) * ( 1 - bezier_t) * handle_left[1] + (bezier_t** 3) * points_parent[1][1] bezier_l += sqrt((x - previous_x)**2 + (y - previous_y)**2) previous_x = x previous_y = y if bezier_l >= expression_to_value(obj.fp_expression): bezier_t = 2.0 bezier_t += step_t x += obj.parent.data.splines[0].bezier_points[0].co[0] - points_parent[ 0][0] y += obj.parent.data.splines[0].bezier_points[0].co[1] - points_parent[ 0][1] obj.location = (x, y, 0.0)
def update(self, obj, context): points = self.get_all() obj.location = points[-1].location if len(points) > 1 else (0.0, 0.0, 0.0) line = expression_to_value(obj.fp_expression) radians = deg_to_radians(obj.fp_angle) prevLocation = (0.0, 0.0, 0.0) line_x = prevLocation[0] + (cos(radians) * line) line_y = prevLocation[1] + (sin(radians) * line) obj.location = (line_x, line_y, 0.0)
def update(self, obj, context): parent_location = get_point_abs_location(obj.parent) print("parent ", obj.parent) collection_of_d_a_location = ([ d for d in bpy.data.objects if (d.fp_id == obj.fp_deps[0] or d.fp_id == obj.fp_deps[1]) and d.fp_id > 0 ]) active_location = [get_point_abs_location(x) for x in collection_of_d_a_location] radius = expression_to_value(obj.parent.fp_expression) a1_x = active_location[0][0] a1_y = active_location[0][1] a2_x = active_location[1][0] a2_y = active_location[1][1] c_x = parent_location[0] c_y = parent_location[1] a_point = (a2_x - a1_x) * (a2_x - a1_x) + (a2_y - a1_y) * (a2_y - a1_y) b_point = 2 * ((a2_x - a1_x) * (a1_x - c_x) + (a2_y - a1_y) * (a1_y - c_y)) cc_point = c_x * c_x + c_y * c_y + a1_x * a1_x + a1_y * a1_y - 2 * (c_x * a1_x + c_y * a1_y) - radius * radius deter = b_point * b_point - 4 * a_point * cc_point if deter < 0: obj.location = (-10000.0, -10000.0, 0.0) elif deter == 0: u1 = (-b_point) / (2 * a_point) if (0 <= u1) and (u1 <= 1): obj.location = (((a1_x + u1 * (a2_x - a1_x)) - c_x), ((a1_y + u1 * (a2_y - a1_y)) - c_y), 0.0) else: e = sqrt(deter) u1 = (-b_point + e) / (2 * a_point) u2 = (-b_point - e) / (2 * a_point) if (u1 < 0 or u1 > 1) and (u2 < 0 or u2 > 1): if (u1 < 0 and u2 < 0) or (u1 > 1 and u2 > 1): obj.location = (-10000.0, -10000.0, 0.0) else: obj.location = (-10000.0, -10000.0, 0.0) else: if (0 <= u1) and (u1 <= 1): obj.location = (((a1_x + u1 * (a2_x - a1_x)) - c_x), ((a1_y + u1 * (a2_y - a1_y)) - c_y), 0.0) if (0 <= u2) and (u2 <= 1): obj.location = (((a1_x + u2 * (a2_x - a1_x)) - c_x), ((a1_y + u2 * (a2_y - a1_y)) - c_y), 0.0)
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
def draw(self, context): layout = self.layout if is_modeling(): self.bl_label = 'Моделирование' row = layout.row() row.operator('fp.copying_stop', text='Готово') return self.bl_label = context.active_object.name + ' (' + context.active_object.fp_type + ')' row = layout.row() if context.active_object.fp_type == Point.FP_TYPE: row.prop(context.active_object, "name", text="Название") row = layout.row() row.prop(context.active_object, "fp_expression") row = layout.row() row.label(text="Значение:") row.alignment = 'LEFT' row.label(text=str( expression_to_value(context.active_object.fp_expression))) row = layout.row() row.prop(context.active_object, "fp_angle") # row = layout.row() # row.alignment = 'EXPAND' # props = row.operator('fp.draw_wire_between_points', text='Тестовая направляющая') # props.color3f = (0.8, 0.8, 0.2) # props.alpha = 0.75 # props.line_width = 3 # props.point_radius = 5 # props.poly = 4 # props.angle_ammend = pi/4 elif context.active_object.fp_type == PointOnLine.FP_TYPE: row.prop(context.active_object, "name", text="Название") row = layout.row() row.prop(context.active_object, "fp_expression") elif context.active_object.fp_type == PointForDart.FP_TYPE: row.prop(context.active_object, "name", text="Название") row = layout.row() row.prop(context.active_object, "fp_expression") row = layout.row() row.prop(context.active_object, "fp_angle") elif context.active_object.fp_type == PointOnPerpendicular.FP_TYPE: row.prop(context.active_object, "name", text="Название") row = layout.row() row.prop(context.active_object, "fp_expression") elif context.active_object.fp_type == PointOnBisector.FP_TYPE: row.prop(context.active_object, "name", text="Название") row = layout.row() row.prop(context.active_object, "fp_expression") elif context.active_object.fp_type == LineContinuation.FP_TYPE: row.prop(context.active_object, "name", text="Название") row = layout.row() row.prop(context.active_object, "fp_expression") elif context.active_object.fp_type == PointXY.FP_TYPE: row.prop(context.active_object, "name", text="Название") elif context.active_object.fp_type == PointFiguresIntersection.FP_TYPE: row.prop(context.active_object, "name", text="Название") elif context.active_object.fp_type == PerpendicularPointOnLine.FP_TYPE: row.prop(context.active_object, "name", text="Название") elif context.active_object.fp_type == ParallelLines.FP_TYPE: row.prop(context.active_object, "name", text="Название") elif context.active_object.fp_type == ReflectionHorizontalLine.FP_TYPE: row.prop(context.active_object, "name", text="Название") elif context.active_object.fp_type == ReflectionVerticalLine.FP_TYPE: row.prop(context.active_object, "name", text="Название") elif context.active_object.fp_type == DividingLine.FP_TYPE: row.prop(context.active_object, "name", text="Название") elif context.active_object.fp_type == IntersectionBeziersCurveAndAxis.FP_TYPE: row.prop(context.active_object, "name", text="Название") row = layout.row() row.prop(context.active_object, "fp_angle") elif context.active_object.fp_type == SpecialPointOnShoulder.FP_TYPE: row.prop(context.active_object, "name", text="Название") row = layout.row() row.prop(context.active_object, "fp_expression") elif context.active_object.fp_type == Arc.FP_TYPE: row.prop(context.active_object, "name", text="Название") row = layout.row() row.prop(context.active_object, "fp_expression") row = layout.row() row.prop(context.active_object, "fp_angles") elif context.active_object.fp_type == Circle.FP_TYPE: row.prop(context.active_object, "name", text="Название") row = layout.row() row.prop(context.active_object, "fp_expression") elif context.active_object.fp_type == LineIntersectionAndCircle.FP_TYPE: row.prop(context.active_object, "name", text="Название") row = layout.row() row.prop(context.active_object, "fp_expression") elif context.active_object.fp_type == ArcSeparation.FP_TYPE: row.prop(context.active_object, "name", text="Название") row = layout.row() row.prop(context.active_object, "fp_expression") elif context.active_object.fp_type == SeparationBeziersCurve.FP_TYPE: row.prop(context.active_object, "name", text="Название") row = layout.row() row.prop(context.active_object, "fp_expression") elif context.active_object.fp_type == SeparationComplexCurve.FP_TYPE: row.prop(context.active_object, "name", text="Название") row = layout.row() row.prop(context.active_object, "fp_expression") elif context.active_object.fp_type == ToolDetail.FP_TYPE: row.prop(context.active_object, "name", text="Название") elif context.active_object.fp_type == LineForDart.FP_TYPE: row.prop(context.active_object, "name", text="Название") row = layout.row() row.prop(context.active_object, "fp_count") row = layout.row() row.label(text="Длина:") row.alignment = "LEFT" row.label(text=str(get_line_length(context.active_object))) row = layout.row() row.label(text="Количество контуров:") row.alignment = "LEFT" contours = get_contours(context.active_object) row.label(text=str(len(contours))) row = layout.row() _props = row.operator("fp.contour_highlight", text="Выбрать контур ({0}/{1})".format( contour_highlight_index() + 1, len(contours))) row = layout.row() row.operator("fp.change_type_line", text="Сменить тип линии") elif context.active_object.fp_type == Line.FP_TYPE: row.prop(context.active_object, "name", text="Название") row = layout.row() row.prop(context.active_object, "fp_count") row = layout.row() row.label(text="Длина:") row.alignment = "LEFT" row.label(text=str(get_line_length(context.active_object))) row = layout.row() row.label(text="Количество контуров:") row.alignment = "LEFT" contours = get_contours(context.active_object) row.label(text=str(len(contours))) row = layout.row() _props = row.operator("fp.contour_highlight", text="Выбрать контур ({0}/{1})".format( contour_highlight_index() + 1, len(contours))) row = layout.row() row.operator("fp.change_type_line", text="Сменить тип линии")
def draw_callback(self, context): global TARGET_LOCATION global ANGLE mouse_coords_3 = mouse.get_coords_location_3d() first_object = context.active_object second_object = [ oth for oth in context.selected_objects if oth.fp_id > 0 and oth.fp_id != context.active_object.fp_id ] if ((not mouse_coords_3) or (not mouse_coords_3[2] == 0.0)): return if (mouse.is_window_event() or True): if first_object.fp_type == Arc.FP_TYPE: angles = first_object.fp_angles point_center_arc = get_point_abs_location(first_object.parent) radius_arc = expression_to_value(first_object.fp_expression) locations = get_point_abs_location(second_object[0]) else: angles = second_object[0].fp_angles point_center_arc = get_point_abs_location( second_object[0].parent) radius_arc = expression_to_value( second_object[0].fp_expression) locations = get_point_abs_location(first_object) coef_k = (mouse_coords_3[1] - locations[1]) / (mouse_coords_3[0] - locations[0]) if locations[0] < mouse_coords_3[0]: ANGLE = 180 + degrees(atan(coef_k)) else: ANGLE = degrees(atan(coef_k)) line_length = sqrt((locations[0] - mouse_coords_3[0])**2 + (locations[1] - mouse_coords_3[1])**2) proportion = 10000 / line_length def_loc_point = [ locations[i] - mouse_coords_3[i] for i in range(3) ] def_loc_mouse = [ mouse_coords_3[i] - locations[i] for i in range(3) ] location = [[0, 0], [0, 0]] location[0][0] = def_loc_point[0] * proportion + mouse_coords_3[0] location[0][1] = def_loc_point[1] * proportion + mouse_coords_3[1] location[1][0] = def_loc_mouse[0] * proportion + mouse_coords_3[0] location[1][1] = def_loc_mouse[1] * proportion + mouse_coords_3[1] self.draw_line(context, ((location[0][0], location[0][1], 0.0), (location[1][0], location[1][1], 0.0))) coords_points = line_to_arc({ "x": locations[0], "y": locations[1] }, { "x": mouse_coords_3[0], "y": mouse_coords_3[1] }, point_center_arc, angles[0], angles[1], radius_arc) for coords_point in coords_points["points"]: vector_coords_point = (coords_point["x"], coords_point["y"], 0.0) if vector_coords_point[0] != -10000: self.draw_point(context, (vector_coords_point, )) TARGET_LOCATION = vector_coords_point
def update(self, obj): collection_of_d_a_location = ([ d for d in bpy.data.objects for i in range(30) if (d.fp_id == obj.fp_deps30[i]) and d.fp_id > 0 ]) points_parent = [ get_point_abs_location(x) for x in collection_of_d_a_location ] for i in range(len(collection_of_d_a_location) - 1): bezier_t = 0.0 bezier_l = 0.0 step_t = 0.001 handle_right = ( obj.parent.data.splines[0].bezier_points[i].handle_right[0] - obj.parent.data.splines[0].bezier_points[0].co[0] + points_parent[0][0], obj.parent.data.splines[0].bezier_points[i].handle_right[1] - obj.parent.data.splines[0].bezier_points[0].co[1] + points_parent[0][1], 0.0) handle_left = ( obj.parent.data.splines[0].bezier_points[i + 1].handle_left[0] - obj.parent.data.splines[0].bezier_points[1].co[0] + points_parent[1][0], obj.parent.data.splines[0].bezier_points[i + 1].handle_left[1] - obj.parent.data.splines[0].bezier_points[1].co[1] + points_parent[1][1], 0.0) previous_x = points_parent[i][0] previous_y = points_parent[i][1] while bezier_t <= 1.0: x = ( (1 - bezier_t)**3) * points_parent[i][0] + 3 * bezier_t * ( (1 - bezier_t)**2) * handle_right[0] + 3 * ( bezier_t**2) * (1 - bezier_t) * handle_left[0] + ( bezier_t**3) * points_parent[i + 1][0] y = ( (1 - bezier_t)**3) * points_parent[i][1] + 3 * bezier_t * ( (1 - bezier_t)**2) * handle_right[1] + 3 * ( bezier_t**2) * (1 - bezier_t) * handle_left[1] + ( bezier_t**3) * points_parent[i + 1][1] bezier_l += sqrt((x - previous_x)**2 + (y - previous_y)**2) previous_x = x previous_y = y bezier_t += step_t obj.fp_line_length[i] = bezier_l sum_length = 0.0 for i in range(len(collection_of_d_a_location) - 1): bezier_l = obj.fp_line_length[i] sum_length += bezier_l if expression_to_value(obj.fp_expression) < sum_length: if i == 0: bezier_l = 0.0 else: bezier_l = sum_length - obj.fp_line_length[i] bezier_t = 0.0 handle_right = ( obj.parent.data.splines[0].bezier_points[i].handle_right[0] - obj.parent.data.splines[0].bezier_points[0].co[0] + points_parent[0][0], obj.parent.data.splines[0].bezier_points[i].handle_right[1] - obj.parent.data.splines[0].bezier_points[0].co[1] + points_parent[0][1], 0.0) handle_left = ( obj.parent.data.splines[0].bezier_points[i + 1].handle_left[0] - obj.parent.data.splines[0].bezier_points[1].co[0] + points_parent[1][0], obj.parent.data.splines[0].bezier_points[i + 1].handle_left[1] - obj.parent.data.splines[0].bezier_points[1].co[1] + points_parent[1][1], 0.0) previous_x = points_parent[i][0] previous_y = points_parent[i][1] while bezier_t <= 1.0: x = ( (1 - bezier_t)**3 ) * points_parent[i][0] + 3 * bezier_t * ( (1 - bezier_t)**2) * handle_right[0] + 3 * ( bezier_t**2) * (1 - bezier_t) * handle_left[0] + ( bezier_t**3) * points_parent[i + 1][0] y = ( (1 - bezier_t)**3 ) * points_parent[i][1] + 3 * bezier_t * ( (1 - bezier_t)**2) * handle_right[1] + 3 * ( bezier_t**2) * (1 - bezier_t) * handle_left[1] + ( bezier_t**3) * points_parent[i + 1][1] bezier_l += sqrt((x - previous_x)**2 + (y - previous_y)**2) previous_x = x previous_y = y if bezier_l >= expression_to_value(obj.fp_expression): bezier_t = 2.0 bezier_t += step_t loc = get_point_abs_location(obj.parent) x -= loc[0] y -= loc[1] obj.location = (x, y, 0.0) break elif expression_to_value( obj.fp_expression ) > sum_length and i == len(collection_of_d_a_location) - 2: obj.fp_expression = str(sum_length) loc = get_point_abs_location(obj.parent) x = points_parent[len(collection_of_d_a_location) - 1][0] - loc[0] y = points_parent[len(collection_of_d_a_location) - 1][1] - loc[1] obj.location = (x, y, 0.0)