how to select and edge an extrude with Bmesh ?

I have this example here

bm =

Add triangle

circle = bmesh.ops.create_circle(bm, segments = 3, diameter = 3)

Fill triangle

Pick first edge the first vertex is part of

circle_edge = circle[‘verts’][0].link_edges[0]
print (‘circle_edge list verts =’,circle_edge )
print (‘circle[verts][0] verts =’,circle[‘verts’][0])
print ()
v1, v2 = circle_edge.verts
print (‘v1 =’,v1, ‘ =’,
print (‘v2 =’,v2 , ‘ =’, )
print ()

but let say that I have an edge selected on a mesh
how do I copy it and move it or may be extrude it using Bmesh?

happy bl

One way to access mesh edge data is through:


OBJECTNUM and EDGENUM are indexes. For example, this would give you the first edge (0) of the second object (1) in your scene:

>>> bpy.context.scene.objects[1].data.edges[0]

Moving this edge would be pretty easy, you would just find out what vertices the edge you want to move is using and then the vertices coordinate values. To extend on the above example:

>>> print( bpy.context.scene.objects[1].data.edges[0].vertices[0])

>>> print( bpy.context.scene.objects[1].data.edges[0].vertices[1])

The first edge in this example is based off of vertices 0 and 1. To see what their current local coordinates are you could use:

>>> bpy.context.scene.objects[1].data.vertices[0].co
<Vector (-2.0000, -2.0000, 0.0000)>

>>> bpy.context.scene.objects[1].data.vertices[1].co
<Vector (2.0000, -2.0000, 0.0000)>

Then you can change the coordinates using assignment:

>>> bpy.context.scene.objects[1].data.vertices[0].co[0] = -3
>>> bpy.context.scene.objects[1].data.vertices[0].co[1] = -1
>>> bpy.context.scene.objects[1].data.vertices[0].co[2] = 1

The code has the ">>> " in it because I copied it over from Blender’s Python Console. If you need a quick overview of getting around the Python Console, these are 2 videos I would recommend:

I’m not as sure about duplicating or extruding edges, I haven’t looked into that myself. I think the bmesh ops page should have some info on how to do it:

This page also has a good overview of a Blender mesh’s base level geometry, but it’s in Japanese. Here’s a google translated version.

can be extrude using Verts or directly with edges
but need the edge’s index

will test later on

right now I can do it with verts but I need to add a panel to get it working
or may be as an operator

I need some variables for extrude up/down right / left
at least for a simple corner shape
but would like after to have some choice of corner’s shape
like rounded or bevel or straight ect…

do you know if there is a way to ID in what viewport mode we are?
like front or top view ?
that would determine the Axis being use!

happy bl

You might be able to do this if you had at least 3 points that created a “planar” face. I’m thinking something like Offset Edges or Edge Roundifier.

Not as sure on this, I think the viewport modes involve complex math like transformation matrices. Maybe look into “” or “bpy.ops.view3d.viewnumpad()”?