bump to v0.0.7: Add convert to empties operator and add icon to specials menu operator #6
57
__init__.py
57
__init__.py
@ -3,6 +3,8 @@
|
||||
# https://extensions.blender.org/add-ons/c3db/
|
||||
|
||||
import bpy
|
||||
from mathutils import Quaternion
|
||||
from mathutils import Vector
|
||||
|
||||
|
||||
class C3DB_PG_properties(bpy.types.PropertyGroup):
|
||||
@ -30,7 +32,8 @@ class C3DB_MT_menu_specials(bpy.types.Menu):
|
||||
layout.separator()
|
||||
layout.operator("c3db.delete_all", icon="TRASH")
|
||||
layout.separator()
|
||||
layout.operator("c3db.delete_all")
|
||||
# layout.operator("C3DB_OT_export_selected_to_empty", icon="OUTLINER")
|
||||
layout.operator("C3DB_OT_export_all_to_empties", icon="OUTLINER")
|
||||
|
||||
|
||||
class C3DB_UL_list(bpy.types.UIList):
|
||||
@ -216,6 +219,14 @@ class C3DB_OT_delete_all(bpy.types.Operator):
|
||||
bl_label = "Delete All 3D Cursors"
|
||||
bl_options = {"REGISTER", "UNDO"}
|
||||
|
||||
@classmethod
|
||||
def poll(cls, context):
|
||||
return bool(
|
||||
context.scene.C3DB_3Dcursors_collection
|
||||
) and context.scene.C3DB_3Dcursors_index < len(
|
||||
context.scene.C3DB_3Dcursors_collection
|
||||
)
|
||||
|
||||
def execute(self, context):
|
||||
context.scene.C3DB_3Dcursors_collection.clear()
|
||||
context.area.tag_redraw() # Refresh the UI
|
||||
@ -293,6 +304,47 @@ class C3DB_OT_move_down_list(bpy.types.Operator):
|
||||
return {"FINISHED"}
|
||||
|
||||
|
||||
# TODO Do the same for only the selected cursor and 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:
|
||||
You are not in Object Mode ..."""
|
||||
|
||||
bl_idname = "c3db.export_all_to_empties"
|
||||
bl_label = "Export All to Empties"
|
||||
bl_options = {"REGISTER", "UNDO"}
|
||||
|
||||
@classmethod
|
||||
def poll(cls, context):
|
||||
return (
|
||||
bool(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):
|
||||
for c3db_3d_cursor in context.scene.C3DB_3Dcursors_collection:
|
||||
if c3db_3d_cursor.rotation_mode == "QUATERNION":
|
||||
rotation = Quaternion(c3db_3d_cursor.rotation_quaternion)
|
||||
rotation_euler = rotation.to_euler()
|
||||
elif c3db_3d_cursor.rotation_mode == "AXIS_ANGLE":
|
||||
rotation = Quaternion(
|
||||
Vector(c3db_3d_cursor.rotation_axis_angle).yzw,
|
||||
c3db_3d_cursor.rotation_axis_angle[0],
|
||||
)
|
||||
rotation_euler = rotation.to_euler()
|
||||
else:
|
||||
rotation_euler = c3db_3d_cursor.rotation_euler
|
||||
|
||||
bpy.ops.object.empty_add(
|
||||
type="PLAIN_AXES",
|
||||
radius=1,
|
||||
location=c3db_3d_cursor.location,
|
||||
rotation=rotation_euler,
|
||||
)
|
||||
return {"FINISHED"}
|
||||
|
||||
|
||||
class C3DB_PT_panel(bpy.types.Panel):
|
||||
bl_label = "3D Cursors Briefcase"
|
||||
bl_idname = "C3DB_PT_panel"
|
||||
@ -346,8 +398,9 @@ classes = (
|
||||
C3DB_OT_remove_from_list,
|
||||
C3DB_OT_move_up_list,
|
||||
C3DB_OT_move_down_list,
|
||||
C3DB_OT_export_all_to_empties,
|
||||
C3DB_PT_panel,
|
||||
)
|
||||
) # TODO C3DB_OT_export_selected_to_empty,
|
||||
|
||||
c3db_keymaps = []
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user