ViewSTL in the Chop Shop

The ViewSTL web application seemed to do what we wanted and about ten times more. This is the story of disassembling the application which became a test of skill and patience.

A friend said, "that looks to work well", when I posted my result. I explained...

As long as the program could render my test data I had not cut to much. view

The tricky part was switching from drop handling to query parameter for getting the input. I didn't want an interactive program. The program had a lot of options but query parameters wasn't one because, of course, most programs that could serve a cad file wouldn't have cors headers. I had that part covered already.

I added jquery to do the xhr for the fetch. There was already some xhr code in there for printing but it was crazy convoluted to get a progress bar. (That was last week for me. No desire to do that again.)

Jquery.get gave me the cad file as a string. Makes sense, no? No. The stl file parser wanted to read an ArrayBuffer which it wrapped with a DataView. I'm not making this up. These things exist. They are for reading bytes, not characters. And jquery docs say that you can ask for your data in binary, and there are many post online about how to do this, all of which disagree.

So I find some google information from the chrome people that show how to convert back and forth. I read a string, convert to ArrayBuffer, call the parser and get all zeros back. I start single stepping the parser, which starts by determining that the ArrayBuffer was really a string and converting it back.

It seems stl format has a binary and a text version. The text parser just used regex replace commands to delete all the words, split on space, and then turned every three remaining numbers into a three.js point in three-space.

My problem was that going into and then back out of ArrayBuffer my line terminators were somehow lost so that the regex approach was failing. By now I was pretty familiar with the parser so I just deleted all of the ArrayBuffer stuff and got my data back.

All of this was strangely satisfying. I enjoyed watching the line count of the application shrink hour by hour. I had looked into using three.js directly but I didn't think I could get a working example going to refine. With this program I just cut out stuff that seemed optional and backed up whenever my 3d part disappeared. I also felt like I was living the original program's evolution in reverse.

My commit history tells the full story of six hours of butchering. github

.

Our abbreviated version of ViewSTL now joins the other tools we use making and documenting our 3d printing.

We keep our version in wiki to be served when needed.

viewstl