From 88f5579d40e31407e997bca36a6a9945603a1313 Mon Sep 17 00:00:00 2001 From: themancalledjakob Date: Sun, 18 May 2025 18:47:00 +0200 Subject: [PATCH] loop in and out --- __init__.py | 14 ++++++++++++++ butils.py | 14 ++++++++++++-- 2 files changed, 26 insertions(+), 2 deletions(-) diff --git a/__init__.py b/__init__.py index 4b8a7ab..ef361dc 100644 --- a/__init__.py +++ b/__init__.py @@ -242,6 +242,18 @@ class ABC3D_text_properties(bpy.types.PropertyGroup): name="Ignore Curve Orientation", default=False, ) + loop_in: bpy.props.BoolProperty( + update=update_callback, + name="Loop In", + description="Loop letter on curve if negative offset would place it in front of it.", + default=False, + ) + loop_out: bpy.props.BoolProperty( + update=update_callback, + name="Loop Out", + description="Loop letter on curve if a large offset would place it behind it.", + default=False, + ) distribution_type: bpy.props.StringProperty() glyphs: bpy.props.CollectionProperty(type=ABC3D_glyph_properties) @@ -809,6 +821,8 @@ class ABC3D_PT_TextPropertiesPanel(bpy.types.Panel): layout.row().prop(props, "offset") layout.row().prop(props, "compensate_curvature") layout.row().prop(props, "ignore_orientation") + layout.row().prop(props, "loop_in") + layout.row().prop(props, "loop_out") layout.column().prop(props, "translation") layout.column().prop(props, "orientation") diff --git a/butils.py b/butils.py index fbb48b0..eec7106 100644 --- a/butils.py +++ b/butils.py @@ -1014,11 +1014,21 @@ def set_text_on_curve(text_properties, reset_timeout_s=0.1, reset_depsgraph_n=4) glyph_pre_advance, glyph_post_advance = get_glyph_prepost_advances(glyph) advance += glyph_pre_advance * scalor + # check if we want to loop + applied_advance = advance + if text_properties.loop_in: + if applied_advance < 0: + applied_advance %= curve_length + + if text_properties.loop_out: + if applied_advance > curve_length: + applied_advance %= curve_length + if distribution_type == "FOLLOW_PATH": outer_node.constraints.new(type="FOLLOW_PATH") outer_node.constraints["Follow Path"].target = mom outer_node.constraints["Follow Path"].use_fixed_location = True - outer_node.constraints["Follow Path"].offset_factor = advance / curve_length + outer_node.constraints["Follow Path"].offset_factor = applied_advance / curve_length outer_node.constraints["Follow Path"].use_curve_follow = True outer_node.constraints["Follow Path"].forward_axis = "FORWARD_X" outer_node.constraints["Follow Path"].up_axis = "UP_Y" @@ -1034,7 +1044,7 @@ def set_text_on_curve(text_properties, reset_timeout_s=0.1, reset_depsgraph_n=4) previous_inner_node_rotation_mode = inner_node.rotation_mode # get info from bezier - location, tangent, spline_index = calc_point_on_bezier_curve(mom, advance, True, True) + location, tangent, spline_index = calc_point_on_bezier_curve(mom, applied_advance, True, True) # check if we are on a new line if spline_index != previous_spline_index: