Skip to content

DAguirreAg/STL-to-gif

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

STL-to-Gif

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.

Input stl file Output gif file

How to use

Basics

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

Modifying the gif

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.

Gif with default frame duration Gif with frame duration of 0.2s

Advanced

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:

Rotating the STL model

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.

Gif with default rotation Gif with rotation of 45° around X axis

Changing the point of view

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°.

Gif with default elevation Gif with elevation of 20°

Other options
  • --initangle: Starting angle of the first frame.

Initial frame with default initial angle Initial frame with initial angle of 30°

  • --offset: Displaces the center from which the STL will revolve.

Gif with default offset Gif with offset of [100,100,0]

Future functionalities

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.

Requirements

You should install the following:

  • Python
  • Matplotlib
  • Numpy
  • Numpy-stl
  • imageio

Attributions

The STL files used as an example were not created by me. Find below the corresponding creators:

Releases

No releases published

Packages

No packages published

Languages