From bf3025487193dc892403095b3d6a81f9ab1a9697 Mon Sep 17 00:00:00 2001 From: Pullusb Date: Tue, 15 Nov 2022 18:36:21 +0100 Subject: [PATCH] imporve and expose follow curve offset 2.1.1 - added: follow curve show offset property in UI - added: follow curve show clickable warning if object has non-zero location to reset location - changed: created follow curve use `fixed offset` --- CHANGELOG.md | 6 ++++++ UI_tools.py | 24 ++++++++++++++++-------- __init__.py | 2 +- utils.py | 4 +++- 4 files changed, 26 insertions(+), 10 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 8b3dba8..2bba1b8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,11 @@ # Changelog +2.1.1 + +- added: follow curve show offset property in UI +- added: follow curve show clickable warning if object has non-zero location to reset location +- changed: created follow curve use `fixed offset` + 2.1.0 - added: 3 actions buttons: diff --git a/UI_tools.py b/UI_tools.py index c273c38..353a292 100644 --- a/UI_tools.py +++ b/UI_tools.py @@ -226,16 +226,24 @@ class GPTB_PT_anim_manager(Panel): row = col.row(align=True) # row.operator('object.create_follow_path_curve', text='Create Curve', icon='CURVE_BEZCURVE') - if context.object and context.object.type == 'CURVE' and context.mode in ('OBJECT', 'EDIT_CURVE'): - row.operator('object.object_from_curve', text='Back To Object', icon='LOOP_BACK') + if context.object: + if context.object.type == 'CURVE' and context.mode in ('OBJECT', 'EDIT_CURVE'): + row.operator('object.object_from_curve', text='Back To Object', icon='LOOP_BACK') - elif (follow_const := context.object.constraints.get('Follow Path')) and follow_const.target: - row.operator('object.edit_curve', text='Edit Curve', icon='OUTLINER_DATA_CURVE') - row.operator('object.remove_follow_path', text='', icon='X') - col.label(text=f'{context.object.name} -> {follow_const.target.name}', icon='CON_FOLLOWPATH') + elif (follow_const := context.object.constraints.get('Follow Path')) and follow_const.target: + row.operator('object.edit_curve', text='Edit Curve', icon='OUTLINER_DATA_CURVE') + row.operator('object.remove_follow_path', text='', icon='X') + col.label(text=f'{context.object.name} -> {follow_const.target.name}', icon='CON_FOLLOWPATH') + if follow_const.use_fixed_location: + col.prop(follow_const, 'offset_factor') + else: + col.prop(follow_const, 'offset') + if context.object.location.length != 0: # context.object.location[:] != (0,0,0): + col.operator('object.location_clear', text='Offseted Location! Reset', icon='ERROR') + # ? Check if object location is animated ? (can be intentional...) - else: - col.operator('object.create_follow_path_curve', text='Create Curve', icon='CURVE_BEZCURVE') + else: + col.operator('object.create_follow_path_curve', text='Create Follow Curve', icon='CURVE_BEZCURVE') ## This can go in an extra category... diff --git a/__init__.py b/__init__.py index a03e596..7766ed3 100755 --- a/__init__.py +++ b/__init__.py @@ -4,7 +4,7 @@ bl_info = { "name": "GP toolbox", "description": "Tool set for Grease Pencil in animation production", "author": "Samuel Bernou, Christophe Seux", -"version": (2, 1, 0), +"version": (2, 1, 1), "blender": (3, 0, 0), "location": "Sidebar (N menu) > Gpencil > Toolbox / Gpencil properties", "warning": "", diff --git a/utils.py b/utils.py index a89146c..31e65b2 100644 --- a/utils.py +++ b/utils.py @@ -1053,7 +1053,7 @@ def orentation_track_from_vector(input_vector) -> str: return orient -def create_follow_path_constraint(ob, curve, follow_curve=False): +def create_follow_path_constraint(ob, curve, follow_curve=False, use_fixed_location=True): '''return create constraint''' # # Clear bone follow path constraint exiting_fp_constraints = [c for c in ob.constraints if c.type == 'FOLLOW_PATH'] @@ -1070,6 +1070,8 @@ def create_follow_path_constraint(ob, curve, follow_curve=False): const.target = curve if follow_curve: const.use_curve_follow = True + if use_fixed_location: + const.use_fixed_location = True return const ## on_bones: