# Updating cylinder's properties using a scipt

I created cylinders using the bpy.ops.mesh.primitive_cylinder_add() command (I used this example). How can I update their radius (or any other property) using python script, instead of deleting the objects and recreate them? I'm using those cylinders to display connection between areas in the brain, as part of an addon I'm implementing. I want to let the user to pick the radius of the cylinders (for rendering purposes), or to automatically change them according to the connections' strength (which may vary).

• Creation is usually viewed as a one way operation with no long term guarantees. Do you allow editing of the mesh such that the result is no longer recognizable to most people as a sphere? What is the larger picture of what you are trying to do? You may get more help by answering that question. – atomicbezierslinger Jan 27 '16 at 19:14
• My question is still the same above in the comments. I tend to think at this time I can not provide any insight to you. I do not understand your larger goal. Please place you work in the question rather than a link. Please state your experience with Python. – atomicbezierslinger Jan 28 '16 at 5:21
• The link is just for the code how I created the cylinder. My end users are going to work wit Blender. I changed the layout and added some buttons. One of the options is to create connections between areas in the brain. I want to let the users the option to change the cylinders properties (like radius) after they created them. Does it make more sense? – Noam Peled Jan 28 '16 at 16:15

An example using a custom property with an update method.

import bpy
from bpy.props import FloatProperty
context = bpy.context
scene = context.scene

def bond_strength(self, context):
self.scale.x = self.scale.y =  self.bond_strength
return None

# create a custom property on all objects
bpy.types.Object.bond_strength = FloatProperty(name="Strength",
default = 1.0,
precision = 4,
update=bond_strength)

# adds a slider to UI object properties panel. # would be in a custom Panel
if True: # only need to run this once
def show_strength(self, context):
self.layout.prop(context.object, "bond_strength")
bpy.types.OBJECT_PT_context_object.remove(show_strength) # put in unregister
bpy.types.OBJECT_PT_context_object.append(show_strength)

#create more
cyl = context.active_object  # newly created cylinder

for i in range(4):
cyl = cyl.copy()