[Bf-python] BMesh upgrade docs & api info

CoDEmanX codemanx at gmx.de
Fri Mar 30 12:07:04 CEST 2012


Hi benoit,

1. there's a uv_textures property for MeshTexturePolys, but no 
uv-coordinates in there. Rather looks here:

http://www.blender.org/documentation/blender_python_api_2_62_1/bpy.types.Mesh.html?highlight=uv_loop_layers#bpy.types.Mesh.uv_loop_layers

http://www.blender.org/documentation/blender_python_api_2_62_1/bpy.types.MeshUVLoop.html#bpy.types.MeshUVLoop

 >>> for uv_loop in 
bpy.data.objects['Cube'].data.uv_loop_layers.active.data:
...     uv_loop.uv
...
Vector((0.0, 0.33435294032096863))
Vector((0.3323138952255249, 0.33333343267440796))
Vector((0.3333333730697632, 0.6656473278999329))

If you wanna export triangles and quads, use tessface_uv_textures 
(behaves like the former uv_textures):

 >>> bpy.data.objects['Cube'].data.update(calc_tessface=1)
 >>> for face_uv in 
bpy.data.objects['Cube'].data.tessface_uv_textures.active.data:
...     for vert_uv in face_uv.uv:
...         list(vert_uv)
...
[0.0, 0.33435294032096863]
[0.3323138952255249, 0.33333343267440796]
[0.3333333730697632, 0.6656473278999329]


2. No, 'cause you don't need such a check. Tessfaces aren't triangulated 
meshes, but triangles and quads. So you should always use tessfaces for 
your exporter.

Default cube:

 >>> for f in bpy.data.objects['Cube'].data.tessfaces:
...     list(f.vertices)
...
[0, 1, 2, 3]
[4, 7, 6, 5]
[0, 4, 5, 1]
[1, 5, 6, 2]
[2, 6, 7, 3]
[4, 0, 3, 7]

the faces refer to 4 vertices each, 4 verts = quad.

Regards, Cody


Am 30.03.2012 08:01, schrieb benoit.muller at laposte.net:
> Hi,
> thank you for this usefull document.
>
> I'm currently upgrading my Exporter to 2.63 and I have 2 questions. I would be
> gratefull if someone could help.
>
> 1) I cannot find the UV information on the MeshTexturePoly. Where should be the UV
> information when using NGons (Mesh.polygons).
>
> 2) The 3DEngine supports Tris and Quads, and is performant with quad.
> So my plan is to first iterate on all Ngons of the Mesh.
> If max NGons are<=4, I would use Mesh.polygons to export Tris and Quads
> If max NGons are>4, I would use Mesh.tessfaces to export tesslated Tris.
> Is it a good strategy ?
>
>
> Regards,
> Benoit Muller
>
>> Message du 23/03/12 02:41
>> De : "Campbell Barton"
>> A : "Blender Foundation Python list"
>> Copie à :
>> Objet : [Bf-python] BMesh upgrade docs&  api info
>>
>> Hi List, its been a while since I posted to the list on bmesh python
>> api progress and related issues.
>>
>> Firstly, I've added a section to our docs which gives some info on how
>> to upgrade scripts as well as some of the differences between the 3
>> ways to access faces now.
>>
>>
> http://www.blender.org/documentation/blender_python_api_2_62_2/info_gotcha.html#ngons-
> and-tessellation-faces
>>
>> One breaking change is that mesh.faces is now called mesh.tessfaces,
>> this is so scripts dont fail silently, either you want to use tessface
>> data - which is a now a polygon cache now and should not be edited
>> since the changes wont apply back to the original mesh or you want to
>> use tessfaces for exporting,
>>
>> ---
>>
>> And a brief update on bmesh docs...
>> Added examples and more descriptions to main BMesh module page
>> * http://www.blender.org/documentation/blender_python_api_2_62_2/bmesh.html
>>
>> The types are better arranges (were hard to follow before)
>> * www.blender.org/documentation/blender_python_api_2_62_2/bmesh.types.html
>>
>> Added customdata access (works different to all our previous mesh api's)
>> *
> http://www.blender.org/documentation/blender_python_api_2_62_2/bmesh.html#customdata-
> access
>>
>> Meshes that are not in editmode can now be converted to/from bmesh see
>> BMesh from_object, from_mesh, to_mesh.
>>
>> Added select_history access.
>> *
> http://www.blender.org/documentation/blender_python_api_2_62_2/bmesh.types.html#bmesh.
> types.BMEditSelSeq
>>
>> --
>> - Campbell
>> _______________________________________________
>> Bf-python mailing list
>> Bf-python at blender.org
>> http://lists.blender.org/mailman/listinfo/bf-python
>>
>
> Une messagerie gratuite, garantie à vie et des services en plus, ça vous tente ?
> Je crée ma boîte mail www.laposte.net
> _______________________________________________
> Bf-python mailing list
> Bf-python at blender.org
> http://lists.blender.org/mailman/listinfo/bf-python



More information about the Bf-python mailing list