Welcome! Log In Create A New Profile

Advanced

linux command line conversion of .stl to a 2d image?

Posted by Claghorn 
linux command line conversion of .stl to a 2d image?
May 03, 2021 07:37PM
I've got a ton of parts I designed and printed for my DIY 3D printer (printed on my old printer, of course), I'd like to catalog them all with images, but it is a pain to load them one at a time into GUI tools and take screen shots. Anyone know of a command line tool that can generate a .jpg (or png, etc) from a .stl file (obviously it would need to know the angle of the view to produce)?
Re: linux command line conversion of .stl to a 2d image?
May 04, 2021 04:30AM
Quote
Claghorn
Anyone know of a command line tool that can generate a .jpg (or png, etc) from a .stl file (obviously it would need to know the angle of the view to produce)?

It also needs to know how far to place the camera from the object, so that you don't get an extreme close-up of one tiny corner of your part, or a zoomed-out view that is filled with mostly empty space.

If you want to do it yourself: I think a Blender script to automatically import and render each file in sequence would be a feasible approach. You'd need to write some mildly-complex code to place the camera correctly. You might, for example, compute a vector going from the (0,0,0) to (1,1,1) in local object coordinates, then place the camera along this vector at a very short distance from the object. The camera will be too close to the object, so the rendered object will not fit inside of the camera frustum. Then increase the distance between the camera and the object until the object's bounding sphere just fits within the camera frustum. For rendering images from Blender with a script, this might be a starting point: [stackoverflow.com] .

If you want a ready-made solution: [github.com]
VDX
Re: linux command line conversion of .stl to a 2d image?
May 04, 2021 06:27AM
... maybe something like a STL-file viewer? - [reprap.org]


Viktor
--------
Aufruf zum Projekt "Müll-freie Meere" - [reprap.org] -- Deutsche Facebook-Gruppe - [www.facebook.com]

Call for the project "garbage-free seas" - [reprap.org]
Re: linux command line conversion of .stl to a 2d image?
May 19, 2021 08:54PM
OpenSCAD can be run from the command line, and provided with a script that reads an STL file and even rotates and positions it. I don't know if you can get it to save a screenshot. However, I think you could have a Java (or whatever) program read an STL, generate the script for OpenSCAD, run OpenSCAD, and then take a screenshot.
Sorry, only registered users may post in this forum.

Click here to login