Filter Scripts

Introduction

PyMeshLab supports “Filter Scripts”: scripts generated by MeshLab that allow to automatically execute a list of filters with user-defined parameters. These scripts were supported by meshlabserver, the tool used for MeshLab batch processing. To generate a filter script using MeshLab is quite easy: after you applied all the desired filters, go to “Filters -> Show current filter script”. A dialog containing the list of all the applied filters will appear. You can edit the order of the filters and their paramters, and then save the filter script. Then, you can use the saved script to apply the list of filters to other meshes using PyMeshLab.

Apply a Filter Script

In PyMeshLab, every MeshSet object stores internally a filter script: you can always save its script that will contain all the applied filters with their parameters:

import pymeshlab
ms = pymeshlab.MeshSet()
ms.load_new_mesh('input.obj')
ms.apply_filter('laplacian_smooth', stepsmoothnum=10)
#apply some other filters....

#.. and then save the script
ms.save_filter_script('my_script.mlx')

You can then apply all the filters of the script to another input mesh:

import pymeshlab
ms = pymeshlab.MeshSet()
ms.load_new_mesh('another_input.obj')
ms.load_filter_script('my_script.mlx')
ms.apply_filter_script()
ms.save_current_mesh('result.obj')

The MeshSet class provides methods that allow to load, save, clear and print a Filter Script. Check the documentation of the MeshSet class for more details.

For further details check the Filter Script: load and apply and Filter Script: create and save tutorials.