Click here to Skip to main content
Licence 
First Posted 24 Jan 2000
Views 140,169
Bookmarked 39 times

Writing AutoCad DXF files

By | 24 Jan 2000 | Article
A simple class for writing AutoCad DXF files
  • Download source files - 16 Kb
  • Sample Image - DxfFiles.jpg

    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

    About the Author

    Claude Gagnon



    Canada Canada

    Member



    Sign Up to vote   Poor Excellent
    Add a reason or comment to your vote: x
    Votes of 3 or less require a comment

    Comments and Discussions

     
    You must Sign In to use this message board. (secure sign-in)
     
    Search this forum  
     FAQ
        Noise  Layout  Per page   
      Refresh
    GeneralMy vote of 5 Pinmembermanoj kumar choubey0:00 18 Feb '12  
    GeneralMy vote of 2 PinmemberFortranist22:14 20 Oct '09  
    GeneralMy vote of 1 PinmemberAlexandre GRANVAUD21:51 18 Mar '09  
    QuestionHow to write an ellipse? Pinmembermudong16:45 30 Jul '06  
    GeneralDXF to C++ Pinsussulubilge12853:29 4 Feb '05  
    GeneralRe: DXF to C++ PinmemberEinsteinJ0:40 8 Feb '05  
    QuestionHow to manipulate AutoCAD files PinmemberGasanov21:39 6 Jul '04  
    GeneralGreat Introduction PinmemberTheBigW4:25 3 Mar '04  
    GeneralRe: Great Introduction PinmemberGagnon Claude15:43 3 Mar '04  
    GeneralCan you help me with better DXF file format understanding PinmemberValeryK2:17 11 Mar '04  
    GeneralRe: Can you help me with better DXF file format understanding PinmemberTheBigW2:27 11 Mar '04  
    GeneralRe: Can you help me with better DXF file format understanding PinmemberGagnon Claude15:57 11 Mar '04  
    General[Message Deleted] PinmemberChuzhakin0:59 1 Nov '05  
    General[Message Deleted] PinmemberChuzhakin0:59 1 Nov '05  
    GeneralCan't open in CorelDraw PinmemberManikandan17:58 24 Dec '01  
    GeneralI need more about DXF Pinmembergazman20:10 3 Jul '01  
    GeneralRe: I need more about DXF Pinmemberreal name20:39 3 Jul '01  
    GeneralRe: I need more about DXF PinmemberJohannes20:58 3 Jul '01  
    QuestionDo you have also LightWave and DirectX? PinsussLev0:08 8 Feb '00  
    AnswerRe: Do you have also LightWave and DirectX? PinsussClaude Gagnon10:40 11 Feb '00  
    QuestionWhere is source code ? PinsussZuccaro Gianfranco21:11 25 Jan '00  
    AnswerRe: Where is source code ? PinsussChris Maunder10:28 26 Jan '00  

    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.

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