Changeset View
Changeset View
Standalone View
Standalone View
release/scripts/startup/bl_ui/space_view3d.py
| Context not available. | |||||
| return | return | ||||
| ''' | ''' | ||||
| #If something is selected | |||||
| # If something is selected | # Individual object types | ||||
| if obj is not None and obj.type in {'MESH', 'CURVE', 'SURFACE'}: | |||||
| layout.operator("object.shade_smooth", text="Shade Smooth") | |||||
| layout.operator("object.shade_flat", text="Shade Flat") | |||||
| layout.separator() | |||||
| if obj is None: | if obj is None: | ||||
| pass | pass | ||||
| elif obj.type == 'MESH': | |||||
| layout.operator_context = 'INVOKE_REGION_WIN' | |||||
| layout.operator_menu_enum("object.origin_set", text="Set Origin", property="type") | |||||
| layout.operator_context = 'INVOKE_DEFAULT' | |||||
| # If more than one object is selected | |||||
| if selected_objects_len > 1: | |||||
| layout.operator("object.join") | |||||
| layout.separator() | |||||
| elif obj.type == 'CAMERA': | if obj.type == 'CAMERA': | ||||
| layout.operator_context = 'INVOKE_REGION_WIN' | layout.operator_context = 'INVOKE_REGION_WIN' | ||||
| layout.operator("view3d.object_as_camera", text="Set Active Camera") | |||||
| if obj.data.type == 'PERSP': | if obj.data.type == 'PERSP': | ||||
| props = layout.operator("wm.context_modal_mouse", text="Camera Lens Angle") | props = layout.operator("wm.context_modal_mouse", text="Adjust Focal Length") | ||||
campbellbarton: This fails if `obj` is None (checked below). | |||||
| props.data_path_iter = "selected_editable_objects" | props.data_path_iter = "selected_editable_objects" | ||||
| props.data_path_item = "data.lens" | props.data_path_item = "data.lens" | ||||
| props.input_scale = 0.1 | props.input_scale = 0.1 | ||||
| if obj.data.lens_unit == 'MILLIMETERS': | if obj.data.lens_unit == 'MILLIMETERS': | ||||
| props.header_text = "Camera Lens Angle: %.1fmm" | props.header_text = "Camera Focal Length: %.1fmm" | ||||
| else: | else: | ||||
| props.header_text = "Camera Lens Angle: %.1f\u00B0" | props.header_text = "Camera Focal Length: %.1f\u00B0" | ||||
| else: | else: | ||||
| props = layout.operator("wm.context_modal_mouse", text="Camera Lens Scale") | props = layout.operator("wm.context_modal_mouse", text="Camera Lens Scale") | ||||
| Context not available. | |||||
| if view and view.camera == obj and view.region_3d.view_perspective == 'CAMERA': | if view and view.camera == obj and view.region_3d.view_perspective == 'CAMERA': | ||||
| props = layout.operator("ui.eyedropper_depth", text="DOF Distance (Pick)") | props = layout.operator("ui.eyedropper_depth", text="DOF Distance (Pick)") | ||||
| else: | else: | ||||
| props = layout.operator("wm.context_modal_mouse", text="DOF Distance") | props = layout.operator("wm.context_modal_mouse", text="Adjust Focus Distance") | ||||
| props.data_path_iter = "selected_editable_objects" | props.data_path_iter = "selected_editable_objects" | ||||
| props.data_path_item = "data.dof.focus_distance" | props.data_path_item = "data.dof.focus_distance" | ||||
| props.input_scale = 0.02 | props.input_scale = 0.02 | ||||
| props.header_text = "DOF Distance: %.3f" | props.header_text = "Focus Distance: %.3f" | ||||
| layout.separator() | layout.separator() | ||||
| elif obj.type in {'CURVE', 'FONT'}: | elif obj.type in {'CURVE', 'FONT'}: | ||||
| layout.operator_context = 'INVOKE_REGION_WIN' | layout.operator_context = 'INVOKE_REGION_WIN' | ||||
| props = layout.operator("wm.context_modal_mouse", text="Extrude Size") | props = layout.operator("wm.context_modal_mouse", text="Adjust Extrusion") | ||||
| props.data_path_iter = "selected_editable_objects" | props.data_path_iter = "selected_editable_objects" | ||||
| props.data_path_item = "data.extrude" | props.data_path_item = "data.extrude" | ||||
| props.input_scale = 0.01 | props.input_scale = 0.01 | ||||
| props.header_text = "Extrude Size: %.3f" | props.header_text = "Extrude: %.3f" | ||||
| props = layout.operator("wm.context_modal_mouse", text="Width Size") | props = layout.operator("wm.context_modal_mouse", text="Adjust Offset") | ||||
| props.data_path_iter = "selected_editable_objects" | props.data_path_iter = "selected_editable_objects" | ||||
| props.data_path_item = "data.offset" | props.data_path_item = "data.offset" | ||||
| props.input_scale = 0.01 | props.input_scale = 0.01 | ||||
| props.header_text = "Width Size: %.3f" | props.header_text = "Offset: %.3f" | ||||
| layout.separator() | |||||
| layout.operator("object.convert", text="Convert to Mesh").target = 'MESH' | |||||
| layout.operator("object.convert", text="Convert to Grease Pencil").target = 'GPENCIL' | |||||
| layout.operator_menu_enum("object.origin_set", text="Set Origin", property="type") | |||||
| layout.separator() | |||||
| elif obj.type == 'GPENCIL': | |||||
| layout.operator("gpencil.convert", text="Convert to Path").type = 'PATH' | |||||
| layout.operator("gpencil.convert", text="Convert to Bezier Curve").type = 'CURVE' | |||||
| layout.operator("gpencil.convert", text="Convert to Polygon Curve").type = 'POLY' | |||||
| layout.operator_menu_enum("object.origin_set", text="Set Origin", property="type") | |||||
Done Inline ActionsThis can be removed if it's going to remain empty. campbellbarton: This can be removed if it's going to remain empty. | |||||
| layout.separator() | layout.separator() | ||||
| elif obj.type == 'EMPTY': | elif obj.type == 'EMPTY': | ||||
| layout.operator_context = 'INVOKE_REGION_WIN' | layout.operator_context = 'INVOKE_REGION_WIN' | ||||
| props = layout.operator("wm.context_modal_mouse", text="Empty Draw Size") | props = layout.operator("wm.context_modal_mouse", text="Adjust Display Size") | ||||
| props.data_path_iter = "selected_editable_objects" | props.data_path_iter = "selected_editable_objects" | ||||
| props.data_path_item = "empty_display_size" | props.data_path_item = "empty_display_size" | ||||
| props.input_scale = 0.01 | props.input_scale = 0.01 | ||||
| props.header_text = "Empty Draw Size: %.3f" | props.header_text = "Empty Display Size: %.3f" | ||||
| layout.separator() | layout.separator() | ||||
Done Inline ActionsThis should probably have a check for whether the object is actually an image empty: HooglyBoogly: This should probably have a check for whether the object is actually an image empty:
`if (obj. | |||||
| if (obj.empty_display_type == 'IMAGE'): | |||||
| layout.operator("gpencil.trace_image") | |||||
| layout.separator() | |||||
| elif obj.type == 'LIGHT': | elif obj.type == 'LIGHT': | ||||
| light = obj.data | light = obj.data | ||||
| layout.operator_context = 'INVOKE_REGION_WIN' | layout.operator_context = 'INVOKE_REGION_WIN' | ||||
| props = layout.operator("wm.context_modal_mouse", text="Power") | props = layout.operator("wm.context_modal_mouse", text="Adjust Light Power") | ||||
| props.data_path_iter = "selected_editable_objects" | props.data_path_iter = "selected_editable_objects" | ||||
| props.data_path_item = "data.energy" | props.data_path_item = "data.energy" | ||||
| props.header_text = "Light Power: %.3f" | props.header_text = "Light Power: %.3f" | ||||
| if light.type == 'AREA': | if light.type == 'AREA': | ||||
| props = layout.operator("wm.context_modal_mouse", text="Size X") | |||||
| props.data_path_iter = "selected_editable_objects" | |||||
| props.data_path_item = "data.size" | |||||
| props.header_text = "Light Size X: %.3f" | |||||
| if light.shape in {'RECTANGLE', 'ELLIPSE'}: | if light.shape in {'RECTANGLE', 'ELLIPSE'}: | ||||
| props = layout.operator("wm.context_modal_mouse", text="Size Y") | props = layout.operator("wm.context_modal_mouse", text="Adjust Area Light X Size") | ||||
| props.data_path_iter = "selected_editable_objects" | |||||
| props.data_path_item = "data.size" | |||||
| props.header_text = "Light Size X: %.3f" | |||||
| props = layout.operator("wm.context_modal_mouse", text="Adjust Area Light Y Size") | |||||
| props.data_path_iter = "selected_editable_objects" | props.data_path_iter = "selected_editable_objects" | ||||
| props.data_path_item = "data.size_y" | props.data_path_item = "data.size_y" | ||||
| props.header_text = "Light Size Y: %.3f" | props.header_text = "Light Size Y: %.3f" | ||||
| else: | |||||
| props = layout.operator("wm.context_modal_mouse", text="Adjust Area Light Size") | |||||
| props.data_path_iter = "selected_editable_objects" | |||||
| props.data_path_item = "data.size" | |||||
| props.header_text = "Light Size: %.3f" | |||||
| elif light.type in {'SPOT', 'POINT'}: | elif light.type in {'SPOT', 'POINT'}: | ||||
| props = layout.operator("wm.context_modal_mouse", text="Radius") | props = layout.operator("wm.context_modal_mouse", text="Adjust Light Radius") | ||||
| props.data_path_iter = "selected_editable_objects" | props.data_path_iter = "selected_editable_objects" | ||||
| props.data_path_item = "data.shadow_soft_size" | props.data_path_item = "data.shadow_soft_size" | ||||
| props.header_text = "Light Radius: %.3f" | props.header_text = "Light Radius: %.3f" | ||||
| elif light.type == 'SUN': | elif light.type == 'SUN': | ||||
| props = layout.operator("wm.context_modal_mouse", text="Angle") | props = layout.operator("wm.context_modal_mouse", text="Adjust Sun Angle") | ||||
| props.data_path_iter = "selected_editable_objects" | props.data_path_iter = "selected_editable_objects" | ||||
| props.data_path_item = "data.angle" | props.data_path_item = "data.angle" | ||||
| props.header_text = "Light Angle: %.3f" | props.header_text = "Light Angle: %.3f" | ||||
| Context not available. | |||||
| if light.type == 'SPOT': | if light.type == 'SPOT': | ||||
| layout.separator() | layout.separator() | ||||
| props = layout.operator("wm.context_modal_mouse", text="Spot Size") | props = layout.operator("wm.context_modal_mouse", text="Adjust Spot Size") | ||||
| props.data_path_iter = "selected_editable_objects" | props.data_path_iter = "selected_editable_objects" | ||||
| props.data_path_item = "data.spot_size" | props.data_path_item = "data.spot_size" | ||||
| props.input_scale = 0.01 | props.input_scale = 0.01 | ||||
| props.header_text = "Spot Size: %.2f" | props.header_text = "Spot Size: %.2f" | ||||
| props = layout.operator("wm.context_modal_mouse", text="Spot Blend") | props = layout.operator("wm.context_modal_mouse", text="Adjust Spot Blend") | ||||
| props.data_path_iter = "selected_editable_objects" | props.data_path_iter = "selected_editable_objects" | ||||
| props.data_path_item = "data.spot_blend" | props.data_path_item = "data.spot_blend" | ||||
Done Inline Actionsamong, also below. campbellbarton: `among`, also below. | |||||
| props.input_scale = -0.01 | props.input_scale = -0.01 | ||||
| props.header_text = "Spot Blend: %.2f" | props.header_text = "Spot Blend: %.2f" | ||||
| layout.separator() | layout.separator() | ||||
| # Shared among some object types | |||||
| if obj.type in {'MESH', 'CURVE', 'SURFACE'}: | |||||
| layout.operator("object.shade_smooth", text="Shade Smooth") | |||||
| layout.operator("object.shade_flat", text="Shade Flat") | |||||
| layout.separator() | |||||
Done Inline ActionsThis shouldn't be needed. Multiple separators are now de-duplicated. campbellbarton: This shouldn't be needed. Multiple separators are now de-duplicated. | |||||
Done Inline ActionsClarification: the if selected_objects_len == 1: shouldn't be needed. campbellbarton: Clarification: the `if selected_objects_len == 1:` shouldn't be needed. | |||||
Done Inline ActionsI added that here to make sure there is always a separator after this group, even when the Join operator doesn't appear. Not sure how else to do that. billreynish: I added that here to make sure there is always a separator after this group, even when the Join… | |||||
| # If more than one object is selected. | |||||
| if obj.type in {'MESH', 'CURVE', 'SURFACE', 'ARMATURE', 'GPENCIL'}: | |||||
Done Inline ActionsThis works for empty objects too - which instance collections. campbellbarton: This works for empty objects too - which instance collections. | |||||
| if selected_objects_len > 1: | |||||
| layout.operator("object.join") | |||||
| if obj.type in {'MESH', 'CURVE', 'SURFACE', 'GPENCIL', 'LATTICE', 'ARMATURE', 'META'}: | |||||
| layout.operator_context = 'INVOKE_REGION_WIN' | |||||
| layout.operator_menu_enum("object.origin_set", text="Set Origin", property="type") | |||||
| layout.operator_context = 'INVOKE_DEFAULT' | |||||
Done Inline Actionsamong campbellbarton: `among` | |||||
| layout.separator() | |||||
| # Shared among all object types | |||||
| layout.operator("view3d.copybuffer", text="Copy Objects", icon='COPYDOWN') | layout.operator("view3d.copybuffer", text="Copy Objects", icon='COPYDOWN') | ||||
| layout.operator("view3d.pastebuffer", text="Paste Objects", icon='PASTEDOWN') | layout.operator("view3d.pastebuffer", text="Paste Objects", icon='PASTEDOWN') | ||||
| Context not available. | |||||
| layout.separator() | layout.separator() | ||||
| props = layout.operator("wm.call_panel", text="Rename Active Object...") | if selected_objects_len > 1: | ||||
| props.name = "TOPBAR_PT_name" | layout.operator("wm.batch_rename") | ||||
| props.keep_open = False | |||||
| else: | |||||
| props = layout.operator("wm.call_panel", text="Rename Active Object...") | |||||
| props.name = "TOPBAR_PT_name" | |||||
| props.keep_open = False | |||||
| layout.separator() | layout.separator() | ||||
| Context not available. | |||||
This fails if obj is None (checked below).