Commands to create a 3D Gcode program from Autocad / Mechanical DeskTop (MDT):

This method of 3D gcode may not be as easy or fast as using a high end CAM system,
but the control you can get over the tool path will be exactly what you want.

Steps 2 thru 5 require Mechanical Desktop to generate the flowwires. These are
exploded into 3dpolylines that joined and used as the toolpath for a Ball End Mill.

You can create the 3dpolylines manually, but the flowwire capability in MDT is a big help.

1. Draw the object you want to machine using solids or surfaces in Autocad 2000 (or MDT). You could import the drawing
or open a sample drawing.
2. Open drawing from MDT (To create surfaces and flowwires) (I used MDT 5 in my example here)
3. Convert the portion(s) of the solid to machine into a surface
Toolbar -zfly-solid-surface -convert-faces (_am2sf)
If the toolbars you need are not open,
Right click a toolbar and select customize
Turn on the toolbars noted here.
or type the command in ( )
4. If more than one surface is needed, join surfaces with:
Toolbar -zfly-edit surface -join surface (_amjoinsf)
It is not necessary to join surfaces,
flowwires can be connected later or
machined at a later time.
5. Create flowwires offset from each surface by the Ball-End-Mill (BEM) radius.
Toolbar – zfly-wire off surfaces – flow wires (_amflow)
Experiment with direction (U or V) and number of lines.
(check save in the dialogue box)
If you want to make a roughing pass,
Offset by the BEM radius plus the
ammount of stock you want to leave.
5-Continued Notes:
Place flowwires in layers to divide sections to be machined.
-layer for roughing
-layer for finish passes
-layer for different size BEM
-layer for flowwires on different surfaces
I number my layers in the order I want to machine them.
6. Group – explode – all wires.
Use the Autocad command "Group".
In the dialogue box:
Select the group, click explode.
The flowwires created in MDT are
actually polylines grouped.
Exploding the group leaves
individual 3Dpolylines.
Be careful what layer the group explodes to.
7. Join wires
toolbar –zfly-edit wires –join wires (_amjoin3d)

It may be necessary to draw some connections at ends to
be sure the tool does not cut into part.
If you have Toolpac (
Toolpac – polyline – maintaince –3dpoly – join segments
(may have to use Toolpac – Object – Modify – UCS Fix Parallel)
8. Reverse direction of wires. (as necessary)
toolbar - zfly-edit wires -wire direction (_amwiredirection)
Toolpac - Polyline- Reverse Direction

At this point you have a toolpath of the CENTER of the
Ball End Mill that can be converted to G-code by several methods...
When you Run this Gcode on a CNC machine
with the tool length set at the end of the BEM,
the tool path will be above the part by the radius
of the BEM.

Either set your tool down by the radius or
shift these toolpaths down before creating the gcode.
9. Methods of Converting polylines to Gcode:
using Autocad and Autocad add-in programs:
Not Stand-alone CAM programs
-Free demo
-Has capabilities to generate nice CNC programs from Autocad entities
-post can be modified to suit your cnc machine
-(demo may not allow enough lines for 3D unless you purchase)
gcodeout.lsp (free download )
I wrote this lisp program for my own use,
-works from command line -select a polyline and output code, repeat until done. -Gcode post is for turbocnc, but can be modified.
Download Gcodeout
"Autocad 2 Gcode Macro"
(free VB macro program you can download from

Forum with Gerry's Macro
If you have Toolpac (from, you can export gcode:
Toolpac – utility – point export (to a text file)
(using a format mask: '<'X[X]Y[Y]Z[Z]'>')
ACE converter (
free download

Manual method to convert 3dpoly line to Gcode.
- List the polyline to the autocad text window.
- copy and paste list (in text window) into Column B of a spreadsheet.
- Number column A sequentially
- Sort columns A and B by column B
- Delete all rows except those starting with “at point”:
( at point, X= -6.5316 Y= -0.9706 Z= 0.0667)
- Re-sort both columns by Column A to get into original order
- Copy and past into Word (text editor) – Paste special – text only
- Replace all “at point, X= “ with “X”
- Replace all “Y= “ with “Y”
- Replace all “Z= “ with “Z”
- Add G1 and feeds

This is a lot of number crunching,
but it will get the job done.

Good Luck