"Binary STL files consist of a 80 byte header line that can be interpreted as a comment string. The following 4 bytes interpreted as a long integer give the total number of facets. What follows is a normal and 3 vertices for each facet, each coordinate represented as a 4 byte floating point number (12 bytes in all). There is a 2 byte spacer between each facet. The result is that each facet is represented by 50 bytes, 12 for the normal, 36 for the 3 vertices, and 2 for the spacer."
I wrote a binary to decimal converter in VB if you want to program it.
I'll post the complete code, but here is what I did (speaking in VB).
-Open the file for random access
-Read in the first 80 characters as one string (the header)
-Create a binary string for the next 4 characters starting at file position 84, then 83, 82, and 81. This creates a 32 character binary string. Convert that string to an integer that is the the number of facets.
-Read in the next 50 bytes in 4 byte groups with 2 spacer bytes at the end. The first three groups are the three normals, the next 9 groups are the x,y,z for the three facet verticies. These are all floating point, of course. Like the facet number I create a binary number by reading the 4 bytes in reverse order.
-repeat for facet 2, etc.
The reason for the delay in posting the code (other than my programming is not that easy to read) is that I added a lot of code to do other things.
Howdy from North Texas I have a stl file that I would like to convert to gcode for a very small part. I was thinking about outsourcing the conversion so my friend with a haas lathe can mill it. haas has not been real helpful except to sell me something else. thanks thom
This thread seems to have died, but maybe we can get it going again, as I have a need to generate a 2D DXF from a 3D STL. It appears to me to be a pretty simple proposition, with some restrictions. My 3D parts are all extruded in the Z axis, so here's what I'm planning to do:
1) Parse the STL file into an array of polygons, each defined by the four points from the file. Also compile a second list of the indices of all polygons which have all three vertices at the same Z position, which indicates they are parallel to the XY plane.
2) Scan through the second list, one polygon at a time. For each one, scan through the list of all polygons, until finding one that both shares an edge with it, and is normal to it. Write the X,Y,Z coordinates of the both vertices of the shared edge to an output array, as this edge is a corner that represents a line segment parallel to the XY plane which must be output to the DXF file
3) After finding all the line segments needing output to the DXF file in step #2, sort the output array, finding all segments which are connected to each other (i.e. - they share a vertex).
4) Write each "string" of connected line segments to it's own layer of the DXF file.
Seems to me this would work, and be pretty easy....
blender 2.5 import the stl file and blender can place a light source on top.
Use the camera to talk a picture of the object. Adjust the light source intensity, render and see if it is a gray scale depth map.
Once the depth map image is ready. The png or jpg picture can be handled by image to gcode function of emc2, that will generate gcode for engraving.
That looks pretty cool to carve out, I may run it through mine just to try it. I like doing the 3d stuff, but don't do it often. I did some simple geometric stuff in gimp one, worked nicely. I've also done the blender depth map approach as well.
Hi
I found Blender can do normal map, that is same as depth map.
see "http://www.blender.org/development/release-logs/blender-236/normal-maps/"
But I do not start to learn it yet.
Hi rweatherly
you and other users have more updates of your VB and Excel apps? i want convert image to vector and import .stl files inv VB .
i need open-source code to i learn about this.
thank you.