2
$\begingroup$

I've been working with both Python and Blender for the first time over the past few days and keep running into these mathutils Vector objects which I have no idea what to do with. I can't figure out a way to convert a Vector into a plain X,Y,Z coordinate set that accurately maps to the Blender units, which I can use and apply to object.location

This:

<Vector (-1.0000, 1.0000, 1.0000)>

To: (x, y, z)

I have an object in the scene, a cube that has been resized into a box. I've made a mesh using bmesh, and am looping the edges and examining the Vector points. The problem is that they don't correlate to the blender units of the object I'm pulling them from in order to loop. Why don't the Vector coordinates translate exactly, what am I doing wrong? I'm sure I'm missing something really simple - any help is much appreciated! :)

$\endgroup$
1
  • $\begingroup$ Please be more specific. How did you scale the object. What are the coordinates and what do you expect them to be? Did you expect world-coordinates when iterating over object points without applying the object transformation? $\endgroup$
    – PeterT
    Aug 26, 2018 at 18:47

1 Answer 1

2
$\begingroup$

You access Vector object as sequence like this:

enter image description here

This functionality comes from python, it's called slice notation.


From API reference:

Note: Classes, methods and attributes that accept vectors also accept other numeric sequences, such as tuples, lists.

You don't have to convert anything, both tuple or vector will work for object location:

enter image description here

$\endgroup$
3
  • $\begingroup$ I have an object in the scene, a cube that has been resized into a box. I've made a mesh using bmesh, and am looping the edges and examining the Vector points. The problem is that they don't correlate to the blender units of the object I'm pulling them from in order to loop. Does that makes sense? Why doesn't the Vector coordinates translate exactly, what am I doing wrong? $\endgroup$
    – ineedhelp
    Aug 26, 2018 at 18:43
  • 1
    $\begingroup$ @ineedhelp The mesh vertices locations are relative to the object's centre. If you need a vertex location relative to scene origin, you need to add the object transformation (it's translation) to the location of each vertex. $\endgroup$ Aug 26, 2018 at 21:34
  • $\begingroup$ That makes sense, thanks. I will take a look! $\endgroup$
    – ineedhelp
    Aug 26, 2018 at 23:39

You must log in to answer this question.

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