How can I add a Vertex from a script? I'd like to create a line from the extrusion of a vertex. This is my script now:

import bpy

location = bpy.context.scene.cursor_location    # Get Cursor location
bpy.ops.object.editmode_toggle()                # Enter Edit Mode

# Here goes the script I'm looking for!

bpy.ops.mesh.extrude_region_move()              # Extrude vertex

First of all you have to create a object and a mesh, after that you can add the vertex to it:

# name: string for new object name
# verts: array of position coords - [(-1.0, 1.0, 0.0), (-1.0, -1.0, 0.0)]

def create_Vertices (name, verts):
    # Create mesh and object
    me = bpy.data.meshes.new(name+'Mesh')
    ob = bpy.data.objects.new(name, me)
    ob.show_name = True
    # Link object to scene
    me.from_pydata(verts, [], [])
    # Update mesh with new data
    return ob

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.