 |
Autodesk |
 |
Tutorial |


Use the DXF Format to Edit Drawings
Jan 17, 2009
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.
- Open a new drawing based on the default acad.dwt template.
- Draw one line.
- Save the drawing.
- 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).
- Leave the default file name and click Save.
- Close the drawing. (AutoCAD may ask you to save again in DWG
format.)
- Open Notepad. Choose File> Open.
- In the Open dialog box, click the drop-down list that
displays Text Documents (*.txt) and choose All Files (*.*).
- Choose the file you just created and click Open. You'll see
something like this:

- 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:

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.
- Return to AutoCAD and click Open from the Standard or Quick
Access toolbar.
- In the Select File dialog box, from the Files of Type
drop-down list, choose DXF (*.dxf).
- 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:
- In AutoCAD, use the ID command to check out the coordinates
of the start and end point of the line. Write down the numbers.
- In AutoCAD, close the DXF file. Don't save changes if
prompted, because this will change the DXF file.
- Go back to the DXF file in Notepad.
- Change the numbers after the 10, 20, 11, and 21 codes. Don't
change anything else.
- Save the file.
- 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:
- Save the drawing as a DXF file.
- Open the DXF file in Notepad.
- 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
About the Author
More Autodesk
More AutoCAD Step by Step Articles by Ellen Finkelstein
|