admesh

The ruby-admesh gem wraps the Admesh STL mesh manipulation tool CLI in a Ruby gem. It has the Admesh software packaged, so installation of Admesh it not necessary.


License
GPL-2.0+
Install
gem install admesh -v 0.1.0

Documentation

ruby-admesh ruby-admesh

The admesh gem wraps the Admesh STL mesh manipulation tool CLI in a Ruby gem.

Installation

The gem has the Admesh software packaged, so installation of Admesh it not necessary.

Add to Gemfile:

gem "admesh"

Run bundle install and require the gem:

require "admesh"

Perform file operations

Perform file operations by running Admesh.perform(file, options = {}). It uses the same options as the admesh executable, but remember to underscore all options names (eg. z_rotate instead of z-rotate). The options are not manipulated or validated, they will be sent to Admesh as-is.

When the command was successful, the output is returned as a string. When the command fails, the output is returned contained in a RuntimeError.

ADMesh supports the following options, grouped by type.

Mesh Transformation and Manipulation Options

   x_rotate: angle          # Rotate CCW about x-axis by angle degrees
   y_rotate: angle          # Rotate CCW about y-axis by angle degrees
   z_rotate: angle          # Rotate CCW about z-axis by angle degrees
   xy-mirror: true          # Mirror about the xy plane
   yz-mirror: true          # Mirror about the yz plane
   xz_mirror: true          # Mirror about the xz plane
   scale: factor            # Scale the file by factor (multiply by factor)
   translate: x,y,z         # Translate the file to x, y, and z
   merge: name              # Merge file called name with input file

Mesh Checking and Repairing Options

   exact: true              # Only check for perfectly matched edges
   nearby: true             # Find and connect nearby facets. Correct bad facets
   tolerance: tol           # Initial tolerance to use for nearby check = tol
   iterations: i            # Number of iterations for nearby check = i
   increment: inc           # Amount to increment tolerance after iteration=inc
   remove_unconnected: true # Remove facets that have 0 neighbors
   fill_holes: true         # Add facets to fill holes
   normal_directions: true  # Check and fix direction of normals (ie. CW, CCW)
   reverse_all: true        # Reverse the directions of all facets and normals
   normal_values: true      # Check and fix normal values
   no_check: true           # Don't do any check on input file

File Output Options

   write_binary_stl: name   # Output a binary STL file called name
   write_ascii_stl: name    # Output an ASCII STL file called name
   write_off: name          # Output a Geomview OFF format file called name
   write_dxf: name          # Output a DXF format file called name
   write_vrml: name         # Output a VRML format file called name

For more information about running admesh, please refer to the official documentation

Print help information

Admesh.help                 # Prints the same info as "admesh --help"