<p>I need to add some simple image renders of STL files to a document.  I currently open the STL files in Preview or one of the slicers and grab a screen shot.</p>

<p>Is there an easier or automatic way to generate PNG images from STL files on a Mac?</p>

[{'answer_id': 6047, 'author': '0scar', 'author_id': 5740, 'author_profile': 'https://3dprinting.stackexchange.com/users/5740', 'pm_score': 2, 'selected': False, 'text': '<p>Typically you would install a (free) 3D model program as Fusion 360, FreeCAD, or many more options to choose from. Once installed, import the STL file and use menu options to export a picture of your STL.</p>\n\n<p>Alternatively, if you have some programming skills, you could <a href="https://en.wikibooks.org/wiki/OpenSCAD_User_Manual/Importing_Geometry" rel="nofollow noreferrer">import the STL file</a> in OpenSCAD and render and export a picture from there. Simply create an OpenSCAD file with the code line below and it will import your <code>example.stl</code>. </p>\n\n<pre><code>import("example.stl", convexity=10);\n</code></pre>\n\n<p>Through the menu you can then export the view to an image. Note that you can do that also from the <a href="https://en.wikibooks.org/wiki/OpenSCAD_User_Manual/Using_OpenSCAD_in_a_command_line_environment" rel="nofollow noreferrer">command line</a> as shown by the OP\'s own answer (nice example of command line usage of OpenSCAD).</p>\n\n<p>These are not the only options, there are many more. E.g. <a href="http://dangerousprototypes.com/blog/2015/05/13/3d-model-stl-to-png-preview/" rel="nofollow noreferrer">this</a> is a nice example. It also describes how Thingiverse.com does STL to web image.</p>\n'}, {'answer_id': 6048, 'author': 'Mark Harrison', 'author_id': 6851, 'author_profile': 'https://3dprinting.stackexchange.com/users/6851', 'pm_score': 5, 'selected': True, 'text': '<p>If you have <a href="http://www.openscad.org" rel="noreferrer">OpenSCAD</a> installed, this shell script will generate 100x100 pixel PNG images for each STL file in your current directory.</p>\n\n<pre><code>for i in *.stl; do\n  T=__tmp__<span class="math-container">$i\n  b=`basename $</span>i`\n  echo import\\(\\"<span class="math-container">$i\\"\\)\\; &gt;$</span>T\n  /Applications/OpenSCAD.app/Contents/MacOS/OpenSCAD -o <span class="math-container">$b.png --imgsize=100,100 $</span>T\n  rm $T\ndone\n</code></pre>\n\n<p>Credit to <a href="https://3dprinting.stackexchange.com/users/5740/0scar">0scar</a> for pointing out STL files can be imported into OpenSCAD.</p>\n\n<p>Update: This code does the same, and generates an html file with annotated images of the files rendered.  When I printed a batch of spare parts for my 3D printer I made a hardcopy and stuck it in the box so I could identify the parts later.</p>\n\n<pre><code>n=-1\nH=00-catalog.html\necho &gt;<span class="math-container">$H \'&lt;table&gt;\'\necho &gt;&gt;$</span>H \'  &lt;tr&gt;\'\nfor i in <span class="math-container">$*; do\n  n=`expr $</span>n + 1`\n  if test $n = 4; then\n      n=0\n      echo &gt;&gt;$H \'  &lt;/tr&gt;\'\n      echo &gt;&gt;$H \'  &lt;tr&gt;\'\n  fi\n  echo $i\n  T=__tmp__$i\n  B=`basename <span class="math-container">$i .stl`\n  echo import\\(\\"$</span>i\\"\\)\\; &gt;<span class="math-container">$T\n  /Applications/OpenSCAD.app//Contents/MacOS/OpenSCAD -o $</span>B.png --imgsize=200,200 <span class="math-container">$T\n  echo &gt;&gt;$</span>H\n  echo &gt;&gt;<span class="math-container">$H \'    &lt;td&gt;\'$</span>i\'&lt;br&gt;&lt;img src="\'$B\'.png"&gt;&lt;/td&gt;\'\n\n  rm <span class="math-container">$T\ndone\necho &gt;&gt;$</span>H \'  &lt;/tr&gt;\'\necho &gt;&gt;$H \'&lt;/table&gt;\'\n</code></pre>\n'}, {'answer_id': 6054, 'author': 'Carl Witthoft', 'author_id': 2191, 'author_profile': 'https://3dprinting.stackexchange.com/users/2191', 'pm_score': 2, 'selected': False, 'text': "<p>If you don't mind using screen grabs,  you could use AppleScript or whatever it's called in the latest MacOS versions to build an automated script to open each file, grab screen, save, etc.  </p>\n"}, {'answer_id': 10802, 'author': 'Paul', 'author_id': 17236, 'author_profile': 'https://3dprinting.stackexchange.com/users/17236', 'pm_score': 1, 'selected': False, 'text': '<p>You can use OpenSCAD, as stated in the accepted answer. \nHere is a version of that script that works for Windows for anyone who needs it, as I did.</p>\n\n<pre><code># Change height and width to the desired output image dimensions, in pixels.\n# The path to openscad.exe may also have to be adjusted based on your installation.\n\nheight=1080\nwidth=1080\n\nfor i in *.stl; do\n  T=__tmp__<span class="math-container">$i\n  b=`basename "$</span>i"`\n  echo import\\(\\"./<span class="math-container">$i\\"\\)\\; &gt; "$</span>T"\n  C:/\'Program Files\'/OpenSCAD/openscad.exe -o "<span class="math-container">$b".png --autocenter --viewall --imgsize=$</span>width,<span class="math-container">$height "$</span>T"\n  rm "$T"\ndone\n</code></pre>\n'}]
['https://3dprinting.stackexchange.com/questions/6046', 'https://3dprinting.stackexchange.com', 'https://3dprinting.stackexchange.com/users/6851/']