Skip to content

Instantly share code, notes, and snippets.

@ganzuul
Last active March 7, 2021 17:52
Show Gist options
  • Save ganzuul/114bee8cb958f9544cdc8bfb5d570dc6 to your computer and use it in GitHub Desktop.
Save ganzuul/114bee8cb958f9544cdc8bfb5d570dc6 to your computer and use it in GitHub Desktop.
Blender qhull stuff
import bpy
import numpy as np
from scipy.spatial import Delaunay
points = np.random.rand(20,3)
tri = Delaunay(points)
mesh = bpy.data.meshes.new("myUnrulyMess") # add the new mesh
obj = bpy.data.objects.new(mesh.name, mesh)
col = bpy.data.collections.get("Collection")
col.objects.link(obj)
bpy.context.view_layer.objects.active = obj
verts = [list(v) for v in points]
edges = []
faces = np.ndarray.tolist(tri.simplices)
mesh.from_pydata(verts, edges, faces)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment