5

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....

Marko Lustro
  • 231
  • 2
  • 5
  • 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. – sambler Oct 17 '17 at 11:40

1 Answers1

6

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.

sambler
  • 55,387
  • 3
  • 59
  • 192