# How to change the top radius of a truncated cone with Python?

My Blender version is 2.76. I used the python command

bpy.ops.mesh.primitive_cone_add(vertices=16, radius1=R1, radius2=R2, depth=L)

to create a truncated cone. In order to animate my scene, I need to increase or decrease the top radius (radius2) of the cone. How can I set its value from within my python script?

• Do you need to identify and select the rings via python, or just change their diameter? I mean does everything need to be automated via python from object creation to top ring animation? Or can anything be done manually? – Todd McIntosh Jun 13 '16 at 21:23
• Do you want to edit the parameter itself after creating the object? or scaling the top vertices would work for you? – Georges D Jun 13 '16 at 21:56
• Thanks, Todd McIntosh and Georges, for your questions. I do not know what you mean with "rings". I use the truncated cone as a whole mesh, and I want to vary its top radius2 between 0 and radius1 so that the truncated cone changes its shape between a pure cone and a cylinder – Klaus Vielhaber Jun 14 '16 at 15:30
• Given your new snippet of info re cone to cylinder edited answer. – batFINGER Jun 14 '16 at 19:09

Cylinder to Cone via shape key.

Here is a take on this using shape keys, Can't use 0 as the radius on the cone tip as it will not be able to be joined as shapes.

import bpy
context = bpy.context
scene = context.scene
# no active object
scene.objects.active = None
R1 = 4
R2 = 4
L = 10
# create cone
depth=L)
cone1 = scene.objects.active
# create opposite cone
depth=L)
cone1.select = True
# join as shapes
bpy.ops.object.join_shapes()
# remove cone1

context.object.data.shape_keys.key_blocks['Cone.001'].value = 1.0