Skip to main content
import bpy

def point_cloud(ob_name, coords, edges=[], faces=[]):
    """Create point cloud object based on given coordinates and name.

    Keyword arguments:
    ob_name -- new object name
    coords -- float triplets eg: [(-1.0, 1.0, 0.0), (-1.0, -1.0, 0.0)]
    """

    # Create new mesh and a new object
    me = bpy.data.meshes.new(ob_name + "Mesh")
    ob = bpy.data.objects.new(ob_name, me)

    # Make a mesh from a list of vertices/edges/faces
    me.from_pydata(coords, []edges, []faces)

    # Display name and update the mesh
    ob.show_name = True
    me.update()
    return ob

# Create the object
pc = point_cloud("point-cloud", [(0.0, 0.0, 0.0)])

# Link object to the active collection
bpy.context.collection.objects.link(pc)

# Alternatively Link object to scene collection
#bpy.context.scene.collection.objects.link(pc)
import bpy

def point_cloud(ob_name, coords, edges=[], faces=[]):
    """Create point cloud object based on given coordinates and name.

    Keyword arguments:
    ob_name -- new object name
    coords -- float triplets eg: [(-1.0, 1.0, 0.0), (-1.0, -1.0, 0.0)]
    """

    # Create new mesh and a new object
    me = bpy.data.meshes.new(ob_name + "Mesh")
    ob = bpy.data.objects.new(ob_name, me)

    # Make a mesh from a list of vertices/edges/faces
    me.from_pydata(coords, []edges, []faces)

    # Display name and update the mesh
    ob.show_name = True
    me.update()
    return ob

# Create the object
pc = point_cloud("point-cloud", [(0.0, 0.0, 0.0)])

# Link object to the scene
bpy.context.scene.objects.link(pc)
import bpy

def point_cloud(ob_name, coords):
    """Create point cloud object based on given coordinates and name.

    Keyword arguments:
    ob_name -- new object name
    coords -- float triplets eg: [(-1.0, 1.0, 0.0), (-1.0, -1.0, 0.0)]
    """

    # Create new mesh and a new object
    me = bpy.data.meshes.new(ob_name + "Mesh")
    ob = bpy.data.objects.new(ob_name, me)

    # Make a mesh from a list of vertices/edges/faces
    me.from_pydata(coords, [], [])

    # Display name and update the mesh
    ob.show_name = True
    me.update()
    return ob

# Create the object
pc = point_cloud("point-cloud", [(0.0, 0.0, 0.0)])

# Link object to the active collection
bpy.context.collection.objects.link(pc)

# Alternatively Link object to scene collection
#bpy.context.scene.collection.objects.link(pc)
import bpy

def point_cloud(ob_name, coords):
    """Create point cloud object based on given coordinates and name.

    Keyword arguments:
    ob_name -- new object name
    coords -- float triplets eg: [(-1.0, 1.0, 0.0), (-1.0, -1.0, 0.0)]
    """

    # Create new mesh and a new object
    me = bpy.data.meshes.new(ob_name + "Mesh")
    ob = bpy.data.objects.new(ob_name, me)

    # Make a mesh from a list of vertices/edges/faces
    me.from_pydata(coords, [], [])

    # Display name and update the mesh
    ob.show_name = True
    me.update()
    return ob

# Create the object
pc = point_cloud("point-cloud", [(0.0, 0.0, 0.0)])

# Link object to the scene
bpy.context.scene.objects.link(pc)
import bpy

def point_cloud(ob_name, coords, edges=[], faces=[]):
    """Create point cloud object based on given coordinates and name.

    Keyword arguments:
    ob_name -- new object name
    coords -- float triplets eg: [(-1.0, 1.0, 0.0), (-1.0, -1.0, 0.0)]
    """

    # Create new mesh and a new object
    me = bpy.data.meshes.new(ob_name + "Mesh")
    ob = bpy.data.objects.new(ob_name, me)

    # Make a mesh from a list of vertices/edges/faces
    me.from_pydata(coords, edges, faces)

    # Display name and update the mesh
    ob.show_name = True
    me.update()
    return ob

# Create the object
pc = point_cloud("point-cloud", [(0.0, 0.0, 0.0)])

# Link object to the active collection
bpy.context.collection.objects.link(pc)

# Alternatively Link object to scene collection
#bpy.context.scene.collection.objects.link(pc)
import bpy

def point_cloud(ob_name, coords, edges=[], faces=[]):
    """Create point cloud object based on given coordinates and name.

    Keyword arguments:
    ob_name -- new object name
    coords -- float triplets eg: [(-1.0, 1.0, 0.0), (-1.0, -1.0, 0.0)]
    """

    # Create new mesh and a new object
    me = bpy.data.meshes.new(ob_name + "Mesh")
    ob = bpy.data.objects.new(ob_name, me)

    # Make a mesh from a list of vertices/edges/faces
    me.from_pydata(coords, edges, faces)

    # Display name and update the mesh
    ob.show_name = True
    me.update()
    return ob

# Create the object
pc = point_cloud("point-cloud", [(0.0, 0.0, 0.0)])

# Link object to the scene
bpy.context.scene.objects.link(pc)
active collection
Source Link
p2or
  • 16.1k
  • 10
  • 87
  • 146
import bpy

def point_cloud(ob_name, coords):
    """Create point cloud object based on given coordinates and name.

    Keyword arguments:
    ob_name -- new object name
    coords -- float triplets eg: [(-1.0, 1.0, 0.0), (-1.0, -1.0, 0.0)]
    """

    # Create new mesh and a new object
    me = bpy.data.meshes.new(ob_name + "Mesh")
    ob = bpy.data.objects.new(ob_name, me)

    # Make a mesh from a list of vertices/edges/faces
    me.from_pydata(coords, [], [])

    # Display name and update the mesh
    ob.show_name = True
    me.update()
    return ob

# Create the object
pc = point_cloud("point-cloud", [(0.0, 0.0, 0.0)])

# Link object to the active collection
active_coll = bpy.context.view_layer.active_layer_collection.collection
active_coll.objects.link(pc)

# Alternatively Link object to scene collection
#bpy.context.scene.collection.objects.link(pc)
import bpy

def point_cloud(ob_name, coords):
    """Create point cloud object based on given coordinates and name.

    Keyword arguments:
    ob_name -- new object name
    coords -- float triplets eg: [(-1.0, 1.0, 0.0), (-1.0, -1.0, 0.0)]
    """

    # Create new mesh and a new object
    me = bpy.data.meshes.new(ob_name + "Mesh")
    ob = bpy.data.objects.new(ob_name, me)

    # Make a mesh from a list of vertices/edges/faces
    me.from_pydata(coords, [], [])

    # Display name and update the mesh
    ob.show_name = True
    me.update()
    return ob

# Create the object
pc = point_cloud("point-cloud", [(0.0, 0.0, 0.0)])

# Link object to the active collection
active_coll = bpy.context.view_layer.active_layer_collection.collection
active_coll.objects.link(pc)

# Alternatively Link object to scene collection
#bpy.context.scene.collection.objects.link(pc)
import bpy

def point_cloud(ob_name, coords):
    """Create point cloud object based on given coordinates and name.

    Keyword arguments:
    ob_name -- new object name
    coords -- float triplets eg: [(-1.0, 1.0, 0.0), (-1.0, -1.0, 0.0)]
    """

    # Create new mesh and a new object
    me = bpy.data.meshes.new(ob_name + "Mesh")
    ob = bpy.data.objects.new(ob_name, me)

    # Make a mesh from a list of vertices/edges/faces
    me.from_pydata(coords, [], [])

    # Display name and update the mesh
    ob.show_name = True
    me.update()
    return ob

# Create the object
pc = point_cloud("point-cloud", [(0.0, 0.0, 0.0)])

# Link object to the active collection
bpy.context.collection.objects.link(pc)

# Alternatively Link object to scene collection
#bpy.context.scene.collection.objects.link(pc)
2.8 Update, API link
Source Link
p2or
  • 16.1k
  • 10
  • 87
  • 146

FirstYou can pass a list of allvertex coordinates to Mesh.from_pydata(vertices, edges, faces) However, you also have to create a object andnew mesh as well as a mesh, after that you can add the vertex to itnew object datablock and link them together properly:

Blender 2.8x

#import namebpy

def point_cloud(ob_name, coords): 
 string for new """Create point cloud object based on given coordinates and name.
# 
 verts   Keyword arguments: 
 array of position ob_name -- new object name
    coords -- float triplets eg: [(-1.0, 1.0, 0.0), (-1.0, -1.0, 0.0)]
 
def create_Vertices (name, verts): """

    # Create new mesh and a new object
    me = bpy.data.meshes.new(name+'Mesh'ob_name + "Mesh")
    ob = bpy.data.objects.new(nameob_name, me)

    # Make a mesh from a list of vertices/edges/faces
    me.from_pydata(coords, [], []) 

    # Display name and update the mesh
    ob.show_name = True
    me.update()
    return ob

# Create the object
pc = point_cloud("point-cloud", [(0.0, 0.0, 0.0)])

# Link object to scene
the active collection
active_coll = bpy.context.view_layer.active_layer_collection.collection
active_coll.objects.link(pc)

# Alternatively Link object to scene collection
#bpy.context.scene.collection.objects.link(pc)

Blender 2.7x

import bpy

def point_cloud(ob_name, coords):
    """Create point cloud object based on given coordinates and name.

    Keyword arguments:
    ob_name -- new object name
    coords -- float triplets eg: [(-1.0, 1.0, 0.0), (-1.0, -1.0, 0.0)]
    """

    # Create new mesh and a new object
    me = bpy.data.meshes.new(ob_name + "Mesh")
    ob = bpy.data.objects.new(ob_name, me) 

    # Make a mesh from a list of vertices/edges/faces
    me.from_pydata(vertscoords, [], []) 

    # UpdateDisplay name and update the mesh 
 with new data ob.show_name = True
    me.update()
    return ob

# Create the object
pc = point_cloud("point-cloud", [(0.0, 0.0, 0.0)])

# Link object to the scene
bpy.context.scene.objects.link(pc)

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
    bpy.context.scene.objects.link(ob)
    me.from_pydata(verts, [], [])
    # Update mesh with new data
    me.update()
    return ob

You can pass a list of vertex coordinates to Mesh.from_pydata(vertices, edges, faces) However, you also have to create a new mesh as well as a new object datablock and link them together properly:

Blender 2.8x

import bpy

def point_cloud(ob_name, coords): 
    """Create point cloud object based on given coordinates and name.
 
    Keyword arguments: 
    ob_name -- new object name
    coords -- float triplets eg: [(-1.0, 1.0, 0.0), (-1.0, -1.0, 0.0)]
    """

    # Create new mesh and a new object
    me = bpy.data.meshes.new(ob_name + "Mesh")
    ob = bpy.data.objects.new(ob_name, me)

    # Make a mesh from a list of vertices/edges/faces
    me.from_pydata(coords, [], []) 

    # Display name and update the mesh
    ob.show_name = True
    me.update()
    return ob

# Create the object
pc = point_cloud("point-cloud", [(0.0, 0.0, 0.0)])

# Link object to the active collection
active_coll = bpy.context.view_layer.active_layer_collection.collection
active_coll.objects.link(pc)

# Alternatively Link object to scene collection
#bpy.context.scene.collection.objects.link(pc)

Blender 2.7x

import bpy

def point_cloud(ob_name, coords):
    """Create point cloud object based on given coordinates and name.

    Keyword arguments:
    ob_name -- new object name
    coords -- float triplets eg: [(-1.0, 1.0, 0.0), (-1.0, -1.0, 0.0)]
    """

    # Create new mesh and a new object
    me = bpy.data.meshes.new(ob_name + "Mesh")
    ob = bpy.data.objects.new(ob_name, me) 

    # Make a mesh from a list of vertices/edges/faces
    me.from_pydata(coords, [], []) 

    # Display name and update the mesh 
    ob.show_name = True
    me.update()
    return ob

# Create the object
pc = point_cloud("point-cloud", [(0.0, 0.0, 0.0)])

# Link object to the scene
bpy.context.scene.objects.link(pc)
Source Link
p2or
  • 16.1k
  • 10
  • 87
  • 146
Loading