if i want one object with 10 circles inside it, i can create first one, then enter edit mode of it, then create remain 9 circles, which seems like design mode programming.

how can i do this at once something like:

mes = bpy.data.meshes.new(name+"Mes")
obj = bpy.data.objects.new(name+"Obj", mes)
for i in (range(1..10):
    mes.primitive_circle_add(...)       # <- will not work ???

is from_pydata only allowed function for mesh object or there is a way to draw circle in it.

  • $\begingroup$ bpy.ops.mesh.primitive_circle_add(...) is what you were looking for in example above. $\endgroup$ – batFINGER Oct 1 '17 at 4:50
  • $\begingroup$ @batFINGER no, that line was just 'pseudocode', i was looking for your answer below :) thanks, it has everything i need, especially moving verts inside bmesh-geom i would not figure out myself. $\endgroup$ – Asain Kujovic Oct 1 '17 at 4:54
  • $\begingroup$ Just noticed you wanted concentrics, edited code in answer accordingly. Can also multiply scalar * v.co to scale coordinates. $\endgroup$ – batFINGER Oct 1 '17 at 5:25

Using bmesh

Suggest getting to know bmesh as soon as possible. There are a number of create primitive operators in bmesh.ops including bmesh.ops.create_circle(..)

import bpy
import bmesh
context = bpy.context
scene = context.scene
me = bpy.data.meshes.new("Circles")
obj = bpy.data.objects.new("Circles", me)
#new bmesh
bm = bmesh.new()
# load in a mesh

for i in range(1, 10):
    # create circle
    geom = bmesh.ops.create_circle(bm, 
                diameter=1 / i)
    verts = geom["verts"]
    # translate verts
    for v in verts:
        v.co.z += i / 4

# write back to mesh
# make context
scene.objects.active = obj
obj.select = True

Note there is a more involved example on bmesh API re circles

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