bump to v0.0.7: Add convert to empties operator and add icon to specials menu operator #6

Merged
dupoxy merged 7 commits from v0.0.7 into main 2024-09-26 21:06:19 +02:00
Showing only changes of commit d49a44cefa - Show all commits

View File

@ -32,8 +32,8 @@ class C3DB_MT_menu_specials(bpy.types.Menu):
layout.separator()
layout.operator("c3db.delete_all", icon="TRASH")
layout.separator()
layout.operator("C3DB_OT_export_selected_to_empty", icon="OUTLINER")
layout.operator("C3DB_OT_export_all_to_empties")
layout.operator("c3db.convert_selected_to_empty", icon="OUTLINER")
layout.operator("c3db.convert_all_to_empties")
class C3DB_UL_list(bpy.types.UIList):
@ -305,12 +305,12 @@ class C3DB_OT_move_down_list(bpy.types.Operator):
# TODO see how to sync the names too.
class C3DB_OT_export_all_to_empties(bpy.types.Operator):
"""Export all 3D Cursors to empty objects. This operator is inactive if:
class C3DB_OT_convert_all_to_empties(bpy.types.Operator):
"""Convert all 3D Cursors to empty objects. This operator is inactive if:
You are not in Object Mode ..."""
bl_idname = "c3db.export_all_to_empties"
bl_label = "Export All to Empties"
bl_idname = "c3db.convert_all_to_empties"
bl_label = "Convert All 3D Cursors to Empties"
bl_options = {"REGISTER", "UNDO"}
@classmethod
@ -344,31 +344,43 @@ class C3DB_OT_export_all_to_empties(bpy.types.Operator):
)
return {"FINISHED"}
# TODO see how to sync the names too.
class C3DB_OT_export_selected_to_empty(bpy.types.Operator):
"""Export selected 3D Cursor to an empty object"""
bl_idname = "c3db.export_selected_to_empty"
bl_label = "Export Selected to Empty"
class C3DB_OT_convert_selected_to_empty(bpy.types.Operator):
"""Convert selected 3D Cursor to an empty object. This operator is inactive if:
You are not in Object Mode ..."""
bl_idname = "c3db.convert_selected_to_empty"
bl_label = "Convert Selected 3D Cursor to Empty"
bl_options = {"REGISTER", "UNDO"}
@classmethod
def poll(cls, context):
return (context.scene.C3DB_3Dcursors_collection and
context.scene.C3DB_3Dcursors_index < len(context.scene.C3DB_3Dcursors_collection) and
context.mode == "OBJECT")
return (
context.scene.C3DB_3Dcursors_collection
and context.scene.C3DB_3Dcursors_index
< len(context.scene.C3DB_3Dcursors_collection)
and context.mode == "OBJECT"
)
def execute(self, context):
item = context.scene.C3DB_3Dcursors_collection[context.scene.C3DB_3Dcursors_index]
item = context.scene.C3DB_3Dcursors_collection[
context.scene.C3DB_3Dcursors_index
]
if item.rotation_mode == "QUATERNION":
rotation = Quaternion(item.rotation_quaternion)
rotation_euler = rotation.to_euler()
elif item.rotation_mode == "AXIS_ANGLE":
rotation = Quaternion(Vector(item.rotation_axis_angle).yzw, item.rotation_axis_angle[0])
rotation = Quaternion(
Vector(item.rotation_axis_angle).yzw, item.rotation_axis_angle[0]
)
rotation_euler = rotation.to_euler()
else:
rotation_euler = item.rotation_euler
bpy.ops.object.empty_add(type="PLAIN_AXES", radius=1, location=item.location, rotation=rotation_euler)
bpy.ops.object.empty_add(
type="PLAIN_AXES", radius=1, location=item.location, rotation=rotation_euler
)
return {"FINISHED"}
@ -425,8 +437,8 @@ classes = (
C3DB_OT_remove_from_list,
C3DB_OT_move_up_list,
C3DB_OT_move_down_list,
C3DB_OT_export_all_to_empties,
C3DB_OT_export_selected_to_empty,
C3DB_OT_convert_all_to_empties,
C3DB_OT_convert_selected_to_empty,
C3DB_PT_panel,
)