0
$\begingroup$

I can scale my model in Blender at export, and that works perfectly fine.

However, I need to do this automatically as I have many models which should all be scaled to 0.01

Can anybody tell me which values I need to change in the obj file to apply for example a scaling of 0.01?

$\endgroup$

2 Answers 2

1
$\begingroup$

Ok, I got it:

I simply go through each line, and if a line starts with "v ", I mulitply each of the 3 values with the desired scale.

It should be noted that a scale of 1 is "100%", a scale of 10 would be "1000%", etc.

$\endgroup$
0
$\begingroup$

Code for @tmighty solution would be something like this. Can confirm it works:

def rescale_obj(obj_path, obj_scaled_path, scale):
    with open(obj_path, 'r') as source:
        with open(obj_scaled_path, 'w') as target:
            for line in source:
                taget_line = line

                if(line.startswith('v ')):
                    coordinates = [float(coordinate) for coordinate in line.split(' ')[1:]]
                    rescaled = [c*scale for c in coordinates]
                    rescaled_as_str = " ".join([str(c) for c in rescaled])
                    taget_line = f'v {rescaled_as_str}\n'

                target.write(taget_line)
$\endgroup$

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .