From CAD to CAM, Cleaning up 2D DWG files for CNC.

9.281 FANS

CAD to CAM - The CNC Programmers delight!

From CAD to CAM – do you work with a CNC programmer? or maybe you are a CNC programmer!

Here are a few AutoCAD  tips, tricks and tools that you can use to clean up the 2D geometry in your DWG files ready to bring into your favourite CAM programming software.

Place your geometry on a ‘CNC’ layer

Be nice to your CNC programmer. Create a Layer in your DWG file for CNC paths and copy the relevant geometry onto it. To make this easy, use the ‘COPYTOLAYER’ command. Copying the relevant geometry to the correct layer is a simple as point and click.


Geometry that does not have a Z coordinate of Zero, when it really should do, can massively confuse the CAD to CAM process. You can use the ‘FLATTEN’ command to set all the Z coordinate values to ‘0’.

‘Flatten’ is an AutoCAD express tool, so it isn’t available to AutoCAD LT users. If you are using AutoCAD LT, you can use the properties palette as a detective tool to help you see what’s going on.

Type ‘PROPERTIES’ at the command line to open the properties palette. Select each entity you are having a problem with, and check out its properties.

For lines, check that the Z value of the start and finish points is set to 0 (Zero). For 2D polylines make sure that the elevation is set to 0 (Zero). For splines click in the ‘Fit Points’ cell and use the forward and backward arrows to step through each fit point, making sure that the Fit point Z is set to 0 (Zero).

AutoCAD, Flattening splines with the properties paletteAutoCAD, Flattening plines with the properties palettAutoCAD, Flattening lines with the properties palette

 (click on the images for a larger view)


CNC machines don’t like overlapping geometry. This can cause them to go back and forward over the same area needlessly.

‘OVERKILL’ was an AutoCAD express tool that has now been included in the main product. The ‘Overkill’ command removes redundant geometry in the following way.

  • Duplicate copies of objects are deleted.
  • Arcs drawn over portions of circles are deleted.
  • Lines, partially overlapping, but drawn at the same angle are combined into a single line.

I have found that it is better to run each option of the overkill command individually for the best results. You may need to play with the tolerance a bit until you get the results you are looking for.

Related Post:  100 Circles. Secrets of AutoCAD QSELECT

The AutoCAD Overkill command dialogue

Convert splines and ellipses

CNC machines don’t like compound curves such as ellipses and splines. CNC machines like polylines – which can only include line and arc segments. You will need to convert splines and ellipses into arcs before you can join them up into a polyline.

In AutoCAD 2012 you can now convert a spline to a polyline using ‘SPLINEDIT’.

  1. Select the spline to convert.
  2. Enter p to convert to Polyline.
  3. Specify a precision value or press Enter to end the command.

In tests, we have found that our CAD to CAM software does this better than AutoCAD. But this is still a useful tool for those who don’t have another option.

There are a number of other ways that you can convert Splines and Ellipses to polylines. You can read more about it in this post on converting Ellipses to Arcs.

Polyline, fuzz distance

CNC machines don’t like geometry that nearly, but doesn’t quite join up at the corners. By turning your lines and arcs into polylines, you can be sure that the corner junction points are spot on. If the polyline won’t join up, you have identified a problem that needs fixing.

A quick way to join multiple lines into one polyline is with the ‘PEDIT’ command. Type ‘pedit’ at the command line, then immediately chose ‘M’ for multiple object selection. Select all the objects you want to join, and then type ’j’ for the join option.

You will be prompted for a ‘Fuzz’ Distance’. This is the margin of error between lines that overlap, or don’t quite join. Set this higher than your biggest overlap/gap and AutoCAD will join all your lines together in one fell swoop.

Tip: If you get an annoying prompt that says ‘Do you want to convert these lines to polylines’ set the ‘PEDITACCEPT’ system variable to ‘1’ to suppress it.

Fillet zero

If you are looking for a little more precision, try the Fillet command. The fillet command has a hidden option which is great for joining up corners.

Type ‘FILLET’ at the command line to start the fillet command. Don’t worry about the current fillet radius that is shown. Simply hold your finger down on the shift key and pick two lines. Bingo, bango the lines will be joined neatly at the junction.

Related Post:  An AutoCAD Tip, Beware the Big ‘A’.

Holding down the ‘SHIFT’ key temporarily overrides the current value of the fillet command with ‘0’ (Zero) which will effectively trim/extend each line or arc to each other in one operation. As a bonus, if one or other of your entities is a polyline, the other entity will automatically be converted to a polyline and added to it.

Select touching objects

Sometimes your lines just don’t want to connect up into Polylines, and it can be difficult to tell where the problem is. A quick way to tell where the problem break might be is with ‘FASTSEL’. Fastsel is an express tool, that prompts you to select one object, and it then selects any items that are touching that object.

FASTSEL has two modes. To change modes type ‘FSMODE’ at the command line, and select ‘off’ or ‘on’. With FSMODE set to ‘on’ AutoCAD will now select every item that is touching every item that touches the item you select… ad infinitum.

Tip: you can use FSMODE ‘transparently’ (i.e. while in the middle of another command) by typing ‘FS at the command line, note the single quote mark before the command alias.

Export DXF

If you only need to export part of your drawing out to a DXF file for CAD to CAM, you can do this with the top secret options in the Export DXF command.

To make us of this, type ‘DXFOUT’ at the command line, and then pick ‘Tools’ and then ‘Options’ from the ‘Save Drawing As’ dialogue that pops up.

In the ‘Saveas’ options dialogue pick the ‘DXF options’ tab, and check the ‘Select objects’ box. Hit OK. When you return to the ‘Save Drawing As’ dialogue, set your file name and path as usual. When you hit OK, you will be prompted for a selection set. Only the geometry you select will be exported.

AutoCAD Export DXF options dialogue


‘CHSPACE’ is a very handy command for moving geometry between model space and paper space. You need to be in paper space for this to work. Type ‘CHSPACE’ at the command line, pick an object, pick a viewport, and the geometry will be ‘pushed’ through the viewport into model space. The command will even scale the geometry by the viewport scale automatically.

Related Post:  The CAD Setter Out's World Famous Dynamic Wood Screw AutoCAD Block

To move objects in the opposite direction, start off in paper space and double click in a view port to make it active . Now run the ‘CHSPACE’ command and select the geometry you wish to move. It will be ‘Pulled’ through into paper space and scaled for you.

Insert views and export layout model space

If you have a .DWG file that has been created with Autodesk Inventor, you may find that all the geometry is in paper space. The Inventor views are actually in a magic hinterland somewhere between paper space and model space. However, all the Inventor views are available in the drawing file as blocks.

To get to the Inventor views use the ‘INSERT’ command to insert the view into model space as a block. You can also browse the available blocks that are in the drawing via the Design centre. You will need to explode the blocks once you’ve inserted them and you may need clean up the geometry a bit.

For more on this tip, check out this post on How to extract 2D AutoCAD geometry from an Autodesk Inventor DWG Drawing File.

For a quick way to put the whole layout into model space, use the ‘EXPORTLAYOUT’ command to export the entire layout into model space in a new drawing. If you do this, don’t forget that you may need to scale the geometry up or down a bit to suit the view scale.

Rounding up CAD to CAM

Drawings are quickly becoming just one of our deliverables. Often a 3D model or 2D geometry is also required for CNC or CAM processing down the line. Creating good clean DWG files is rapidly becoming part of your job.

Can you think of any other processes you use to clean up and extract your geometry for CAD to CAM or CNC programming? Please feel free to leave a comment…


Read this post for more ways to optimize your AutoCAD DWG drawing files.

12 Responses to “From CAD to CAM, Cleaning up 2D DWG files for CNC.

  • Hi I’m Ricky

    I’m having problems with my dxf files
    Went I open them on my cnc it’s tells me that the material thinness 0.00
    But I’m new to this and I don’t know what to do, please help!

  • Does Auocad’s PEDIT -> FIT command — which turns faceted curves (based on many tiny straight lines) into arc-fit curves based a series of tiny arcs — help with output precision such as printing and CNC? I’m guessing that all the display options for curves in Autocad (VIEWRES, WHIPARC, number of segments in curves) affect only the way curves are displayed on the display screen, but not how they print or CNC. What Autocad options, if any, actually affect the number of facets in curving lines that translate into printer, CNC, and laser cutter output quality?

  • Hi ,
    I have a big problem with my plotter for cutting fabrics shapes. I would automatically cut shapes printed on fabric textile captured by a smart camera CCD : one shot one cut automatic , without click by operator because he moves the shapes .Now for me isn’t possible because not able to cleance and trasform path shapes in CNC automatically .
    How can I do ?

  • When we import dxf files into Alphacam, it shows not closed counters then we zoom the two curve area , it shows not perfectly joined, Ho i can make perfect tool path for cam.

    Is any Tool path analyzer so it can show bad sectors to clean in autocad.

    • Hi Ameer,

      I suggest that you use ‘FASTSEL’ to analyse which geometry has successfully been joined. This will highlight where the Geometry cannot be joined, and you can then look into it to fix the problem.

      Does that help?


      • Ameerjani
        12 months ago

        How can i export Perfect 1:1 scale PDF for my Printer after Drawing completed in Autocad.

        My Plotter will accept only PDF files

  • Thanks for this. When you covert a spline to a polyline, it asks for the precision. If that value is high, ie lots of lines and arc, will this slow the CNC cut down?

    • Hi Adam,

      Yes – the CNC treats each geometry individually. To put it another way, each piece of geometry will be turned into a line of G-code which controls the CNC machine.

      Les geometry = less code = a faster run time.

      Does that make sense?

  • Stacie
    1 year ago

    Thanks for this great list of instructions – very helpful. Now that I have completed these steps, I am wondering if there a way to test the CAD drawing to find out if it is ready for CNC. I am new at this procedure and would love to know if I am doing things correctly. If so, please let me know as I would like to make sure before sending this off.

    • Hi Stacie,

      Thanks for your comment – what a great idea! You’ve really got me thinking…

      Probably the best way to check that everything is ready for CNC would be to send a test file to your CNC programmer. Ask them for feedback and add this feedback to your checklist.

      I hope that helps? Let us know what you think.


Join the conversation :)

You have to agree to the comment policy.

Follow Cadsetterout on: