Align cursor to selected should inclide rotation option
Apologies f this already exists. I could not find it. When using the Align cursor to a selected tool, it should include the option to match rotation as well as location.
I wrote some code to make a button to do it but seems like it should be an available option out of the box:
import bpy
def align_cursor_to_selection():
# Get the active object
active_object = bpy.context.active_object
if active_object is not None:
# Get the position and rotation of the selected object
position = active_object.location
rotation = active_object.rotation_euler
# Set the position and rotation of the 3D cursor to match the selected object
bpy.context.scene.cursor.location = position
bpy.context.scene.cursor.rotation_euler = rotation
class CursorToSelectedPanel(bpy.types.Panel):
bl_idname = "VIEW3D_PT_cursor_to_selected"
bl_label = "Cursor to Selected"
bl_space_type = 'VIEW_3D'
bl_region_type = 'UI'
bl_category = "Tool"
def draw(self, context):
layout = self.layout
layout.operator("view3d.cursor_to_selected", text="Align Cursor to Selected")
class CursorToSelectedOperator(bpy.types.Operator):
bl_idname = "view3d.cursor_to_selected"
bl_label = "Align Cursor to Selected"
def execute(self, context):
align_cursor_to_selection()
return {'FINISHED'}
def register():
bpy.utils.register_class(CursorToSelectedPanel)
bpy.utils.register_class(CursorToSelectedOperator)
def unregister():
bpy.utils.unregister_class(CursorToSelectedPanel)
bpy.utils.unregister_class(CursorToSelectedOperator)
if __name__ == "__main__":
register()
2 Comments
blender.community/c/rightclickselect/nORp/ i was asking for basically the same here. So agree fully! Hope this gets worked on sometime soon
It is the backtick ` to include code, not singlequote ' . On a QWERTY keyboard it's the key in the top left corner with tilde ~ on the shift position.