Categories

AutoCAD 2015 and AutoCAD LT 2015 Bible

The most comprehensive AutoCAD book around!

Use the DXF format to edit drawings

AutoCAD supports Autodesk’s DXF (Drawing Interchange File) format, which is a text-only format that contains a 2D drawing’s information. The DXF format is often used to exchange drawings between different CAD programs.

You can save a drawing in DXF format and you can open a DXF file in AutoCAD and save it as a drawing. Try this round-trip exercise.

  1. Open a new drawing based on the default acad.dwt template.
  2. Draw one line.
  3. Save the drawing.
  4. Choose File> Save As (in 2009, choose Menu Browser> File> Save As). From the Files of Type drop-down list in the Save Drawing As dialog box, choose the most recent DXF option (such as AutoCAD 2007 DXF (*.dxf).
  5. Leave the default file name and click Save.
  6. Close the drawing. (AutoCAD may ask you to save again in DWG format.)
  7. Open Notepad. Choose File> Open.
  8. In the Open dialog box, click the drop-down list that displays Text Documents (*.txt) and choose All Files (*.*).
  9. Choose the file you just created and click Open. You’ll see something like this:

DXF files

  1. In Notepad, press Ctrl + F and enter entities to find the section that contains entities (drawing objects). Here’s a crib sheet for what you’ll see:

DXF codes

Now you know a few of the DXF codes:

  • 0: Name
  • 10: X coordinate of start point (of a line)
  • 20: Y coordinate of start point (of a line)
  • 11: X coordinate of end point (of a line)
  • 21: Y coordinate of end point (of a line)

Note: You can find all the codes in AutoCAD Help. In the Help window, click on Contents tab> AutoLISP, Visual LISP, and DXF> DXF Reference. There, you can look in the ENTITIES section for the specific codes as they apply to specific objects.

  1. Return to AutoCAD and click Open from the Standard or Quick Access toolbar.
  2. In the Select File dialog box, from the Files of Type drop-down list, choose DXF (*.dxf).
  3. Choose the file you just created and click Open. The DXF file opens with your line displayed.

You can modify a drawing by editing its DXF file. Follow these steps:

  1. In AutoCAD, use the ID command to check out the coordinates of the start and end point of the line. Write down the numbers.
  2. In AutoCAD, close the DXF file. Don’t save changes if prompted, because this will change the DXF file.
  3. Go back to the DXF file in Notepad.
  4. Change the numbers after the 10, 20, 11, and 21 codes. Don’t change anything else.
  5. Save the file.
  6. Re-open the file in AutoCAD. Your line is now different, using the X and Y coordinates that you specified in the DXF file in Notepad.

Now, let’s say that you have some text that you want to globally change, such as block attributes. Perhaps you want to change all instances of AB to CD. You can use the -ATTEDIT command to create global changes in attribute values, but perhaps you prefer to do this in a text environment. Here’s how to do this:

  1. Save the drawing as a DXF file.
  2. Open the DXF file in Notepad.
  3. Use the Find feature to search for AB. When you find it, change it to CD.

Continue on in this way.

You can even open the DXF file in WordPad or Microsoft Word and use the Replace feature. However, I don’t recommend using the Replace All button, because DXF files insert lots of codes that may have the text string you want to change.

When you’re done, save the file, re-open it in AutoCAD and the drawing will have the changes you made. Don’t forget to save in DWG format again

Ellen Finkelstein

2 comments to Use the DXF format to edit drawings

  • Modify dxf | Asianevangelis

    […] Use the DXF format to edit drawings – EllenFinkelstein.comAutoCAD supports Autodesk’s DXF (Drawing Interchange File) format, which is a text-only format that contains a 2D drawing’s information. The DXF format is … […]

  • jeff

    I have a minimum .DXF file that has lines with – coordinates. When imported these are shifted (by there limits) so that these lines appear in positive coordinate space. What do I need to add to this file so nothing is shifted?

Leave a Reply

You can use these HTML tags

<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>