2
$\begingroup$

I want to access to this data:

uv vertice and 2d cursor coordinates example

I tried:

Exporting UV coordinates

http://blenderartists.org/forum/showthread.php?254004-Accessing-UV-data-in-Python-script

http://blenderartists.org/forum/showthread.php?334400-I-want-to-select-a-vertex-on-UV-layer

but all that return the 3dview vertices coordinates....

some ideas?

thanks

$\endgroup$
1
  • 1
    $\begingroup$ Space.ImadeEditor.cursor_location maybe? $\endgroup$ – Denis Apr 3 '15 at 22:35
2
$\begingroup$

This will print the uv coordinates of each vertex and (x, y) position in the UVmap editor then the cursor location

import bpy

ob = bpy.context.active_object

for area in bpy.context.screen.areas:
    if area.type == 'IMAGE_EDITOR':   #find the UVeditor
        cursor = area.spaces.active.cursor_location   # get cursor location
        if  area.spaces.active.image :                #get image dimension
            x = area.spaces.active.image.size[0]
            y = area.spaces.active.image.size[1]
        else:
            x = y = 256

        for v in ob.data.loops :
             uv = ob.data.uv_layers.active.data[v.index].uv   #get uv coo

            #calculate and print the position in the uv editor
             print("vertex %d at with UV coo (%d , %d) at  (%d ,%d)"%(v.index, uv[0], uv[1], uv[0]*x, uv[1]*y) )  
             print( "is selected ? " , ob.data.uv_layers.active.data[v.index].select )

        print (cursor,x,y)
$\endgroup$
6
  • $\begingroup$ hi.. uv = ob.data.uv_layers.active.data[v.index].uv don't work.. even in this case the v in ob.data.loops is the same as each vertex in UV area yes??? $\endgroup$ – yhoyo Apr 3 '15 at 23:15
  • $\begingroup$ @yhoyo what error you are getting exactly ? $\endgroup$ – Chebhou Apr 3 '15 at 23:35
  • $\begingroup$ this one: prntscr.com/6p93yx $\endgroup$ – yhoyo Apr 3 '15 at 23:50
  • $\begingroup$ @yhoyo it seems that it doesn't work in edit mode , i'll look for something else $\endgroup$ – Chebhou Apr 4 '15 at 0:49
  • $\begingroup$ I understand.. but this is confusing because this data in objecto_mode is practically pointless and switch between modes is not very efficient.. also.. "UV vertex" is only avalaible in edit_mode... some another ideas please? $\endgroup$ – yhoyo Apr 4 '15 at 1:00

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.