How to use the command "assimp" (with examples)
The “assimp” command-line client is part of the Open Asset Import Library (assimp). It allows users to load and convert 3D file formats. With support for over 40 import formats and exporting to several popular 3D formats, assimp is a powerful tool for working with 3D models.
Use case 1: List all supported import formats
Code:
assimp listext
Motivation: Listing all the supported import formats can be helpful when you need to know if a specific format is supported by assimp.
Explanation: The command “assimp listext” displays a list of all supported import formats.
Example output:
Supported file extensions:
3d, 3ds, ac, ac3d, acc, ase, b3d...
Use case 2: List all supported export formats
Code:
assimp listexport
Motivation: Knowing the supported export formats is useful when you want to convert a 3D model to a specific format.
Explanation: The command “assimp listexport” shows a list of all supported export formats.
Example output:
Supported export formats:
3d, 3ds, ac, ac3d, ase, assbin, assxml...
Use case 3: Convert a file to one of the supported output formats, using the default parameters
Code:
assimp export input_file.stl output_file.obj
Motivation: Converting a 3D model to a different format can be necessary when the target application or tool only supports certain file types. The example command converts an STL file (“input_file.stl”) to an OBJ file (“output_file.obj”).
Explanation: The “assimp export” command converts the input file to the specified output format using the default parameters. In this case, the STL file is converted to an OBJ file.
Example output:
Exporting 'input_file.stl' to 'output_file.obj'... [SUCCESS]
Use case 4: Convert a file using custom parameters
Code:
assimp export input_file.stl output_file.obj parameters
Motivation: When converting a file, sometimes there are specific parameters or options that can be set to control the conversion process. This use case demonstrates how to provide custom parameters.
Explanation: The command “assimp export” is used to convert the input file to the specified output format. In this example, custom parameters can be defined by replacing “parameters” with the desired options. Referencing the “dox_cmd.h” file in assimp’s source code provides available parameters.
Example output:
Exporting 'input_file.stl' to 'output_file.obj' with custom parameters... [SUCCESS]
Use case 5: Display a summary of a 3D file’s contents
Code:
assimp info path/to/file
Motivation: Obtaining a summary of a 3D file’s contents can be useful for understanding its structure and properties without having to open it in a separate application.
Explanation: The “assimp info” command displays a summary of the specified 3D file’s contents, including information about meshes, materials, animations, and more.
Example output:
Summary of 'path/to/file':
Meshes: 2
Materials: 1
Animations: 0
Textures: 0
...
Use case 6: List all supported subcommands (“verbs”)
Code:
assimp help
Motivation: When first starting with the assimp command-line client, it can be helpful to see a list of all available subcommands to understand the full range of functionality.
Explanation: The “assimp help” command displays a list of all supported subcommands or “verbs” that can be used with the assimp command-line client.
Example output:
Available subcommands:
export: Convert a 3D file to another format
info: Display information about a 3D file
listext: List all supported import formats
listexport: List all supported export formats
...
Use case 7: Get help on a specific subcommand
Code:
assimp subcommand --help
Motivation: When you need assistance or additional information about a specific subcommand, using the “–help” option will provide the necessary help documentation.
Explanation: By replacing “subcommand” with the desired subcommand from the available list, the command “assimp subcommand –help” displays the help documentation for that specific subcommand.
Example output:
Help for 'subcommand':
Usage: assimp subcommand [OPTIONS] [args]...
...
Conclusion:
The “assimp” command-line client is a versatile tool for working with 3D models. With its support for numerous import and export formats, along with functionalities such as conversion, information display, and more, it provides a wide range of capabilities for 3D file manipulation and exploration.