For the last few months it’s been possible to use Meshlab filters directly from Blender Python, so I thought I’d post a “how to”
To use meshlab filters on Blender meshes
Details are at:
You first need to install pymeshlab
You can do this from the Blender scripting workspace in Blender 2.92
BUT you have to have admininistor priviledges so for Windows users
JUST THIS ONCE open Blender by R-clicking on it in the start menu and select"Run as Administrator"
Open up the System Console (under the Window menu)
Then paste the following into the scripting workspace and run it
import subprocess import sys import os # path to python.exe python_exe = os.path.join(sys.prefix, 'bin', 'python.exe') # upgrade pip subprocess.call([python_exe, "-m", "ensurepip"]) subprocess.call([python_exe, "-m", "pip", "install", "--upgrade", "pip"]) # install required packages subprocess.call([python_exe, "-m", "pip", "install", "pymeshlab"]) print("DONE")
Now exit Blender and restart it normally
After restart you can import meshlab using Blender Python and pass it meshes and run filters on them without having to save and load it back and forth as a file
The following is a simple script to check it’s working.
Output will appear in the System Console window (not the main Blender Python window)
Also for more information see:
import pymeshlab print("\n\n") pymeshlab.print_pymeshlab_version() print("\n\n") filters = pymeshlab.filter_list() print("AVAILABLE FILTERS ARE") for f in filters: print(f) print("\n\n") print("SPECIFIC FILTER PARAMETERS can be listed for each filter, eg:-") print(">>> pymeshlab.print_filter_parameter_list('discrete_curvatures')") pymeshlab.print_filter_parameter_list('discrete_curvatures')
For instruction on the process of strategy to load a blender mesh in to meshlab see the tutorial
Incidentally when I import pymeshlab I get the following error in the Blender python console but not in the System console, and it seems to work fine (so I just ignore it)
Warning: Unable to load the following plugins:
- filter_sketchfab.dll: filter_sketchfab.dll does not seem to be a Qt Plugin.*
Cannot load library C:…\filter_sketchfab.dll: The specified module could not be found.