1
$\begingroup$

This: create mesh then add vertices to it in python (see snippet below) used mesh.from_pydata(verts, edges, faces).

I would like to just create a mesh of vertices, no edges, no faces.

I would think I would delete:

edges = []
faces = [[0, 1, 2, 3]]

But what would I replace mesh.from_pydata(verts, edges, faces) with?

import bpy

mesh = bpy.data.meshes.new("myBeautifulMesh")  # 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 = [( 1.0,  1.0,  0.0), 
         ( 1.0, -1.0,  0.0),
         (-1.0, -1.0,  0.0),
         (-1.0,  1.0,  0.0),
         ]  # 4 verts made with XYZ coords
edges = []
faces = [[0, 1, 2, 3]]

mesh.from_pydata(verts, edges, faces)
$\endgroup$
1
  • $\begingroup$ mesh.from_pydata(verts, [ ] , [ ] ) $\endgroup$
    – relaxed
    Dec 27, 2021 at 12:26

1 Answer 1

2
$\begingroup$

This should work (edited to add - I just tried it, it works):

vertices = [( 1.0,  1.0,  0.0), 
            ( 1.0, -1.0,  0.0),
            (-1.0, -1.0,  0.0),
            (-1.0,  1.0,  0.0),
           ]
edges = []
faces = []
new_mesh = bpy.data.meshes.new('new_mesh')
new_mesh.from_pydata(vertices, edges, faces)

See How to create mesh through the Blender Python API, which describes how to create a mesh of just a vertex, no edges or faces.

$\endgroup$

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.