I have a small script to re-size an object while keeping its proportions. There's no problem while using it in the text editor - just write either x or y or z in the field
scale, then enter the new dimension in the field
new_dim, and that's all, the object is re-sized keeping its proportions.
The idea is to insert it into the UI context and create a panel proposing to change the values of x, y and z.
This panel would be the same as the existing dimension panel, but this one would use the script to keep the proportions of the object based on the value entered in x, y or z.
To create the UI menu is not a problem but I can not generate the 3 fields - X, Y and Z - with the opportunity to enter a value.
How can I do it?
Here is the script in question:
i = 2 ob = bpy.context.active_object d = ob.dimensions x = d y = d z = d scale = "x" #value chosen by the user: either x, y or z. new_dim = 3 #value set by the user number.value set by the user. if( scale == "x"): indice = 0 elif( scale == "y"): indice = 1 else: indice = 2 old_dim = d[indice] factor = new_dim / old_dim scale_x = ob.scale scale_y = ob.scale scale_z = ob.scale ob.scale = scale_x * factor ob.scale = scale_y * factor ob.scale = scale_z * factor