i’m working on a uipanel button to vary a size of an object 10 times in a row and have them in succession, like an array but each cube has diff size. to do this i need access the duplicate object and have it resized, but how to access duplicate object?
i found this but it did not work with my code some reason
import bpy
class MESH_OT_Add_Array(bpy.types.Operator):
bl_label = "random duplicator 10"
bl_idname = "mesh.add_array"
def execute(self, context):
'''
bpy.ops.object.modifier_add(type='ARRAY')
bpy.context.object.modifiers["Array"].count = 10
for m in bpy.context.active_object.modifiers:
if m.type=='ARRAY':
bpy.ops.object.modifier_apply(modifier=m.name)
return {'FINISHED'}
'''
obj = bpy.data.objects.get("Cube")
dupObj = obj.copy()
print(dupObj.name)
bpy.data.scenes[0].objects.link(dupObj)
return {'FINISHED'}
class ULTIMATE_PT_Panel(bpy.types.Panel):
bl_label = "Ultimate Duplication"
bl_idname = "ULTIMATE_PT_Panel"
bl_space_type = 'VIEW_3D'
bl_region_type = 'UI'
bl_category = 'Ultimate Duplication'
def draw(self, context):
layout = self.layout
# col = layout.column()
row = layout.row()
row.operator("object.duplicate_move", icon="DUPLICATE")
row = layout.row()
row.operator("mesh.add_array", icon="MOD_ARRAY")
def register():
bpy.utils.register_class(ULTIMATE_PT_Panel)
bpy.utils.register_class(MESH_OT_Add_Array)
def unregister():
bpy.utils.unregister_class(ULTIMATE_PT_Panel)
bpy.utils.unregister_class(MESH_OT_Add_Array)
if __name__ == "__main__":
register()