Script to edit Cylinder sides after creation

I find myself often frustrated with Blender when I model multiple cylindric Intersections.
By the time you simply move an object or scale it you dont get access to alter the sides any more unless you delete and create a new one.
With complex objects this becomes really cumbersome.
I figured out that working with nurbs paths can somewhat make it easier, however the problem with that approach is that a.) booleans dont work unless conversion takes place and b) arbitrary sides are still not possible.
To be honest I only need this when working with cylinders.

Is it possible to fix that shortcoming with a script?
Apparently this was even planned as a feature for 2.5x https://wiki.blender.org/index.php/Dev:2.5/Source/Development/Proposals/Editable_Object_Parameters

The dilemma is that after creation, once you move, rotate etc. eg. a cylinder you can no longer alter the sides. I see why you are not allowed to do that once you entered edit-mode but the current restrictions seem superimposed to me. This behavior makes block outs a pain to do. Is there a way to counter that with a script?

Bump because this is important

Bump because this is important

I started off writing a post to explain why this isn’t possible, but then I started thinking about it a bit more.

if you start with a cylinder, and you don’t rotate anything in edit mode, this should work:

import bpy

v=64 #number of vertices, change this value as needed!


ob=bpy.context.active_object
r=ob.dimensions[0]/2
h=ob.dimensions[2]
loc=ob.location
rot=ob.rotation_euler
lay=ob.layers
bpy.ops.mesh.primitive_cylinder_add(vertices=v, radius=r, depth=h, view_align=False, enter_editmode=False, location=loc, rotation=rot, layers=lay)



before:


after:


Also, note that it creates a new cylinder, matching location, rotation and the current layer the selected cylinder is on, it doesn’t touch materials or anything like that, all it does is recreate the cylinder with more vertices. It doesn’t even delete the existing cylinder, though that could be added in.

Ok, on further tweaking, I have improved the script to handle multiple objects, delete old objects, and I even packaged it as an addon.

you can download the .py file here: https://drive.google.com/drive/folders/0BzxL5g-rNY2pYnlfRmVFM09QeFU?usp=sharing

Here is the code:

bl_info = {    "name": "Recreate Cylinders",
    "author": "Sterling Roth",
    "version": (0,1),
    "blender": (2, 78, 0),
    "location": "Spacebar Search > \'re_cylinder\'",
    "description": "Recreates cylinders with new vertex count",
    "warning": "Only works on primitive cylinders",
    "wiki_url": "",
    "category": "Mesh",
    }


import bpy


def re_cyl(verts):


    for i in bpy.context.selected_objects: 
        r=i.dimensions[1]/2
        h=i.dimensions[2]
        loc=i.location
        rot=i.rotation_euler
        lay=i.layers
        bpy.context.scene.objects.unlink(i)
        bpy.data.objects.remove(i)
        bpy.ops.mesh.primitive_cylinder_add(vertices=verts, radius=r, depth=h, view_align=False, enter_editmode=False, location=loc, rotation=rot, layers=lay)


    return




from bpy.props import IntProperty




class MESH_OT_re_cylinder(bpy.types.Operator):
    """Add a simple box mesh"""
    bl_idname = "mesh.re_cylinder"
    bl_label = "Recreate Cylinder"
    bl_options = {'REGISTER', 'UNDO'}


    vertices = IntProperty(
            name="Vertices",
            description="Vertices",
            min=3, max=128,
            default=16,
            )


    def execute(self, context):
        re_cyl(self.vertices)
        return {'FINISHED'}




def menu_func(self, context):
    self.layout.operator(MESH_OT_re_cylinder.bl_idname, icon='MESH_CYLINDER')




def register():
    bpy.utils.register_class(MESH_OT_re_cylinder)
    bpy.types.INFO_MT_mesh_add.append(menu_func)




def unregister():
    bpy.utils.unregister_class(MESH_OT_re_cylinder)
    bpy.types.INFO_MT_mesh_add.remove(menu_func)


if __name__ == "__main__":
    register()


    # test call
    bpy.ops.mesh.re_cylinder()



Let me know how that works for you, I’m no wizard, but I can do some debugging.

it works both ways too, so you can reduce the amount of verts if needed. works great for doing LOD versions:


Hi SterlingRoth,

can you update this script for Blender 2.83 please? Thanks