CNCzone.com-The Largest Machinist Community on the net!



Home Page Mark Forums Read Today's Posts My Replies Classifieds Reviews Photo Gallery Web Links Share Files Advertise With Us Ad List
Go Back   CNCzone.com-The Largest Machinist Community on the net! > OpenSource CNC Design Center > Coding


Coding Post your Coding for opensource projects here.


This forum is sponsored by:

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #25   Ban this user!
Old 09-20-2010, 08:56 AM
 
Join Date: Jun 2005
Location: USA
Posts: 180
rweatherly is on a distinguished road

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.
Reply With Quote

Sponsored Links
  #26   Ban this user!
Old 09-20-2010, 05:45 PM
 
Join Date: Jun 2005
Location: USA
Posts: 180
rweatherly is on a distinguished road

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
File Type: txt Stl2TextVBCode.txt‎ (3.4 KB, 38 views)
File Type: zip StlBinaryReaderCNCZone.zip‎ (342.6 KB, 22 views)
Reply With Quote

  #27   Ban this user!
Old 10-08-2010, 12:11 PM
 
Join Date: Oct 2010
Location: US
Posts: 2
Thomru is on a distinguished road

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
Reply With Quote

  #28   Ban this user!
Old 02-19-2011, 09:10 PM
 
Join Date: Feb 2006
Location: USA
Posts: 2,373
HimyKabibble is on a distinguished road

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.
Reply With Quote

  #29   Ban this user!
Old 03-02-2011, 12:16 PM
 
Join Date: Apr 2010
Location: p.r.china
Age: 64
Posts: 16
ktchk is on a distinguished road
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 Images
File Type: png butterfly.png‎ (107.0 KB, 9 views)
Reply With Quote

  #30   Ban this user!
Old 03-02-2011, 01:00 PM
 
Join Date: Jul 2005
Location: USA
Posts: 82
klick0 is on a distinguished road

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.
Reply With Quote

Sponsored Links
  #31   Ban this user!
Old 03-02-2011, 01:29 PM
 
Join Date: Apr 2010
Location: p.r.china
Age: 64
Posts: 16
ktchk is on a distinguished road

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.
Reply With Quote

  #32   Ban this user!
Old 03-02-2011, 01:30 PM
 
Join Date: Feb 2009
Location: USA
Posts: 1,475
mcphill is on a distinguished road
Buy me a Beer?

Do you by chance have a picture of the machined part to compare to the screenshot?
Reply With Quote

  #33   Ban this user!
Old 06-04-2011, 10:18 AM
 
Join Date: Apr 2010
Location: p.r.china
Age: 64
Posts: 16
ktchk is on a distinguished road
The butterfly engraved

The file is being engraved at-last.
The next time I will use wood instead of plastic.
Attached Images
File Type: jpg IMG_1416.jpg‎ (53.5 KB, 7 views)
Reply With Quote

Reply




Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On





All times are GMT -5. The time now is 06:22 AM.





Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2012, vBulletin Solutions, Inc.
Content Relevant URLs by vBSEO
Template-Modifications by TMS

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361