Click here to Skip to main content
11,577,721 members (62,339 online)
Click here to Skip to main content

Tagged as

Writing AutoCad DXF files

, 24 Jan 2000 159.7K 3K 42
Rate this:
Please Sign up or sign in to vote.
A simple class for writing AutoCad DXF files
  • Download source files - 16 Kb
  • Sample Image - DxfFiles.jpg

    <!-- Article Starts -->

    This article demonstrate how to write an ASCII DXF files. A DXF file is a file composed of sections and associated values. They are read by AutoCad and then converted to a drawing.

    I have developped a class CDxf to write a DXF file from an application. Then the user must use AutoCad to interpret the DXF file.

    I have included only a small portion of what can be do with DXF files. All the details are contained in the following document from the AutoDesk web site : http://www.autodesk.com/techpubs/autocad/dxf/.

    // Here is the code to write a DXF file that will draw a circle in AutoCad.
    // 
    void CDxf::Circle ()
    {
    	// 1000 diameter circle
    	// Creation of an output stream objet in text mode.
    	// ios::app : append
    	ofstream FichierDxf ("TestDxf.dxf", ios::app);
    
    	// Draw the circle
    	FichierDxf << 0          << endl;
    	FichierDxf << "CIRCLE"   << endl;
    	FichierDxf << 8          << endl;       // Group code for layer name
    	FichierDxf << 0          << endl;       // Layer number
    	FichierDxf << 10         << endl;       // Center point of circle
    	FichierDxf << 0.0        << endl;       // X in OCS coordinates
    	FichierDxf << 20         << endl;
    	FichierDxf << 0.0        << endl;       // Y in OCS coordinates
    	FichierDxf << 30         << endl;
    	FichierDxf << 0.0        << endl;       // Z in OCS coordinates
    	FichierDxf << 40         << endl;       // radius of circle
    	FichierDxf << 500.0      << endl;       
    
    	FichierDxf.close();
    }

    By being able to write a DXF file, I can integrate into my applications a way to share information with AutoCad. Obviously there is a lot more that can be added to this class.

    License

    This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

    A list of licenses authors might use can be found here

    Share

    About the Author

    Claude Gagnon
    Canada Canada
    No Biography provided

    You may also be interested in...

    Comments and Discussions

     
    GeneralMy vote of 5 Pin
    manoj kumar choubey18-Feb-12 0:00
    membermanoj kumar choubey18-Feb-12 0:00 
    GeneralMy vote of 2 Pin
    Fortranist20-Oct-09 22:14
    memberFortranist20-Oct-09 22:14 
    GeneralMy vote of 1 Pin
    Alexandre GRANVAUD18-Mar-09 21:51
    memberAlexandre GRANVAUD18-Mar-09 21:51 
    QuestionHow to write an ellipse? Pin
    mudong30-Jul-06 16:45
    membermudong30-Jul-06 16:45 
    GeneralDXF to C++ Pin
    ulubilge12854-Feb-05 3:29
    sussulubilge12854-Feb-05 3:29 
    GeneralRe: DXF to C++ Pin
    EinsteinJ8-Feb-05 0:40
    memberEinsteinJ8-Feb-05 0:40 
    QuestionHow to manipulate AutoCAD files Pin
    Gasanov6-Jul-04 21:39
    memberGasanov6-Jul-04 21:39 
    GeneralGreat Introduction Pin
    TheBigW3-Mar-04 4:25
    memberTheBigW3-Mar-04 4:25 
    GeneralRe: Great Introduction Pin
    Gagnon Claude3-Mar-04 15:43
    memberGagnon Claude3-Mar-04 15:43 
    GeneralCan you help me with better DXF file format understanding Pin
    ValeryK11-Mar-04 2:17
    memberValeryK11-Mar-04 2:17 
    GeneralRe: Can you help me with better DXF file format understanding Pin
    TheBigW11-Mar-04 2:27
    memberTheBigW11-Mar-04 2:27 
    GeneralRe: Can you help me with better DXF file format understanding Pin
    Gagnon Claude11-Mar-04 15:57
    memberGagnon Claude11-Mar-04 15:57 
    General[Message Deleted] Pin
    Chuzhakin1-Nov-05 0:59
    memberChuzhakin1-Nov-05 0:59 
    General[Message Deleted] Pin
    Chuzhakin1-Nov-05 0:59
    memberChuzhakin1-Nov-05 0:59 
    GeneralRe: Can you help me with better DXF file format understanding Pin
    Member 1062317727-Feb-14 3:24
    memberMember 1062317727-Feb-14 3:24 
    GeneralCan't open in CorelDraw Pin
    Manikandan24-Dec-01 17:58
    memberManikandan24-Dec-01 17:58 
    GeneralI need more about DXF Pin
    gazman3-Jul-01 20:10
    membergazman3-Jul-01 20:10 
    GeneralRe: I need more about DXF Pin
    real name3-Jul-01 20:39
    memberreal name3-Jul-01 20:39 
    GeneralRe: I need more about DXF Pin
    Johannes3-Jul-01 20:58
    memberJohannes3-Jul-01 20:58 
    QuestionDo you have also LightWave and DirectX? Pin
    Lev8-Feb-00 0:08
    sussLev8-Feb-00 0:08 
    AnswerRe: Do you have also LightWave and DirectX? Pin
    Claude Gagnon11-Feb-00 10:40
    sussClaude Gagnon11-Feb-00 10:40 
    QuestionWhere is source code ? Pin
    Zuccaro Gianfranco25-Jan-00 21:11
    sussZuccaro Gianfranco25-Jan-00 21:11 
    AnswerRe: Where is source code ? Pin
    Chris Maunder26-Jan-00 10:28
    sussChris Maunder26-Jan-00 10:28 

    General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

    Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

    | Advertise | Privacy | Terms of Use | Mobile
    Web04 | 2.8.150603.1 | Last Updated 25 Jan 2000
    Article Copyright 2000 by Claude Gagnon
    Everything else Copyright © CodeProject, 1999-2015
    Layout: fixed | fluid