Skip to content
bsutton edited this page Oct 23, 2011 · 11 revisions

The 3DC library provides for the manipulation of common graphics file formats (STL, AMF) including:

  • rotation
  • position translations
  • unit conversion
  • merging
  • file format conversion

The 3DC library also provides a command line interface which supports all of the above functions.

Prerequisites

  • Java 1.6

Download

Download the 3dc.jar

Supported file formats

  • STL
  • STLB
  • Obj - limited
  • AMF

Running

To run 3DC from the command line type:

java -jar 3dc-1.0.jar

Command Line Arguments

3dc takes a series of command line arguments which essentially define the set of input files, the set of transformation to be applied to the input files and the final output file.

The simplest form of the command line is:

java -jar 3dc-1.0.jar -i input.stl -o output.stl

The above command would simply read the input.stl file and write it out to the file output.stl. This is actually a somewhat useful operation as some CAD applications output STL files which can't be read be all programs. 3dc is able to clean these files as it copies them.

Every time 3dc is invoked you MUST specify one or more input files and one output file. If you specify multiple input files all of the objects are combined and written out to the output file. The most useful form of this is when the output file is an AMF file as AMF supports 'multi-object' files with each object being able to specify a different material and/or colour.

java -jar 3dc-1.0.jar -i input1.stl -i input2.stl -o output.amf

The above command reads both of the input files and writes any contained objects to the resulting AMF file.

To apply a transformation to an input file add a set of transformation directives after the input file.

java -jar 3dc-1.0.jar -i input1.stl -r 90:0:0 -i input2.stl -t 10:0:0 -o output.amf

The above command reads the objects from input1.stl and rotates them 90 degrees around the X axis, the objects from input2.stl are read and translated +10 units along the X axis. The transformed objects from both sets of input files are then written to the output.amf file.

You can also apply multiple transforms to each input file.

java -jar 3dc-1.0.jar -i input1.stl -r 90:0:0 -t 5:10:100 -i input2.stl -o output.amf

The above command applies two transformations to input1.stl, input2.stl's object as simply read without any transformations being applied. Both sets of objects are then written out to output.amf.

The following example provides a more complex example of combining multiple files and applying a variety of transformations to each file.

java -jar 3dc-1.0.jar -v -i src/test/resources/cube.stl -u millimeter -material pla -colour red -i src/test/resources/kwartzlab.stl -u meter -material abs -r 0:0:0 -i src/test/resources/rook.amf -material pla -u micron -t 10:10:10 -r 180:0:180 -i src/test/resources/rook.stl -material pla -colour yellow -o src/test/resources/result.amf -u millimeter

Command Line reference

###-c | -colour Used by input files to assign a colour to the objects contained in the file. The output file must be able to support colour properties for this to have any meaning. Currently only AMF supports colour.

The colour option must come after the -i option.

e.g. java -jar 3dc-1.0.jar -i input.stl -c red -o output.amf

###-i | -input <inputfilename.ext> Defines an input file to be loaded and manipulated according to the arguments that follow after the filename.

e.g. e.g. java -jar 3dc-1.0.jar -i input.stl

-m | -material

Applies a specific material to all objects in the associated input file.The output file must be able to support material properties for this to have any meaning. Currently only AMF supports material.

e.g. java -jar 3dc-1.0.jar -i input.stl -m pla -o output.amf

-o | -output

Defines the name of the file that the transformed objects are to be written to. You cannot apply any transforms to the output file. The only valid switch after specifying the output file is the -unit switch.

e.g. java -jar 3dc-1.0.jar -i input.stl -u inch -o output.amf -u millimeter

-r | -rotation <x:y:x>

Applies a rotation to the objects in the associated input file. The rotation is done around an artificial axis at the geometric centre of combined objects in the file.

If multiple axis of rotation are specified then each is applied in order; x, y then z.

e.g. java -jar 3dc-1.0.jar -i input.stl -r 90:45:180 -o output.amf

-t | -translate <x:y:z>

Applies a geometric translation along the defined axis.

e.g. java -jar 3dc-1.0.jar -i input.stl -t 10:0:0 -o output.amf

###-v | -version Prints the version number of 3DC on startup.

-u | -units <micron|millimeter|meter|inch|feet>

Specifies the units of measure for either an input file or an output file. If no units of measure are specified on a file then millimeters are assumed. All input files are converted to the output files unit of measure.

e.g. java -jar 3dc-1.0.jar -i input.stl -u inch -o output.stl -u millimeter