Page MenuHome

can´t make uv and return attributes in the same execution
Closed, ArchivedPublic

Description

This is a problem that i have with uv in python
As i sad in title we can´t make a new uv (MeshTextureFaceLayer) and return yours attributes in the same execution.

Trying this:

import bpy
obj = bpy.context.active_object
mesh = obj.data
uvtex = bpy.ops.mesh.uv_texture_add()
print(dir(uvtex))

we get the list:

['__and__', '__class__', '__contains__', '__delattr__', '__doc__', '__eq__', '__
format__', '__ge__', '__getattribute__', '__gt__', '__hash__', '__iand__', '__in
it__', '__ior__', '__isub__', '__iter__', '__ixor__', '__le__', '__len__', '__lt
__', '__ne__', '__new__', '__or__', '__rand__', '__reduce__', '__reduce_ex__', '
__repr__', '__ror__', '__rsub__', '__rxor__', '__setattr__', '__sizeof__', '__st
r__', '__sub__', '__subclasshook__', '__xor__', 'add', 'clear', 'copy', 'differe
nce', 'difference_update', 'discard', 'intersection', 'intersection_update', 'is
disjoint', 'issubset', 'issuperset', 'pop', 'remove', 'symmetric_difference', 's
ymmetric_difference_update', 'union', 'update']

but with the uv created and trying this:

import bpy
obj = bpy.context.active_object
mesh = obj.data
uvtex = mesh.uv_textures.active
print(dir(uvtex))

we get this:

['__doc__', '__module__', '__slots__', 'active', 'active_clone', 'active_render'
, 'bl_rna', 'data', 'name', 'rna_type']

As would be...

This bug is crashing the script template "uv Operator" of Trunk
Any idea?

Bye!

Event Timeline

More stuff for campbell :)

Operators never return data like this, we have rna functions which work as you are expecting.
most collections have load/new/add functions as well as equivalents for removing.
# ---
import bpy
obj = bpy.context.active_object
uvlayer = obj.data.uv_textures.new()

Campbell Barton (campbellbarton) changed the task status from Unknown Status to Archived.Feb 1 2011, 6:21 AM