Featured post

new redirect for blender.org bpy docs.

http://www.blender.org/api/blender_python_api_current/ As of 10/11 november 2015 we can now link to the current api docs and not be worr...

May 23, 2011

Blender 2.5 Python 3.2 Selecting Creased Edges


import bpy

obj = bpy.context.active_object
bpy.ops.object.mode_set(mode='OBJECT')

for i in obj.data.edges:
if i.crease > 0.0:
i.select = True

bpy.ops.object.mode_set(mode='EDIT')
This is useful if for whatever reason you need to select all creased edges on an object that has a lot of geometry.

As a response to Enzymes query below, I posted additional examples of edge selection, which I think can prove to be useful to get people started Edge selection with criteria

5 comments:

  1. Hi Dealga, I've been trying to contact you to ask Blender Python related question. Kind of related to above script on this post, but I need to also Split and Separate the Edge.

    Basically I have been searching for a script that does select each edge of selected mesh one by one, and splitting it (if crease is bigger than 90 or maybe if it is Marked as Sharp).

    The closest to what I am trying to do is this post:
    http://blenderartists.org/forum/showthread.php?147108-Split-a-mesh-by-vertex-groups

    But, then again all I'd like to do is to separate all edges from mesh into separate edge (after I previously delete the Face Only).

    Could you help with this? Thank you very much.

    ReplyDelete
  2. Thanks for your answer.

    import bpy
    obj = bpy.context.active_object
    bpy.ops.object.mode_set(mode='EDIT')
    bpy.ops.mesh.delete(type='ONLY_FACE')
    bpy.ops.object.mode_set(mode='OBJECT')
    for indx in range(len(obj.data.edges)):
    print(indx)

    obj.data.edges[indx].select = True

    bpy.ops.object.mode_set(mode='EDIT')
    bpy.ops.mesh.split()

    bpy.ops.object.mode_set(mode='OBJECT')
    obj.data.edges[indx].select = False

    ReplyDelete
  3. Hi Dealga,

    I am trying to automate the import of a series of obj scenes into blender 2.60 that were generated in another program. I can import a single one through the blender gui without a problem. But I want to import hundreds of them and then render each one using a script. My issue is figuring out the syntax for this line, which never ceases to generate an error:

    bpy.ops.import_scene.obj(filepath="scene_to_import.obj")

    While I have found documentation online to give me syntax guidance, I have not been able to get this particular operator to work properly. Any suggestions would be appreciated.

    Thanks

    ReplyDelete
    Replies
    1. Hi pmpfx,

      As it happens I have some interest in this, and will write a short introduction to it here :

      http://blenderscripting.blogspot.com/2012/03/importing-obj.html

      Delete

Please use Blender.StackExchange.com for python scripting questions unrelated to this post.