Visual LISP, AutoLISP and General Customization
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

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

7 REPLIES 7
SOLVED
Reply
Message 1 of 8
Anonymous
12787 Views, 7 Replies

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

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

 

 

 

7 REPLIES 7
Message 2 of 8
wayne.brill
in reply to: Anonymous

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

Message 3 of 8
Anonymous
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

Message 4 of 8
kdub_nz
in reply to: Anonymous

>>> If possible please clarify

 

 

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

 

Regards

 


// Called Kerry in my other life.

Everything will work just as you expect it to, unless your expectations are incorrect.
Sometimes the question is more important than the answer.

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

Message 5 of 8
Anonymous
in reply to: kdub_nz

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

Message 6 of 8
kdub_nz
in reply to: Anonymous

 

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

 


// Called Kerry in my other life.

Everything will work just as you expect it to, unless your expectations are incorrect.
Sometimes the question is more important than the answer.

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

Message 7 of 8
Anonymous
in reply to: kdub_nz

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
Message 8 of 8
Anonymous
in reply to: Anonymous

What about the other codes:

 

Current, Max, Newest, and Unknown? 

 

What happens to the drawing when each of the above are chosen?

 

- Cb

 

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

AutoCAD Inside the Factory


Autodesk Design & Make Report