1
$\begingroup$

I am new to blender. I have been looking into a github code, and trying to understand the operations. I am confused about the blender scaling operation.

This is the code for scaling:

def __scale(self, name, size):
    obj = bpy.data.objects[name]
    for dim in range(3):
        obj.scale[dim] = size

def __ensureList(self, inp):
    if type(inp) != list:
        inp = [inp]
    return inp

def resize(self, names, size, dim=0):
    names = self.__ensureList(names)
    if type(names) == str:
        names = [names]
    for name in names:
        obj = bpy.data.objects[name]
        obj.dimensions[dim] = size
        scale = obj.scale[dim]
        self.__scale(name, scale)

To scale, I execute the following command: blender.resize([obj_name], 2.7)

When I print the min, max and mean of the 3D points before and after scaling the results are:

before scaling:
min_x: -0.20754599571228027, max_x: 0.20533299446105957, mean_x: 0.0007154246070189982.
min_y: -0.1282069981098175, max_y: 0.1692579984664917, mean_y: 0.0012065420240592241.
min_z: -0.46883198618888855, max_z: 0.3920080065727234, mean_z: -0.000768613462913994.

after scaling:
min_x: -1.3572359085083008, max_x: 1.342764139175415, mean_x: 0.004678481022643731
min_y: -0.8384028077125549, max_y:1.1068536043167114, mean_y: 0.007890116447166636
min_z: -3.065901517868042, max_z: 2.5635154247283936, mean_z: -0.005026305425451572

A scaling of 2.7 along each dimension is resulting into a scale of approx 6.55 along each dimension. Can someone please explain the math behind this scaling. I mean if there is a point X(x,y,z) before scaling then what would be X after scaling ?

I am asking this question as I am not able to understand the post: How does scaling work in Blender, *exactly*?

Thanks, and would appreciate any help in understanding this.

Some edits based on suggestions from the comments:

Min max mean are numpy.min(), numpy.max(), numpy.mean(). I loop over the mesh vertices (obj.data.vertices), and add the vertex.co to a numpy array. and the test object is a mesh.

$\endgroup$
12
  • $\begingroup$ Could you indicates how min/max are calculated here? using world matrix? What is the test object? $\endgroup$ – lemon Sep 26 '20 at 20:02
  • $\begingroup$ Min max mean are numpy.min(), numpy.max(), numpy.mean(). I loop over the mesh vertices (obj.data.vertices), and add the vertex.co to a numpy array. and the test object is a mesh. $\endgroup$ – Shivam Duggal Sep 26 '20 at 20:13
  • $\begingroup$ obj.data.vertices coordinates are not supposed to change when scaling... so are you using matrix_world? $\endgroup$ – lemon Sep 26 '20 at 20:16
  • $\begingroup$ bpy.ops.object.transform_apply(scale=True) I do this before printining the vertices after applying scaling $\endgroup$ – Shivam Duggal Sep 26 '20 at 20:22
  • $\begingroup$ OK, I think you should indicate all these in the question to make it understandable. Though, from the mesh you used where the 6.5 ratio comes from? $\endgroup$ – lemon Sep 26 '20 at 20:24

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.