Can't Add Platonic Solids in Blender via Script After watching the following tutorial, I thought I was going to customize it a bit and add a dodecahedron in the place of the ico sphere.

Tutorial that I followed
https://www.youtube.com/watch?v=F-cgCXg7Z3o

As mentioned in the tutorial, I found out via the console, that to add a dodecahedron, Blender runs the following command:

bpy.ops.mesh.primitive_solid_add(source='12')


So below was my best guess at implementing it and it doesn't work. Any idea how I'd go about doing this?

import bpy
from bpy import context
from math import sin, cos, radians

primitive_add = bpy.ops.mesh.primitive_solid_add

# get cursor loc - Script Modified by SardiPax
cursor = context.scene.cursor_location

radialdist = 2.0

xsize = 0.15
ysize = 0.15
zsize = 0.15

theta = 0.0
pi_over_8 = 6.28 / 16.0

levels = -10
maxlevels = 10
divi = 2.0
inci = 0.25

while levels &lt; maxlevels:

    while theta &lt; 6.28:
           x = cursor.x + (radialdist-(levels+ 2*cos (theta+levels/divi))) * cos (theta-levels/divi)
           y = cursor.x + (radialdist-(levels+ 2*sin (theta-levels/divi))) * sin (theta-levels/divi)
           z = cursor.z+levels
           bpy.ops.mesh.primitive_solid_add(source='12',location=(x, y, z))

           bpy.ops.transform.resize(value=(xsize* cos (theta-levels/divi), ysize* cos (theta-levels/divi),  zsize* cos (theta-levels/divi)), constraint_axis=(False, False, False), constraint_orientation='GLOBAL', mirror=False, proportional='DISABLED', proportional_edit_falloff='SMOOTH', proportional_size=1, snap=False, snap_target='CLOSEST', snap_point=(0, 0, 0), snap_align=False, snap_normal=(0, 0, 0), texture_space=False, release_confirm=False)
           theta += pi_over_8

    theta = 0.0
    levels += inci

radialdist = 1.0


Also at: https://gist.github.com/robksawyer/93597658ccc75fba324e

I'm using the following addon:
https://github.com/jaredly/blender-addons/blob/master/add_mesh_solid.py
first you have to add the add mesh: Extra Objects...



also, first try with

bpy.ops.mesh.primitive_solid_add(source='12')


best