align object origins

convenience function to align origins
This commit is contained in:
jrkb 2025-05-18 13:43:50 +02:00
parent be5f060c98
commit 34eeb4af94

View file

@ -691,6 +691,10 @@ class ABC3D_PT_FontCreation(bpy.types.Panel):
layout.row().operator(
f"{__name__}.temporaryhelper", text="Debug Function Do Not Use"
)
box.label(text="origin points")
box.row().operator(f"{__name__}.align_origins_to_active_object", text="Align origins to Active Object")
# box.row().operator(f"{__name__}.align_origins_to_metrics", text="Align origins to Metrics (left)")
# box.row().operator(f"{__name__}.fix_objects_metrics_origins", text="Fix objects metrics origins")
class ABC3D_PT_TextPropertiesPanel(bpy.types.Panel):
@ -1012,6 +1016,72 @@ class ABC3D_OT_AlignMetrics(bpy.types.Operator):
butils.align_metrics_of_objects(objects)
return {"FINISHED"}
class ABC3D_OT_AlignOriginsToActiveObject(bpy.types.Operator):
"""Align origins of selected objects to origin of active object on one axis."""
bl_idname = f"{__name__}.align_origins_to_active_object"
bl_label = "Align origins to Active Object"
bl_options = {"REGISTER", "UNDO"}
enum_axis = (('0','X',''),('1','Y',''),('2','Z',''))
axis: bpy.props.EnumProperty(items = enum_axis, default='2')
def execute(self, context):
objects = bpy.context.selected_objects
butils.align_origins_to_active_object(objects, int(self.axis))
return {"FINISHED"}
# class ABC3D_OT_AlignOriginsToMetrics(bpy.types.Operator):
# """Align origins of selected objects to their metrics left border.
# Be aware that shifting the origin will also shift the pivot point around which an object rotates.
# If an object does not have metrics, it will be ignored."""
# bl_idname = f"{__name__}.align_origins_to_metrics"
# bl_label = "Align origins to metrics metrics"
# bl_options = {"REGISTER", "UNDO"}
# ignore_warning: bpy.props.BoolProperty(
# name="Do not warn in the future",
# description="Do not warn in the future",
# default=False,
# )
# def draw(self, context):
# layout = self.layout
# layout.row().label(text="Warning!")
# layout.row().label(text="This also shifts the pivot point around which the glyph rotates.")
# layout.row().label(text="This may not be what you want.")
# layout.row().label(text="Glyph advance derives from metrics boundaries, not origin points.")
# layout.row().label(text="If you are sure about what you're doing, please continue.")
# layout.row().prop(self, "ignore_warning")
# def invoke(self, context, event):
# if not self.ignore_warning:
# wm = context.window_manager
# return wm.invoke_props_dialog(self)
# return self.execute(context)
# def execute(self, context):
# objects = bpy.context.selected_objects
# butils.align_origins_to_metrics(objects)
# butils.fix_objects_metrics_origins(objects)
# return {"FINISHED"}
# class ABC3D_OT_FixObjectsMetricsOrigins(bpy.types.Operator):
# """Align metrics origins of selected objects to their metrics bounding box.
# If an object does not have metrics, it will be ignored."""
# bl_idname = f"{__name__}.fix_objects_metrics_origins"
# bl_label = "Fix metrics origin of all selected objects"
# bl_options = {"REGISTER", "UNDO"}
# def execute(self, context):
# objects = bpy.context.selected_objects
# butils.fix_objects_metrics_origins(objects)
# return {"FINISHED"}
class ABC3D_OT_TemporaryHelper(bpy.types.Operator):
"""Temporary Helper ABC3D\nThis could do anything.\nIt's just there to make random functions available for testing."""
@ -1617,6 +1687,9 @@ classes = (
ABC3D_OT_RemoveMetrics,
ABC3D_OT_AlignMetricsToActiveObject,
ABC3D_OT_AlignMetrics,
ABC3D_OT_AlignOriginsToActiveObject,
# ABC3D_OT_AlignOriginsToMetrics,
# ABC3D_OT_FixObjectsMetricsOrigins,
ABC3D_OT_TemporaryHelper,
ABC3D_OT_RemoveText,
ABC3D_OT_PlaceText,