0
$\begingroup$

In this picture I have a cube selected and in the transform panel you can see the cube's data, such as location and rotation. Is there a way to use the data of this selected object, like the x-location, and turn it into a variable? enter image description here

$\endgroup$
4
  • $\begingroup$ Hello ! Here's all the available members of bpy.types.Object. Additionally I suggest you enable the developer extras in the preferences and the python tooltips which will open a tooltip with the property path when you hover over a field $\endgroup$
    – Gorgious
    Commented Sep 25, 2022 at 8:18
  • $\begingroup$ That setting is just under Settings > Interface > Display > Python Tooltips nowadays. No need ot enable developer extras. $\endgroup$
    – John Eason
    Commented Sep 25, 2022 at 8:21
  • $\begingroup$ One way to do it are drivers. $\endgroup$ Commented Sep 25, 2022 at 8:56
  • $\begingroup$ ups forgot the link docs.blender.org/api/current/bpy.types.Object.html $\endgroup$
    – Gorgious
    Commented Sep 26, 2022 at 11:06

1 Answer 1

0
$\begingroup$

I figured it out. If you change the x-location in the transform panel, the code will appear in the info section:

bpy.context.object.location[0] = 1

So to get the data from the active object and turn it into variables, I did this:

xl = bpy.context.object.location[0]

yl = bpy.context.object.location[1]

zl = bpy.context.object.location[2]

$\endgroup$

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .