The following is a script that is supposed to access UV info but it fails right away in both Object and Edit modes. I fist tried using Bl-2.69.8, then 2.69 then 2.68 and it happens the same every time. I've also tried adding bpy. to the beginning of context but the result is the same.

Can anyone clear this up?

enter image description here

  • 1
    $\begingroup$ Should be bpy.context, it's probably treating context as a unique val which is not defined. $\endgroup$
    – iKlsR
    Jan 21 '14 at 9:53

What you're looking for is bpy.context, so the first line should be:

obj = bpy.context.active_object

It refers to the bpy module being imported in the first line.

You can also use this at the beginning of your scripts:

import bpy
from bpy import context

The entire script should look like this:

import bpy
import bmesh

ob = bpy.context.object
me = ob.data
bm = bmesh.from_edit_mesh(me)

uv_layer = bm.loops.layers.uv.verify()

for f in bm.faces:
    for l in f.loops:
        luv = l[uv_layer]
        if luv.select:
            luv.uv = l.vert.co.xy

  • 3
    $\begingroup$ @MarcClintDion bpy, not .bpy. Dot not preceded by identifier (accessor), or succeeded by number (floating point), is syntax error. $\endgroup$
    – Adhi
    Jan 22 '14 at 23:34

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.