This might fall into the “you don’t need that” category, but knowing this may payoff in the future. I’m using a script to make a bunch of planes. I want to resize each plane before exiting the loop. Tried two methods, one works fine (before I name the variable) while the other fails (named variable) despite the ‘rotation_Euler’ working. I must be mixing up types. ‘rotation_Euler’ seems to be a Basic Object Operation reference by ‘bpy.types.Object’ which is right there in the assignment of the object to the name =‘o’ but the transform uses the reference ‘bpy.ops.transform’
How do I correctly assign a variable name such that I can do the transform?
#default values
defaultSquareSize = 1
griddivs_Y = 4
griddivs_X = 4
def draw_grid(W, H, box):
while H != 0:
wTest = W
while wTest != 0:
x = defaultSquareSize * (wTest - 1)
y = defaultSquareSize * (H - 1)
creating the plane works just fine
bpy.ops.mesh.primitive_plane_add(size=1, enter_editmode=False, align='WORLD', location=(x, y, 0))
resizing the plane works just fine
bpy.ops.transform.resize(value=(padding, padding, 1))
creating a named variable for the object isn’t an issue
o = bpy.context.active_object
#o = bpy.context.object
rotating the object using its variable name works fine
o.rotation_euler[2] = radians(20)
transform throws an AttributeError: ‘Object’ object has no attribute ‘transform’
o.transform.resize(value=(padding, padding, 1))
wTest -= 1
H -= 1
draw_grid(griddivs_X, griddivs_Y, defaultSquareSize)