In Blender Python I can add a lamp by doing the following:

DataBlock = bpy.data.lamps.new(name='HemiA', type='HEMI')
ObjHandle = bpy.data.objects.new(name='HemiA', object_data=DataBlock)

I want to do the same for mesh primitives such as Suzanne. There is an operator for this: bpy.ops.mesh.primitive_monkey_add(), however there doesn't seem to be any way to create a mesh primitive data block.


I am not sure if there are functions which return mesh primitives as a data block in the Blender API. But you can create a Suzanne data block by using a bmesh and bmesh.ops.create_monkey(bm, matrix) which you can then convert to a mesh data block

import bpy
import bmesh

bm = bmesh.new()

# Create mesh data block from bmesh
mesh = bpy.data.meshes.new('Mesh')

# Create object and link object to scene
obj = bpy.data.objects.new('Object', mesh)
| improve this answer | |

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.