MLAB-project / stl-thumbnailer

Shows thumbnails of STL files in Nautilus file browser
GNU General Public License v3.0
58 stars 16 forks source link

OpenSCAD thumbnails, please #7

Open nathanielstenzel opened 4 years ago

nathanielstenzel commented 4 years ago

If you do not do it already, could you please add OpenSCAD file thumbnail generation? I know this is meant to be an STL thumbnail generator but if it uses OpenSCAD to make them then it should not be a big hassle. At least I hope not.

kaklik commented 4 years ago

The .scad file thumbnail generation is a complicated task because of some scad files are very high computation and memory demanding. Therefore calculation of the thumbnail image could easily waste out all system resources.

nathanielstenzel commented 4 years ago

I will have to admit that I have made one or two that would not "render" on my older machines. The "preview" on those works just fine, but can you get an image from the "preview" instead of the "render"?

nathanielstenzel commented 4 years ago

It looks like you can export a PNG file from a "preview". That would work great. I don't think anyone would expect the thumbnails of any file to be made out of a high resolution render when there is a cheap (processing-wise) and easy method available.

nathanielstenzel commented 4 years ago

cmd = "openscad -o %s.png --preview --imgsize=%s,%s %s 2> /dev/null; mv %s.png %s" % (fout, size, size, ff, fout, fout)

The --preview forces it to generate the image in preview mode. My test file was admittedly a simple one. I do not know if the default behavior is --render or --preview or if it varies based on output dimensions. I do know that the command generated a PNG of my SCAD file.

nathanielstenzel commented 4 years ago

It looks like --preview is the default mode. Something with 781 CSG tree elements gets a thumbnail in 21-48 seconds on a Intel(R) Celeron(R) CPU 900 @ 2.20GHz (single core) when I run the command by hand. That is crappy, but it is a complex file on an old machine with 6GB of RAM too.

nathanielstenzel commented 4 years ago

https://github.com/nathanielstenzel/stl-thumbnailer

I am not sure if I actually had to adjust the STL thumbnail stuff. I had trouble getting it to work. The magic number thing seemed to get it to work for me. It may be my imagination though since I tried a number of things.

nathanielstenzel commented 4 years ago

It was easier to just have OpenSCAD called directly for the OpenSCAD thumbnail generation so I switched to that.

nathanielstenzel commented 4 years ago

It looks like the Debian version in Linux Mint does not like --preview and expect a specific option to go with --preview. I have not made this thumbnailer work on Linux Mint but I have on Fedora Linux.

vmario89 commented 3 years ago

made some fork of the fork, which is made for Fedora 34, supporting stl and scad. dirty but works: https://github.com/vmario89/stl-thumbnailer

ajbogh commented 1 year ago

I had trouble with the current version in Ubuntu and found that the code for using openscad was complicated because it had to generate additional temp files. I created a fork that uses stl-thumb and opened #11.

Feel free to decline it if you feel like openscad is better.