transform shapes by setting rules...help

hi all
I’m fresh in python(don’t know well),I try to set shape transform follow my rules,but I don’t know how?
example:

bpy.ops.mesh.primitive_cube_add(location=(0, 0, 1), rotation=(0, 0, 0))
bpy.ops.object.duplicate()
bpy.ops.transform.translate(value=(0.5,-3,0))
bpy.ops.transform.resize(value=(2,-5,1))

bpy.ops.object.duplicate()
bpy.ops.transform.translate(value=(5.5,4,0))
bpy.ops.transform.rotate(value=(pi/2,),axis=(0,0,-1))

bpy.ops.object.duplicate()
bpy.ops.transform.translate(value=(6,1,0))
bpy.ops.transform.resize(value=(0.2,0.5,0.8))

bpy.ops.object.duplicate()
bpy.ops.transform.translate(value=(-12.5,-11.4,0))
bpy.ops.transform.resize(value=(1,1.4,1))

how can I set the rules such as r01…r(n+1),and I can pick the object transform?
anyone can help?
thanks

What is r01 ??

You mean, you want to have a set of rules and want to apply rule nr i to an object of your choice?


import bpy

def rul1(transval,sizeval):    

    bpy.ops.object.duplicate()
    bpy.ops.transform.translate(value=(transval))
    bpy.ops.transform.resize(value=(sizeval))
rul1((0,0,0),(1,3,2))

works on the ACITVE object! (Bl 2.61)

Then if elif else to chose the right function with analogue built other ones

sorry, my bad

import bpy,math
from math import pi

#set basicshape
bpy.ops.mesh.primitive_cube_add(location=(0, 0, 1), rotation=(0, 0, 0))
#rule01
bpy.ops.object.duplicate()
bpy.ops.transform.translate(value=(0.5,-3,0))
bpy.ops.transform.resize(value=(2,-5,1))
#rule02
bpy.ops.object.duplicate()
bpy.ops.transform.translate(value=(5.5,4,0))
bpy.ops.transform.rotate(value=(pi/2,),axis=(0,0,-1))
#rule03
bpy.ops.object.duplicate()
bpy.ops.transform.translate(value=(6,1,0))
bpy.ops.transform.resize(value=(0.2,0.5,0.8))
#rule04
bpy.ops.object.duplicate()
bpy.ops.transform.translate(value=(-12.5,-11.4,0))
bpy.ops.transform.resize(value=(1,1.4,1))

I follow your code but it shows NameError:name ‘rull’ is not defined in the system console…
have I lost something…?

it is rul1 (ONE!)

Just used copy paste (from above) and worked without error!

Ha!
sorry about my bull eye @@