Bmesh Help for extrude

is selected an edge and need to extrude it to a certain length

got this but not doing the extrude part


            
        dx = 2.0 
        dy = 0.0 
        dz = 0.0
           
        for v in bm.verts:
        
            if v.select or not edbm:
                # Translate all verts if object is in object mode,
                # selected verts only if in edit mode.
#                v.co += v.normal * 0.2
                #  Extrude and move verts 
                v.co +=  Vector( [ dx, dy, dz ] )
 



can some one help to do the extrude and move it to a certain distance

thanks
happy bl

you might have to do a mesh update afterwards

Can’t you use the built-in extrude op?

I can do the copy fine
but don’t see how to do an extend or extrude and move edge some where else!

don’t really won’t to use bpy ops operator
too slow prefer to use the Bmesh data
more flexible also !

I could show a pic of what I need to do
but simple I need to extrude normal to the edge and same distance then the length of the edge
to get a square
so is there also a way to find in which World pace the 3D view is
like front or top or side view ?

thanks
happy bl

With bmesh it must be something like:

sel_edges = [e for e in bm.edges if e.select]
new_geom = bmesh.ops.extrude_edge_only(bm, edges=sel_edges, use_select_history=False)['geom']
extruded_verts = [v for v in new_geom if isinstance(v, bmesh.types.BMVert)]

# move extruded_verts anyhow

redid another little script and it does the extend

now 2 things needed for this to work

after doing the extend edge
the selected edge remain the old one
is there a way to auto select the new added edge ?

also before doing the extend command
is there a way to get the first selected edge length and use it to move the newly created edge a certain distance = to the first selected edge?

looks like it does a edge normal extend which is good and easier!

I could limit the move operation to a certain view like front or top view if necessary
unless there is a way to detect the view !
doing it in 3D would be too complicated need a lot of math I guess!

it does not seems to see any selected edge !

here is sample file

thanks
happy bl

Attachments

edge-extendrh1.blend (745 KB)

got the length of old edge

edlength = ( edge.verts[0].co - edge.verts[1].co).length
print ('l1 = ', edlength )

how do you get the latest added edge ?
like edge itself or index to do a translate !

see uploaded file
the edge is moved but it does not filled the face
is there some option to get the face ?

thanks
happy bl