1
$\begingroup$

I don't like to always have to reduce the overly high vertices count on the primitives (no, really! 32 vertices for a circle which I'll subdivide a couple times anyway?).
Therefore, I used this script for a while to get rid of that.

# To be saved in
#    scripts/startup/
# with a .py file extension.

from bpy.props import IntProperty
from bpy.props import EnumProperty
from bpy.types import (
    MESH_OT_primitive_circle_add,
    MESH_OT_primitive_cone_add,
    MESH_OT_primitive_cylinder_add,
    MESH_OT_primitive_uv_sphere_add,
)

# Circle (12 vertices, no fill)
MESH_OT_primitive_circle_add.vertices = IntProperty(name="Vertices", default=12)
MESH_OT_primitive_circle_add.fill_type = EnumProperty(items=[('NOTHING', 'Nothing', 'Tooltip'), ('NGON', 'Ngon', 'Tooltip'), ('TRIFAN', 'Triangle Fan', 'Tooltip')], name="Fill Type")

# Cone (12 vertices, no fill)
MESH_OT_primitive_cone_add.vertices = IntProperty(name="Vertices", default=12)
MESH_OT_primitive_cone_add.end_fill_type = EnumProperty(items=[('NOTHING', 'Nothing', 'Tooltip'), ('NGON', 'Ngon', 'Tooltip'), ('TRIFAN', 'Triangle Fan', 'Tooltip')], name="Fill Type")

# Cylinder (12 vertices, no fill)
MESH_OT_primitive_cylinder_add.vertices = IntProperty(name="Vertices", default=12)
MESH_OT_primitive_cylinder_add.end_fill_type = EnumProperty(items=[('NOTHING', 'Nothing', 'Tooltip'), ('NGON', 'Ngon', 'Tooltip'), ('TRIFAN', 'Triangle Fan', 'Tooltip')], name="Fill Type")


# UV Sphere (24 segments, 12 rings)
MESH_OT_primitive_uv_sphere_add.segments = IntProperty(name="Segments", default=24)
MESH_OT_primitive_uv_sphere_add.ring_count = IntProperty(name="Rings", default=12)

I hardly put it together by gathering sparse information here and there.

And it worked great, until Blender 2.80 came out.
Now, due to heavy API changes it no longer works.

I'm banging my head through the web in search of information, but it seems to be very a well kept secret.

Hopefully, this topic is of some interest for someone else.

Update

I found these instructions to work in the console:

# Circle
bpy.ops.mesh.primitive_circle_add(vertices=12, fill_type='NOTHING', enter_editmode=False, location=(0, 0, 0))

# Cylinder
bpy.ops.mesh.primitive_cylinder_add(vertices=12, radius=1, depth=2, end_fill_type='NOTHING', enter_editmode=False, location=(0, 0, 0))

# Cone
bpy.ops.mesh.primitive_cone_add(vertices=12, radius1=1, radius2=0, depth=2, end_fill_type='NOTHING', enter_editmode=False, location=(0, 0, 0))

# UV Sphere
bpy.ops.mesh.primitive_uv_sphere_add(segments=24, ring_count=12, radius=1, enter_editmode=False, location=(0, 0, 0))

But they do not set the properties for the primitives.
Instead, they draw them immediately.
And this would be even worse: having to delete 4 primitives each time you load a new file.

$\endgroup$
  • 1
    $\begingroup$ Looks like access to these have been removed from bpy.types. Not sure if there is a way through RNA black magic. $\endgroup$ – Robert Gützkow Aug 5 '19 at 12:30
  • 1
    $\begingroup$ The furthest I got was bpy.ops.mesh.primitive_circle_add.get_rna_type().properties["vertices"].default, however that is read-only so you can't set the value with it. $\endgroup$ – Robert Gützkow Aug 5 '19 at 12:37

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.