1
$\begingroup$

I see in Blender 2.81 that cursor has rotation informations. I would like to find a way to use cursor's Orientation and apply it to an object. Is there an easy way to do that ?

Thanks !

$\endgroup$
  • $\begingroup$ Hello :). You can manually copy the XYZ values, or use it as a driver for your object. Then, by rotating your cursor, the driven object will also rotate. $\endgroup$ – Jachym Michal Dec 10 '19 at 11:48
  • 2
    $\begingroup$ I'm not aware of a simple option or shortcut in the UI, this is possible in Python though (and therefore an add-on could be written which provide a button). Otherwise the approach described by Jachym would work as well. $\endgroup$ – Robert Gützkow Dec 10 '19 at 11:49
3
$\begingroup$

Snap to cursor with code

Quick little script to copy either or both of cursor location, rotation to selected objects.

import bpy
from mathutils import Matrix

use_rotation = True # use cursor rot
use_location = True #  "    "    loc

context = bpy.context

cursor = context.scene.cursor

tc, qc, sc = cursor.matrix.decompose()

for ob in context.selected_objects:
    to, qo, so = ob.matrix_world.decompose()

    R = qc.to_matrix().to_4x4() if use_rotation else qo.to_matrix().to_4x4()

    T = Matrix.Translation(tc) if use_location else Matrix.Translation(to)

    S = Matrix.Diagonal(so).to_4x4()

    ob.matrix_world = T @ R @ S
|improve this answer|||||
$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.