3

I have an .stl file and I want to write a python script to scale if. So for example, if I have a file with a cube of dimensions 2x2x2mm, and I have my scale set to 10, the script should spit out an stl file with a cube of dimensions 20x20x20mm.

I searched and found numpy-stl library for modifying stl files. However, I can't seem to find any function that scales an .stl. Can someone point me in the right direction as what to use?

Umar Dastgir
  • 688
  • 9
  • 25

2 Answers2

1

I know this is an old question, but you should be able to directly modify the mesh.x, mesh.y and mesh.z attributes to accomplish this.

Andrew
  • 163
  • 8
1

I also stumbled across this post while trying to get an answer to the same problem. I assume you are using numpy-stl.

My solution was to create a rotation matrix R using the scaling parameter instead of rotation angles and then use mesh.rotate_using_matrix(R,point=centroid).

Seems to work for me.