This repository contains a Python script to create a gif file from a STL file. The script will automatically center the STL for a better visualization.
Open a terminal and run the python script passing the STL filename with the -i
option as follow:
python STL-To-Gif.py -i inputfile
python STL-To-Gif.py -i inputfile -o outputfile
For those of you interested in changing the gif's properties, you have available the following options:
--nframes
: Amount of frames that the gif will use.--duration
: Duration of display of each frame.--path
: Folder in where the frames will be saved.
Sometimes the STL's position, angle, rotation axis,... are not the most desired ones for creating an appealing gif. For those cases, you have available the following options:
For those cases in which the STL model's original orientation is not the most desired one, the following options are available to change the orientation:
--rotation_angle
: Degrees to rotate the STL model.--rotation_axis
: Specify the rotation axis of the STL.
In below example the STL model was rotated 45° around the X axis.
Once the model is rotated as desired, sometimes we want to change the camera's point of view as the model will always rotate around the Z axis (looking straight at the image, the up direction). In order to change this, just pass the following option:
--elevation
: Elevation of the STL.
In below example the camera's elevation was modified to 20°.
--initangle
: Starting angle of the first frame.
--offset
: Displaces the center from which the STL will revolve.
In future versions I would like to add a GUI interface for fast checking the resulting gif as well as a faster algorithm to handle big STL files.
You should install the following:
- Python
- Matplotlib
- Numpy
- Numpy-stl
- imageio
The STL files used as an example were not created by me. Find below the corresponding creators:
- T-Rex skull: Created by 3P3D
- Pikachu: Created by FLOWALISTIK
- Charmander: Created by FLOWALISTIK
- Bulbasaur: Created by FLOWALISTIK
- Squirtle: Created by FLOWALISTIK