1
$\begingroup$

I'm banging my head trying to find any documentation, but I can't seem to find anything about that matter.

Background:
I was sick of manually changing the default vertices for Circles, Cones and Cylinders to 12.

I found this script and it works just perfectly.

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

from bpy.props import IntProperty
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,
)

MESH_OT_primitive_circle_add.vertices = IntProperty(name="Vertices", default=12)
MESH_OT_primitive_cone_add.vertices = IntProperty(name="Vertices", default=12)
MESH_OT_primitive_cylinder_add.vertices = IntProperty(name="Vertices", default=12)
#MESH_OT_primitive_uv_sphere_add.segments = IntProperty(name="Segments", default=16)
#MESH_OT_primitive_uv_sphere_add.ring_count = IntProperty(name="Rings", default=8)

Problem:
Now, I'm still sick of having to change the default fill type to NOTHING.

I tried adding the following lines (one at a time, of course) to no avail:

MESH_OT_primitive_cone_add.vertices = StringProperty(name="End_Fill_Type", default='NOTHING')
MESH_OT_primitive_cone_add.vertices = IntProperty(name="End_Fill_Type", default=0)
MESH_OT_primitive_cone_add.vertices = StringProperty(name="Base_Fill_Type", default='NOTHING')
MESH_OT_primitive_cone_add.vertices = IntProperty(name="Base_Fill_Type", default=0)
MESH_OT_primitive_cone_add.vertices = StringProperty(name="Cap_Fill_Type", default='NOTHING')
MESH_OT_primitive_cone_add.vertices = IntProperty(name="Cap_Fill_Type", default=0)

I tried both with and without underscore (_).
And the same for Cylinder

Note:

I tried entering the following in a console window:

bpy.ops.mesh.primitive_cone_add(end_fill_type='NOTHING')

and also

bpy.ops.mesh.primitive_cylinder_add(end_fill_type='NOTHING')

and both worked flawlessly.

$\endgroup$
2
$\begingroup$

You can see the property names by hovering mouse above the field.

hover mouse to see python access names of many parts of UI

Note that you need to match this name in the first part of the script file before the =. The latter needs to define property in blender operator format. For the dropdown menu it's in fact enumerator type, not string. You can't really specify default value for enumerator but I found that this has the desired effect nonetheless. So the file should look like this (note you need to import EnumProperty in the beginning as well):

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,
)

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")
MESH_OT_primitive_cone_add.end_fill_type = EnumProperty(items=[('NOTHING', 'Nothing', 'Tooltip'), ('NGON', 'Ngon', 'Tooltip'), ('TRIFAN', 'Triangle Fan', 'Tooltip')], name="Fill Type")
MESH_OT_primitive_cylinder_add.end_fill_type = EnumProperty(items=[('NOTHING', 'Nothing', 'Tooltip'), ('NGON', 'Ngon', 'Tooltip'), ('TRIFAN', 'Triangle Fan', 'Tooltip')], name="Fill Type")
MESH_OT_primitive_cone_add.vertices = IntProperty(name="Vertices", default=12)
MESH_OT_primitive_cylinder_add.vertices = IntProperty(name="Vertices", default=12)

If you need to create certain type of geometry often you might as well copy the operator that creates it and store it in script file or python console where you can execute it. You can store all the properties you can edit in the side panel.

copy the lines to reproduce results quickly

Drag the top info bar down and right click to select and CTRL-C to copy the lines for quickly using them later. You can even make them their own operators, add them to menus or add keybinds to them.

$\endgroup$
  • $\begingroup$ THAAAAAAAAAAAANK YOOOOOOOOUUUUUUUUU!!!!!!!!!!! $\endgroup$ – Fantômas Apr 27 '16 at 15:16

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.