Project

stl

0.01
No commit activity in last 3 years
No release in over 3 years
Read and write STL files
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

~> 1.5
>= 0

Runtime

 Project Readme

STL

Build Status Gem Version

Read, write and manipulate both ASCII and binary STL files

Installation

Add this line to your application's Gemfile:

gem 'stl'

And then execute:

$ bundle

Or install it yourself as:

$ gem install stl

Usage

require 'stl'

stl = STL.read('my_awesome.stl')
stl.faces			    # => [Face, ...]

To convert an ASCII STL file to a binary file:

STL.read('ascii.stl').write('binary.stl', :binary)

Writing binaries files is actually the default, so you can also leave off the last argument to write, if you want.

STL.read('ascii.stl').write('binary.stl')

You can also convert binary files to ASCII.

STL.read('binary.stl').write('ascii.stl', :ascii)

Converting between ASCII and binary

There's an easier way to do a format conversion, and it doesn't require that you know the original format. Simply use the convert method, and the format of the input will be toggled (ASCII to binary, or binary to ASCII). The converted filename will be the same as the original, but with '-ascii' or '-binary' appended, as appropriate.

STL.convert('ascii.stl')	# => ascii-binary.stl
STL.convert('binary.stl')	# => binary-ascii.stl

License

Copyright 2014 Brandon Fosdick bfoz@bfoz.net and released under the BSD license.