Site icon The CAD Setter Out

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

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.

Flatten

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)

Overkill

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.

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.

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.

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

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

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.