{"id":2432,"date":"2009-06-05T12:02:21","date_gmt":"2009-06-05T12:02:21","guid":{"rendered":"https:\/\/blogs.mathworks.com\/pick\/2009\/06\/05\/writing-to-stl-files\/"},"modified":"2009-06-05T12:02:21","modified_gmt":"2009-06-05T12:02:21","slug":"writing-to-stl-files","status":"publish","type":"post","link":"https:\/\/blogs.mathworks.com\/pick\/2009\/06\/05\/writing-to-stl-files\/","title":{"rendered":"Writing to STL files"},"content":{"rendered":"<div xmlns:mwsh=\"https:\/\/www.mathworks.com\/namespace\/mcode\/v1\/syntaxhighlight.dtd\" class=\"content\">\r\n   <p><a href=\"https:\/\/www.mathworks.com\/matlabcentral\/fileexchange\/authors\/15007\">Jiro<\/a>'s pick this week is <a href=\"https:\/\/www.mathworks.com\/matlabcentral\/fileexchange\/4512-surf2stl\"><tt>surf2stl<\/tt><\/a> by <a href=\"https:\/\/www.mathworks.com\/matlabcentral\/fileexchange\/authors\/12330\">Bill McDonald<\/a>.\r\n   <\/p>\r\n   <p>About a month ago, at a seminar I gave at a university, a graduate student came up to me and asked whether there was a function\r\n      for writing out 3D model files. Specifically, he was referring to STL files (stereolithography files). It was a topical question\r\n      because it came soon after I talked about some of the exporting capabilities in MATLAB for graphical file formats.\r\n   <\/p>\r\n   <p>I knew that we didn't have any built in, but I promptly suggested checking out the File Exchange. I've seen a few functions\r\n      for reading from STL files, so I figured there would be counterparts. Sure enough, there were a few. Here's a list of entries\r\n      with a tag of <a href=\"https:\/\/www.mathworks.com\/matlabcentral\/fileexchange\/?term=tag:&#34;stl&#34;\">\"stl\"<\/a>.\r\n   <\/p>\r\n   <p>From the list, I am highlighting Bill's <tt>surf2stl<\/tt>. It has nice help, clean code, good reviews, and has even inspired another entry.\r\n   <\/p>\r\n   <p><img decoding=\"async\" vspace=\"5\" hspace=\"5\" src=\"https:\/\/blogs.mathworks.com\/images\/pick\/surf2stl_screenshot.png\"> <\/p>\r\n   <p>Download and give it a try!<\/p>\r\n   <p><a href=\"https:\/\/blogs.mathworks.com\/pick\/?p=2432#respond\"><b>Comments?<\/b><\/a><\/p><script language=\"JavaScript\">\r\n<!--\r\n\r\n    function grabCode_7586d0d7c2994d78ad4ac78a4e751486() {\r\n        \/\/ Remember the title so we can use it in the new page\r\n        title = document.title;\r\n\r\n        \/\/ Break up these strings so that their presence\r\n        \/\/ in the Javascript doesn't mess up the search for\r\n        \/\/ the MATLAB code.\r\n        t1='7586d0d7c2994d78ad4ac78a4e751486 ' + '##### ' + 'SOURCE BEGIN' + ' #####';\r\n        t2='##### ' + 'SOURCE END' + ' #####' + ' 7586d0d7c2994d78ad4ac78a4e751486';\r\n    \r\n        b=document.getElementsByTagName('body')[0];\r\n        i1=b.innerHTML.indexOf(t1)+t1.length;\r\n        i2=b.innerHTML.indexOf(t2);\r\n \r\n        code_string = b.innerHTML.substring(i1, i2);\r\n        code_string = code_string.replace(\/REPLACE_WITH_DASH_DASH\/g,'--');\r\n\r\n        \/\/ Use \/x3C\/g instead of the less-than character to avoid errors \r\n        \/\/ in the XML parser.\r\n        \/\/ Use '\\x26#60;' instead of '<' so that the XML parser\r\n        \/\/ doesn't go ahead and substitute the less-than character. \r\n        code_string = code_string.replace(\/\\x3C\/g, '\\x26#60;');\r\n\r\n        author = 'Jiro Doke';\r\n        copyright = 'Copyright 2008 The MathWorks, Inc.';\r\n\r\n        w = window.open();\r\n        d = w.document;\r\n        d.write('<pre>\\n');\r\n        d.write(code_string);\r\n\r\n        \/\/ Add author and copyright lines at the bottom if specified.\r\n        if ((author.length > 0) || (copyright.length > 0)) {\r\n            d.writeln('');\r\n            d.writeln('%%');\r\n            if (author.length > 0) {\r\n                d.writeln('% _' + author + '_');\r\n            }\r\n            if (copyright.length > 0) {\r\n                d.writeln('% _' + copyright + '_');\r\n            }\r\n        }\r\n\r\n        d.write('<\/pre>\\n');\r\n      \r\n      d.title = title + ' (MATLAB code)';\r\n      d.close();\r\n      }   \r\n      \r\n-->\r\n<\/script><p style=\"text-align: right; font-size: xx-small; font-weight:lighter;   font-style: italic; color: gray\"><br><a href=\"javascript:grabCode_7586d0d7c2994d78ad4ac78a4e751486()\"><span style=\"font-size: x-small;        font-style: italic;\">Get \r\n            the MATLAB code \r\n            <noscript>(requires JavaScript)<\/noscript><\/span><\/a><br><br>\r\n      Published with MATLAB&reg; 7.8<br><\/p>\r\n<\/div>\r\n<!--\r\n7586d0d7c2994d78ad4ac78a4e751486 ##### SOURCE BEGIN #####\r\n%%\r\n% <https:\/\/www.mathworks.com\/matlabcentral\/fileexchange\/authors\/15007\r\n% Jiro>'s pick this week is\r\n% <https:\/\/www.mathworks.com\/matlabcentral\/fileexchange\/4512-surf2stl\r\n% |surf2stl|> by \r\n% <https:\/\/www.mathworks.com\/matlabcentral\/fileexchange\/authors\/12330\r\n% Bill McDonald>.\r\n%\r\n% About a month ago, at a seminar I gave at a university, a graduate\r\n% student came up to me and asked whether there was a function for writing\r\n% out 3D model files. Specifically, he was referring to STL files\r\n% (stereolithography files). It was a topical question because it came\r\n% soon after I talked about some of the exporting capabilities in MATLAB\r\n% for graphical file formats.\r\n%\r\n% I knew that we didn't have any built in, but I promptly suggested\r\n% checking out the File Exchange. I've seen a few functions for reading\r\n% from STL files, so I figured there would be counterparts. Sure enough,\r\n% there were a few. Here's a list of entries with a tag of \r\n% <https:\/\/www.mathworks.com\/matlabcentral\/fileexchange\/?term=tag:\"stl\"\r\n% \"stl\">.\r\n%\r\n% From the list, I am highlighting Bill's |surf2stl|. It has nice help,\r\n% clean code, good reviews, and has even inspired another entry.\r\n%\r\n% <<surf2stl_screenshot.png>>\r\n%\r\n% Download and give it a try!\r\n%\r\n% <https:\/\/blogs.mathworks.com\/pick\/?p=2432#respond *Comments?*>\r\n##### SOURCE END ##### 7586d0d7c2994d78ad4ac78a4e751486\r\n-->","protected":false},"excerpt":{"rendered":"<p>\r\n   Jiro's pick this week is surf2stl by Bill McDonald.\r\n   \r\n   About a month ago, at a seminar I gave at a university, a graduate student came up to me and asked whether there was a function\r\n    ... <a class=\"read-more\" href=\"https:\/\/blogs.mathworks.com\/pick\/2009\/06\/05\/writing-to-stl-files\/\">read more >><\/a><\/p>","protected":false},"author":35,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":[],"categories":[16],"tags":[],"_links":{"self":[{"href":"https:\/\/blogs.mathworks.com\/pick\/wp-json\/wp\/v2\/posts\/2432"}],"collection":[{"href":"https:\/\/blogs.mathworks.com\/pick\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blogs.mathworks.com\/pick\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blogs.mathworks.com\/pick\/wp-json\/wp\/v2\/users\/35"}],"replies":[{"embeddable":true,"href":"https:\/\/blogs.mathworks.com\/pick\/wp-json\/wp\/v2\/comments?post=2432"}],"version-history":[{"count":0,"href":"https:\/\/blogs.mathworks.com\/pick\/wp-json\/wp\/v2\/posts\/2432\/revisions"}],"wp:attachment":[{"href":"https:\/\/blogs.mathworks.com\/pick\/wp-json\/wp\/v2\/media?parent=2432"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blogs.mathworks.com\/pick\/wp-json\/wp\/v2\/categories?post=2432"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blogs.mathworks.com\/pick\/wp-json\/wp\/v2\/tags?post=2432"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}