From 2973ffbb49251d7cfb22af6033c91f74f0ca03b6 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Fri, 5 Feb 2010 14:29:05 +0000 Subject: add menus for vertex group and shape key panels, functionality wasnt communicated well with icons and getting cluttered. also made 'transfer shape' script copy into the active object to match 'join as shape', which was quite confusing before. --- release/scripts/op/object.py | 26 +++++++++++++------ release/scripts/ui/properties_data_mesh.py | 40 ++++++++++++++++++++++-------- release/scripts/ui/properties_material.py | 2 +- release/scripts/ui/space_view3d.py | 1 - 4 files changed, 50 insertions(+), 19 deletions(-) (limited to 'release') diff --git a/release/scripts/op/object.py b/release/scripts/op/object.py index d02285b9c91..6fb15f1504c 100644 --- a/release/scripts/op/object.py +++ b/release/scripts/op/object.py @@ -140,7 +140,7 @@ class SubdivisionSet(bpy.types.Operator): class ShapeTransfer(bpy.types.Operator): - '''Copy the active objects current shape to other selected objects with the same number of verts''' + '''Copy another selected objects active shape to this one by applying the relative offsets.''' bl_idname = "object.shape_key_transfer" bl_label = "Transfer Shape Key" @@ -199,8 +199,10 @@ class ShapeTransfer(bpy.types.Operator): continue target_normals = me_nos(me_other.verts) - # target_coords = me_cos(me_other.verts) - target_coords = me_cos(me_other.shape_keys.keys[0].data) + if me_other.shape_keys: + target_coords = me_cos(me_other.shape_keys.keys[0].data) + else: + target_coords = me_cos(me_other.verts) ob_add_shape(ob_other, orig_key_name) @@ -306,12 +308,22 @@ class ShapeTransfer(bpy.types.Operator): def execute(self, context): C = bpy.context ob_act = C.active_object - if ob_act.active_shape_key is None: - self.report({'ERROR'}, "Active object has no shape key") - return {'CANCELLED'} objects = [ob for ob in C.selected_editable_objects if ob != ob_act] - return self._main(ob_act, objects, self.properties.mode, self.properties.use_clamp) + if 1: # swap from/to, means we cant copy to many at once. + if len(objects) != 1: + self.report({'ERROR'}, "Expected one other selected mesh object to copy from") + return {'CANCELLED'} + ob_act, objects = objects[0], [ob_act] + + if ob_act.type != 'MESH': + self.report({'ERROR'}, "Other object is not a mesh.") + return {'CANCELLED'} + + if ob_act.active_shape_key is None: + self.report({'ERROR'}, "Other object has no shape key") + return {'CANCELLED'} + return self._main(ob_act, objects, self.properties.mode, self.properties.use_clamp) class JoinUVs(bpy.types.Operator): '''Copy UV Layout to objects with matching geometry''' diff --git a/release/scripts/ui/properties_data_mesh.py b/release/scripts/ui/properties_data_mesh.py index 9128a742adb..63daf3fc701 100644 --- a/release/scripts/ui/properties_data_mesh.py +++ b/release/scripts/ui/properties_data_mesh.py @@ -23,6 +23,29 @@ from rna_prop_ui import PropertyPanel narrowui = 180 +class MESH_MT_vertex_group_specials(bpy.types.Menu): + bl_label = "Vertex Group Specials" + + def draw(self, context): + layout = self.layout + + layout.operator("object.vertex_group_sort", icon='SORTALPHA') + layout.operator("object.vertex_group_copy", icon='COPY_ID') + layout.operator("object.vertex_group_copy_to_linked", icon='LINK_AREA') + layout.operator("object.vertex_group_mirror", icon='ARROW_LEFTRIGHT') + + +class MESH_MT_shape_key_specials(bpy.types.Menu): + bl_label = "Shape Key Specials" + + def draw(self, context): + layout = self.layout + + layout.operator("object.shape_key_transfer", icon='COPY_ID') # icon is not ideal + layout.operator("object.join_shapes", icon='COPY_ID') # icon is not ideal + layout.operator("object.shape_key_mirror", icon='ARROW_LEFTRIGHT') + + class DataButtonsPanel(bpy.types.Panel): bl_space_type = 'PROPERTIES' bl_region_type = 'WINDOW' @@ -121,11 +144,7 @@ class DATA_PT_vertex_groups(DataButtonsPanel): col = row.column(align=True) col.operator("object.vertex_group_add", icon='ZOOMIN', text="") col.operator("object.vertex_group_remove", icon='ZOOMOUT', text="") - col.operator("object.vertex_group_sort", icon='SORTALPHA', text="") - - col.operator("object.vertex_group_copy", icon='COPY_ID', text="") - if ob.data.users > 1: - col.operator("object.vertex_group_copy_to_linked", icon='LINK_AREA', text="") + col.menu("MESH_MT_vertex_group_specials", icon='DOWNARROW_HLT', text="") if group: row = layout.row() @@ -178,6 +197,7 @@ class DATA_PT_shape_keys(DataButtonsPanel): sub = col.column(align=True) sub.operator("object.shape_key_add", icon='ZOOMIN', text="") sub.operator("object.shape_key_remove", icon='ZOOMOUT', text="") + sub.menu("MESH_MT_shape_key_specials", icon='DOWNARROW_HLT', text="") if kb: col.separator() @@ -206,13 +226,10 @@ class DATA_PT_shape_keys(DataButtonsPanel): subsub.prop(ob, "shape_key_lock", text="") subsub.prop(kb, "mute", text="") sub.prop(ob, "shape_key_edit_mode", text="") - - sub = row.row(align=True) - sub.operator("object.shape_key_transfer", icon='COPY_ID', text="") # icon is not ideal - sub.operator("object.shape_key_mirror", icon='ARROW_LEFTRIGHT', text="") + + sub = row.row() sub.operator("object.shape_key_clear", icon='X', text="") - row = layout.row() row.prop(kb, "name") @@ -286,6 +303,9 @@ class DATA_PT_vertex_colors(DataButtonsPanel): if lay: layout.prop(lay, "name") +bpy.types.register(MESH_MT_vertex_group_specials) +bpy.types.register(MESH_MT_shape_key_specials) + bpy.types.register(DATA_PT_context_mesh) bpy.types.register(DATA_PT_normals) bpy.types.register(DATA_PT_settings) diff --git a/release/scripts/ui/properties_material.py b/release/scripts/ui/properties_material.py index bd3b6f86e7e..dfd182283e8 100644 --- a/release/scripts/ui/properties_material.py +++ b/release/scripts/ui/properties_material.py @@ -44,7 +44,7 @@ class MATERIAL_MT_sss_presets(bpy.types.Menu): class MATERIAL_MT_specials(bpy.types.Menu): - bl_label = "Material Options" + bl_label = "Material Specials" def draw(self, context): layout = self.layout diff --git a/release/scripts/ui/space_view3d.py b/release/scripts/ui/space_view3d.py index 2cc056ac04a..880ab51b87f 100644 --- a/release/scripts/ui/space_view3d.py +++ b/release/scripts/ui/space_view3d.py @@ -671,7 +671,6 @@ class VIEW3D_MT_object(bpy.types.Menu): layout.separator() - layout.operator("object.join_shapes") layout.operator("object.join_uvs") layout.operator("object.join") -- cgit v1.2.3