• Industries
  • Products
  • Buy
  • Services & Support
  • Communities
  • Discussion Groups

    Visual LISP, AutoLISP and General Customization

    Reply
    Member
    Ramesh_venkat
    Posts: 3
    Registered: ‎10-19-2011
    Accepted Solution

    How to save *.DWG format to *.DXF format

    1999 Views, 6 Replies
    10-19-2011 05:15 AM

    Hi, I am new to AutoCAD Customization (using C#). I am trying to save a *.DWG file to *.DXF format. The DXF file is created, but when i tried to open the same DXF file in AutoCAD,it is showing as "not a Valid DXF file".

     

    Code :

    // Open *.DWG file

    Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.Open("..\..\abc.dwg",true);

    // Save to *.DXF format

    Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument.Database.Saveas("..\..\def.dxf",Autodesk.AutoCAD.DatabaseServices.DwgVersion.Current);

    // Close and discard changes,if any

    Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument.CloseAndDiscard();

     

    ONE MORE THING... When i used the saveas command in Autocad, it is showing different dxf file formats(AutoCAD 2010 DXF,AutoCAD 2007 /LT 2007 DXF etc..). How to save in particular DXF format. If possible give me a sample C# code for this.

     

    Thanks in Advance,

    Venkata Ramesh V

     

     

     

    Please use plain text.
    ADN Support Specialist
    Posts: 54
    Registered: ‎08-25-2004

    Re: How to save *.DWG format to *.DXF format

    10-19-2011 11:48 AM in reply to: Ramesh_venkat

    Hi,

     

    Try using  the DxfOut function of the database. Here is a C# example that saves a DXF to an older format.

     

    CommandMethod("dxfout12")]
    static public void My_dxfout12()
    {
    Database db = Application.DocumentManager.MdiActiveDocument.Database;
    int precision = 16;
    db.DxfOut("r12.dxf", precision, DwgVersion.AC1009);

    }


    You can set the drawing version using the Autodesk.AutoCAD.DatabaseServices.DwgVersion.  

     

    Also for AutoCAD .NET questions I would suggest posting in the .NET  discussion group.

     

    Cheers,

    Wayne Brill

    Autodesk Developer Network



    Wayne Brill
    Developer Technical Services
    Autodesk Developer Network

    Please use plain text.
    Member
    Ramesh_venkat
    Posts: 3
    Registered: ‎10-19-2011

    Re: How to save *.DWG format to *.DXF format

    10-20-2011 04:19 AM in reply to: wayne.brill

    Hi Wanye,

       Its working, i tried the same DXFout fucntion last night, but had a doubt that time regarding the Version. I thought like the DWGVersion means the Version of the file that we are going to Save. Anyways things are clear now.Finally 2 small things to clarify

     

    1. I checked the ObjectARX for AutoCAD 2011 for "DwgVersion Enumeration" where in i found something like AC1001 = 8, AC1002 = 9..etc but i couldn't make any sense which one belongs to which version(like AC1001 for 2010,AC1002 for 2007 etc..) So where can i get this help.

     

    2. While i'm searching for this DXFOut function i came across "GetSupportedDXFOutVersions()" , it is returning

    AC1800,AC1015,AC1012(i'm using AutoCAD 2011). I thought that i can save my DWG file to DXF in only mentioned three formats(Versions). but i'm able to use all the Versions while saving to DXF,instead of only above mentioned three versions.

    i.e i can use

    Autodesk.AutoCAD.DatabaseServices.DWGVersion.AC1024 (even though GetSupportedDXFOutVersions() didnt returned the value AC1024).

    If possible please clarify/Brief me on this.

     

    Thanks for the DIscussion_Admin(Group/Member) for moving my post to right place and Thanks for your advice wyane.From now i will post these type of things in .NET forum.

     

    Venkata Ramesh V

    Please use plain text.
    Valued Mentor
    KerryBrown
    Posts: 259
    Registered: ‎11-29-2008

    Re: How to save *.DWG format to *.DXF format

    10-20-2011 06:11 AM in reply to: Ramesh_venkat

    >>> If possible please clarify

     

     

    http://en.wikipedia.org/wiki/.dwg

     

    Regards

     

    //-------------------------------------------------------

    class keyThumper<T> : Lazy<T>;      another  Swamper


    I do not endorse the social media app links below:smileyembarrassed:

    Please use plain text.
    Member
    Ramesh_venkat
    Posts: 3
    Registered: ‎10-19-2011

    Re: How to save *.DWG format to *.DXF format

    10-20-2011 10:32 PM in reply to: KerryBrown

    Thanks Kerry for the link. I checked the link, found some helpfull stuff there. I found almost all the enum's, but i couldn't found

    AC1800 which my GetSupportedSaveVersions() returned when i called it in AutoCAD-2011 environment. Any idea on this enum.

     

    Thanks for the help.

     

    Venkata Ramesh V

    Please use plain text.
    Valued Mentor
    KerryBrown
    Posts: 259
    Registered: ‎11-29-2008

    Re: How to save *.DWG format to *.DXF format

    10-21-2011 05:22 PM in reply to: Ramesh_venkat

     

    The enumerators are

     

     

    [Wrapper("AcDb::AcDbDwgVersion ")]
    public enum DwgVersion
    {
        AC1001 = 8,
        AC1002 = 9,
        AC1003 = 10,
        AC1004 = 11,
        AC1005 = 12,
        AC1006 = 13,
        AC1007 = 14,
        AC1008 = 15,
        AC1009 = 0x10,
        AC1010 = 0x11,
        AC1011 = 0x12,
        AC1012 = 0x13,
        AC1013 = 20,
        AC1014 = 0x15,
        AC1015 = 0x17,
        AC1021 = 0x1b,
        AC1024 = 0x1d,
        AC1500 = 0x16,
        AC1800 = 0x19,
        AC1800a = 0x18,
        AC1To2 = 1,
        AC1To40 = 2,
        AC1To50 = 3,
        AC2100a = 0x1a,
        AC2400a = 0x1c,
        AC2To10 = 5,
        AC2To20 = 4,
        AC2To21 = 6,
        AC2To22 = 7,
        Current = 0x1d,
        Max = 0x7fff,
        MC0To0 = 0,
        Newest = 0x1d,
        Unknown = 0x7ffe
    }

     My short research indicates AC1800 represents 2004

     

    Regards

     

    //-------------------------------------------------------

    class keyThumper<T> : Lazy<T>;      another  Swamper


    I do not endorse the social media app links below:smileyembarrassed:

    Please use plain text.
    Active Member
    Posts: 8
    Registered: ‎12-20-2012

    Re: How to save *.DWG format to *.DXF format

    01-11-2013 05:09 PM in reply to: KerryBrown

    Version history

    Version Internal version AutoCAD versions
    DWG R1.0MC0.0AutoCAD Release 1.0
    DWG R1.2AC1.2AutoCAD Release 1.2
    DWG R1.40AC1.40AutoCAD Release 1.40
    DWG R2.05AC1.50AutoCAD Release 2.05
    DWG R2.10AC2.10AutoCAD Release 2.10
    DWG R2.21AC2.21AutoCAD Release 2.21
    DWG R2.22AC1001, AC2.22AutoCAD Release 2.22
    DWG R2.50AC1002AutoCAD Release 2.50
    DWG R2.60AC1003AutoCAD Release 2.60
    DWG R9AC1004AutoCAD Release 9
    DWG R10AC1006AutoCAD Release 10
    DWG R11/12AC1009AutoCAD Release 11, AutoCAD Release 12
    DWG R13AC1012AutoCAD Release 13
    DWG R14AC1014AutoCAD Release 14
    DWG 2000AC1015AutoCAD 2000, AutoCAD 2000i, AutoCAD 2002
    DWG 2004AC1018AutoCAD 2004, AutoCAD 2005, AutoCAD 2006
    DWG 2007AC1021AutoCAD 2007, AutoCAD 2008, AutoCAD 2009
    DWG 2010AC1024AutoCAD 2010, AutoCAD 2011, AutoCAD 2012
    DWG 2013AC1027AutoCAD 2013
    Please use plain text.