I found many old information. Where is simple example to add all primitives (completly working example with actual blender)

I need put cylinder, and move it into specyfic location, seting scale and assign color and name. Im not using mesh, faces etc, I need only primitives like box or torus....

  • $\begingroup$ This site is more for single questions at a time, importing would be a different topic to creating primitives. See if this answer helps with importing. $\endgroup$
    – sambler
    Oct 17, 2017 at 11:40

1 Answer 1


There are several operators that add primitive objects to a scene, look at the reference for each to see all available options.

An example of adding several objects -

import bpy

for x in range(10):
    bpy.ops.mesh.primitive_cone_add(location=(x,0.0,1.0), radius1=0.5, radius2=0.1)
    bpy.ops.mesh.primitive_cube_add(location=(x,0.0,2.0), radius=0.5)
    bpy.ops.mesh.primitive_ico_sphere_add(location=(x,0.0,3.0), size=0.5)
    bpy.ops.mesh.primitive_monkey_add(location=(x,0.0,4.0), radius=0.5)

You can also find similar operators available when using bmesh, which is a better option when you want to edit mesh objects, or build more complex models.

Note that after you add an object using one of the primitive operators, it becomes the active object, that means you can get the object using bpy.context.active_object and make further adjustments after you have created it.

This answer gives an example of creating multiple materials and assigning them to different faces.

  • $\begingroup$ How put color to this primitoves? This is trouble because colors is less than objects. I need 4 colorb but objects have 100. Trouble is how create materials without objects. $\endgroup$ Oct 17, 2017 at 13:08
  • $\begingroup$ I have color in html #hexhexhex or in rgb in integer $\endgroup$ Oct 17, 2017 at 14:02
  • 1
    $\begingroup$ @MarkoLustro This answer is an example of creating a BI material. Cycles nodes takes a bit more. Blender takes rgb values as floats, that is 0.0-1.0 matches 0-255 so if you have red as 127 use 127/255 to get the float equivalent. You use int('BB', 16) to turn the hex into an int or together as int('BB',16)/255. $\endgroup$
    – sambler
    Oct 18, 2017 at 3:20
  • $\begingroup$ Yes , colors working, thanks. The trouble is how add this color to the scene and save it in 'F' mode (alvays in blender file) $\endgroup$ Oct 19, 2017 at 7:18
  • 1
    $\begingroup$ mat.use_fake_user = True - that property is common between all items that support a fake user. $\endgroup$
    – sambler
    Oct 19, 2017 at 17:12

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .