databpy
  • Home
  • Attributes
  • API
  1. Objects
  2. create_pointcloud_object
  • Function reference
  • Attribute
    • named_attribute
    • store_named_attribute
    • remove_named_attribute
    • AttributeDomains
    • AttributeTypes
    • AttributeArray
  • Collections
    • create_collection
  • Objects
    • create_object
    • create_mesh_object
    • create_curves_object
    • create_pointcloud_object
    • create_bob
    • evaluate_object
    • BlenderObject
    • LinkedObjectError

On this page

  • create_pointcloud_object
    • Parameters
    • Returns
    • Examples
    • Notes
  1. Objects
  2. create_pointcloud_object

create_pointcloud_object

create_pointcloud_object(positions=None, name='PointCloud', collection=None)

Create a new Blender point cloud object.

This function creates a point cloud by first creating a mesh with vertices at the specified positions, then converting it to a point cloud using Blender’s convert operator.

Parameters

Name Type Description Default
positions np.ndarray The point positions as a numpy array with shape (N, 3). If None, creates an empty point cloud object. Defaults to None. None
name str The name of the object. Defaults to ‘PointCloud’. 'PointCloud'
collection bpy.types.Collection The collection to link the object to. Defaults to None. None

Returns

Name Type Description
Object The created point cloud object.

Examples

import numpy as np
from databpy import create_pointcloud_object

# Create point cloud with 100 random points
positions = np.random.random((100, 3))
pc_obj = create_pointcloud_object(positions, name="MyPC")
print(len(pc_obj.data.points))  # 100

Notes

This function works by creating a temporary mesh and converting it to a point cloud using bpy.ops.object.convert(target='POINTCLOUD').