584,837 active members*
5,374 visitors online*
Register for free
Login
IndustryArena Forum > OpenSource CNC Design Center > Coding > Stereolithography file to GCode
Page 2 of 2 12
Results 21 to 34 of 34
  1. #21
    Join Date
    Jun 2005
    Posts
    180
    Here is the description for the binary file:

    "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.

  2. #22
    Join Date
    Sep 2010
    Posts
    0
    Hello sweatherly,

    thanks for ut reply.
    I am very thankful to you if you can post your VB code for binary file read.

    ~Dhr1

  3. #23
    Join Date
    Jun 2005
    Posts
    180
    It may take a few hours to find the code, but I will post it ASAP.

  4. #24
    Join Date
    Sep 2010
    Posts
    0
    ok.
    take your time.
    I am trying with myself also.

  5. #25
    Join Date
    Jun 2005
    Posts
    180
    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.

  6. #26
    Join Date
    Jun 2005
    Posts
    180
    Attached are two files:

    The .zip is the Excel file with the VB program.

    The .txt file is the VB program alone. It has calls to the Excel sheets in it, but you can modify it to work as a stand-alone.

    You can probably find something with an ASCII and a binary .stl file and test the above to double check that it is working correctly.

    It is not the best written or annotated program, but it works as far as I know.
    Attached Files Attached Files

  7. #27
    Join Date
    Oct 2010
    Posts
    0
    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

  8. #28
    Join Date
    Feb 2006
    Posts
    7063
    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....

    Regards,
    Ray L.

  9. #29
    Join Date
    Apr 2010
    Posts
    42

    stl file to gcode

    Hi
    I did a stl file to gcode by

    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.

    See the attached png picture.
    Attached Thumbnails Attached Thumbnails butterfly.png  

  10. #30
    Join Date
    Jul 2005
    Posts
    82
    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.

  11. #31
    Join Date
    Apr 2010
    Posts
    42
    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.

  12. #32
    Join Date
    Feb 2009
    Posts
    2143
    Do you by chance have a picture of the machined part to compare to the screenshot?

  13. #33
    Join Date
    Apr 2010
    Posts
    42

    The butterfly engraved

    The file is being engraved at-last.
    The next time I will use wood instead of plastic.
    Attached Thumbnails Attached Thumbnails IMG_1416.jpg  

  14. #34
    Join Date
    Mar 2018
    Posts
    15

    Re: Stereolithography file to GCode

    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.

Page 2 of 2 12

Similar Threads

  1. Gcode file samples
    By safecnc in forum G-Code Programing
    Replies: 4
    Last Post: 12-21-2010, 07:38 PM
  2. Need gcode or dxf file for drilling UHU PCB
    By visky in forum UHU Servo Controllers
    Replies: 0
    Last Post: 10-07-2008, 08:45 PM
  3. Is there any way to add notes to a gcode file?
    By Anokiernan in forum G-Code Programing
    Replies: 4
    Last Post: 02-22-2008, 04:11 AM
  4. Can Someone Covert File To Gcode?
    By bcnc in forum CNC (Mill / Lathe) Control Software (NC)
    Replies: 21
    Last Post: 06-27-2007, 03:16 AM
  5. How to mirror GCode file?
    By anoah in forum Uncategorised CAM Discussion
    Replies: 6
    Last Post: 07-08-2003, 06:26 PM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •