mesh2img.py is a Python script for Blender that converts STL and PLY mesh files into images.
blender -P /path/to/mesh2img.py
to execute. See Usage below for more details.# Don't do this
$ python mesh2img.py # doesn't work
Because this Python script is not meant to be called directly, but rather by Blender's built-in Python interpreter, you must execute the script like this:
/path/to/blender -b -P /path/to/mesh2img.py -- [mesh2img.py arguments here]
-b
flag will tell Blender not to launch the user interface and operate only here on the command line.-P
flag gives Blender a path to a Python script. That's what this is!--
in the middle tells Blender to not look at the rest of the flags. They're only for mesh2img.py at this point.mesh2img.py
arguments are covered belowAfter this runs, each mesh file will have a PNG in the same folder with the same name and _200
appended to it.
blender -b -P mesh2img.py -- --paths /all/my/meshes_folder --dimensions 200
blender -b -P mesh2img.py -- --paths /some/mesh/file.stl --dimensions 200 800,600 2048 -i jpg
blender -b -P mesh2img.py -- --paths /some/mesh/file.stl --dimensions 300 -m gold
blender -b -P mesh2img.py -- --paths /half/my/meshes "/other/meshes folder" \
--dimensions 200 -o "/some/output/folder/{exec_time}/{basename}_{width}.{ext}"
blender -b -P mesh2img.py -- --help
Several functions and the Mesh2Img class can be imported from this script into your own Python scripts. Just place this script in the same directory as your script or in the 2.XX/python/lib
folder of your Blender directory.
from mesh2img import delete_object_by_name, Mesh2Img, scale_mesh
0.1
MIT