1
$\begingroup$

Just isn't working, I'm not sure what else to say. There's no errors and it returns True when you call the value.

I'm trying create a script that creates an object and unwraps it. It's as simple as it gets: it creates a plane, selects all the edges, marks seams on all those selected eges and unwraps it into a square texture.

import bpy
import bmesh

bpy.ops.mesh.primitive_grid_add(x_subdivisions = 0, y_subdivisions = 0, radius = 8)

ob = bpy.context.object
me = ob.data


# unwrap
bpy.ops.object.mode_set(mode = 'EDIT')

bpy.ops.object.select_all

for edge in me.edges:   
    edge.use_seam = True # isn't working

bpy.ops.uv.smart_project(me)

No seams are being added.

Apologies if this ends up being something obvious, I'm new to scripting in Blender.

$\endgroup$
1
  • 1
    $\begingroup$ Of note is that with a plane that only has the four outer edges, adding seams doesn't make any difference to unwrapping. In your example you will get the same result by creating the plane and using bpy.ops.mesh.uv_texture_add(). Also smart project can be set to break the uv's based on edge angle so doesn't need seams to be set. $\endgroup$
    – sambler
    Sep 16 '17 at 10:39
3
$\begingroup$

It's only obvious if you know how blender works. What is happening is the mesh data is copied into a bmesh structure when you go into edit mode, this bmesh data is copied back when leaving edit mode. The changes you make to the underlying mesh data while the mesh is in edit mode are overwritten by this process and won't affect the mesh that you see in edit mode.

If you move your set use_seam loop to above the set edit mode you will get the result that you expect.

$\endgroup$
1
  • $\begingroup$ Yeah, I just figured that out. Some part of me figured "data" just pertained to the geometry. $\endgroup$ Sep 16 '17 at 10:38

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.