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
Solved! Go to Solution.
Solved by kdub_nz. Go to Solution.
Solved by wayne.brill. Go to Solution.
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
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
>>> 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
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
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
Version history
DWG R1.0 | MC0.0 | AutoCAD Release 1.0 |
DWG R1.2 | AC1.2 | AutoCAD Release 1.2 |
DWG R1.40 | AC1.40 | AutoCAD Release 1.40 |
DWG R2.05 | AC1.50 | AutoCAD Release 2.05 |
DWG R2.10 | AC2.10 | AutoCAD Release 2.10 |
DWG R2.21 | AC2.21 | AutoCAD Release 2.21 |
DWG R2.22 | AC1001, AC2.22 | AutoCAD Release 2.22 |
DWG R2.50 | AC1002 | AutoCAD Release 2.50 |
DWG R2.60 | AC1003 | AutoCAD Release 2.60 |
DWG R9 | AC1004 | AutoCAD Release 9 |
DWG R10 | AC1006 | AutoCAD Release 10 |
DWG R11/12 | AC1009 | AutoCAD Release 11, AutoCAD Release 12 |
DWG R13 | AC1012 | AutoCAD Release 13 |
DWG R14 | AC1014 | AutoCAD Release 14 |
DWG 2000 | AC1015 | AutoCAD 2000, AutoCAD 2000i, AutoCAD 2002 |
DWG 2004 | AC1018 | AutoCAD 2004, AutoCAD 2005, AutoCAD 2006 |
DWG 2007 | AC1021 | AutoCAD 2007, AutoCAD 2008, AutoCAD 2009 |
DWG 2010 | AC1024 | AutoCAD 2010, AutoCAD 2011, AutoCAD 2012 |
DWG 2013 | AC1027 | AutoCAD 2013 |
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.