- select active camera operator
- calling menu use exec rather then invoke
This commit is contained in:
@@ -75,6 +75,27 @@ class SelectPattern(bpy.types.Operator):
|
|||||||
row.prop(props, "extend")
|
row.prop(props, "extend")
|
||||||
|
|
||||||
|
|
||||||
|
class SelectCamera(bpy.types.Operator):
|
||||||
|
'''Select object matching a naming pattern.'''
|
||||||
|
bl_idname = "object.select_camera"
|
||||||
|
bl_label = "Select Camera"
|
||||||
|
bl_register = True
|
||||||
|
bl_undo = True
|
||||||
|
|
||||||
|
def poll(self, context):
|
||||||
|
return context.scene.camera is not None
|
||||||
|
|
||||||
|
def execute(self, context):
|
||||||
|
scene = context.scene
|
||||||
|
camera = scene.camera
|
||||||
|
if camera.name not in scene.objects:
|
||||||
|
self.report({'WARNING'}, "Active camera is not in this scene")
|
||||||
|
|
||||||
|
context.scene.objects.active = camera
|
||||||
|
camera.selected = True
|
||||||
|
return {'FINISHED'}
|
||||||
|
|
||||||
|
|
||||||
class SubdivisionSet(bpy.types.Operator):
|
class SubdivisionSet(bpy.types.Operator):
|
||||||
'''Sets a Subdivision Surface Level (1-5)'''
|
'''Sets a Subdivision Surface Level (1-5)'''
|
||||||
|
|
||||||
@@ -450,6 +471,7 @@ class MakeDupliFace(bpy.types.Operator):
|
|||||||
|
|
||||||
|
|
||||||
bpy.types.register(SelectPattern)
|
bpy.types.register(SelectPattern)
|
||||||
|
bpy.types.register(SelectCamera)
|
||||||
bpy.types.register(SubdivisionSet)
|
bpy.types.register(SubdivisionSet)
|
||||||
bpy.types.register(ShapeTransfer)
|
bpy.types.register(ShapeTransfer)
|
||||||
bpy.types.register(JoinUVs)
|
bpy.types.register(JoinUVs)
|
||||||
|
|||||||
@@ -385,6 +385,7 @@ class VIEW3D_MT_select_object(bpy.types.Menu):
|
|||||||
layout.operator("object.select_mirror", text="Mirror")
|
layout.operator("object.select_mirror", text="Mirror")
|
||||||
layout.operator("object.select_by_layer", text="Select All by Layer")
|
layout.operator("object.select_by_layer", text="Select All by Layer")
|
||||||
layout.operator_menu_enum("object.select_by_type", "type", "", text="Select All by Type...")
|
layout.operator_menu_enum("object.select_by_type", "type", "", text="Select All by Type...")
|
||||||
|
layout.operator("object.select_camera", text="Select Camera")
|
||||||
|
|
||||||
layout.separator()
|
layout.separator()
|
||||||
|
|
||||||
|
|||||||
@@ -1247,7 +1247,7 @@ static void WM_OT_search_menu(wmOperatorType *ot)
|
|||||||
ot->poll= wm_search_menu_poll;
|
ot->poll= wm_search_menu_poll;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int wm_call_menu_invoke(bContext *C, wmOperator *op, wmEvent *event)
|
static int wm_call_menu_exec(bContext *C, wmOperator *op)
|
||||||
{
|
{
|
||||||
char idname[BKE_ST_MAXNAME];
|
char idname[BKE_ST_MAXNAME];
|
||||||
RNA_string_get(op->ptr, "name", idname);
|
RNA_string_get(op->ptr, "name", idname);
|
||||||
@@ -1262,7 +1262,7 @@ static void WM_OT_call_menu(wmOperatorType *ot)
|
|||||||
ot->name= "Call Menu";
|
ot->name= "Call Menu";
|
||||||
ot->idname= "WM_OT_call_menu";
|
ot->idname= "WM_OT_call_menu";
|
||||||
|
|
||||||
ot->invoke= wm_call_menu_invoke;
|
ot->exec= wm_call_menu_exec;
|
||||||
|
|
||||||
RNA_def_string(ot->srna, "name", "", BKE_ST_MAXNAME, "Name", "Name of the menu");
|
RNA_def_string(ot->srna, "name", "", BKE_ST_MAXNAME, "Name", "Name of the menu");
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user