How to use the pyassimp.export function in pyassimp

To help you get started, we’ve selected a few pyassimp examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github robotlearn / pyrobolearn / pyrobolearn / utils / mesh.py View on Github external
def convert_mesh(from_filename, to_filename, library='pyassimp', binary=False):
    """
    Convert the given file containing the original mesh to the other specified format using the `pyassimp` library.

    Args:
        from_filename (str): filename of the mesh to convert.
        to_filename (str): filename of the converted mesh.
        library (str): library to use to convert the meshes. Select between 'pyassimp' and 'trimesh'.
        binary (bool): if True, it will be in a binary format. This is only valid for some formats such as STL where
          you have the ASCII version 'stl' and the binary version 'stlb'.
    """
    if library == 'pyassimp':
        scene = pyassimp.load(from_filename)
        extension = to_filename.split('.')[-1].lower()
        if binary:  # for binary add 'b' as a suffix. Ex: '.stlb'
            pyassimp.export(scene, to_filename, file_type=extension + 'b')
        else:
            pyassimp.export(scene, to_filename, file_type=extension)
        pyassimp.release(scene)
    elif library == 'trimesh':
        export_mesh(trimesh.load(from_filename), to_filename)
    else:
        raise NotImplementedError("The given library '{}' is currently not supported, select between 'pyassimp' and "
                                  "'trimesh'".format(library))
github robotlearn / pyrobolearn / pyrobolearn / utils / parsers / robots / mujoco_parser.py View on Github external
mesh_dirname = self._mesh_dirname

            # create filename with the correction extension (STL)
            basename = os.path.basename(filename)
            basename_without_extension = ''.join(basename.split('.')[:-1])
            # dirname = os.path.dirname(filename)
            # filename_without_extension = dirname + basename_without_extension
            # new_filename = filename_without_extension + '.stl'
            new_filename = mesh_dirname + '/' + basename_without_extension + '.stl'

            # if file does not already exists, convert it
            if not os.path.isfile(new_filename):

                # use pyassimp to
                scene = pyassimp.load(filename)
                pyassimp.export(scene, new_filename, file_type='stlb')
                pyassimp.release(scene)

                #
                # export_mesh(trimesh.load(filename), new_filename)

            return new_filename
        return filename
github robotlearn / pyrobolearn / pyrobolearn / utils / mesh.py View on Github external
Convert the given file containing the original mesh to the other specified format using the `pyassimp` library.

    Args:
        from_filename (str): filename of the mesh to convert.
        to_filename (str): filename of the converted mesh.
        library (str): library to use to convert the meshes. Select between 'pyassimp' and 'trimesh'.
        binary (bool): if True, it will be in a binary format. This is only valid for some formats such as STL where
          you have the ASCII version 'stl' and the binary version 'stlb'.
    """
    if library == 'pyassimp':
        scene = pyassimp.load(from_filename)
        extension = to_filename.split('.')[-1].lower()
        if binary:  # for binary add 'b' as a suffix. Ex: '.stlb'
            pyassimp.export(scene, to_filename, file_type=extension + 'b')
        else:
            pyassimp.export(scene, to_filename, file_type=extension)
        pyassimp.release(scene)
    elif library == 'trimesh':
        export_mesh(trimesh.load(from_filename), to_filename)
    else:
        raise NotImplementedError("The given library '{}' is currently not supported, select between 'pyassimp' and "
                                  "'trimesh'".format(library))