.NET

Reply
Active Contributor
NayaraFJ
Posts: 42
Registered: ‎08-11-2011
Message 1 of 7 (304 Views)

How to save a file in DXF?

304 Views, 6 Replies
10-11-2011 04:26 AM

Please help!

*Expert Elite*
Alfred.NESWADBA
Posts: 8,892
Registered: ‎06-29-2007
Message 2 of 7 (300 Views)

Betreff: How to save a file in DXF?

10-11-2011 04:50 AM in reply to: NayaraFJ

Hi,

 

is that what you are missing?

   <Runtime.CommandMethod("ADESK_saveAsDxf")> _
   Public Shared Sub ADESK_saveAsDxf()
      Dim tFileName As String = "C:\TEMP\myDxfFileName.DXF"
      Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument.Database.DxfOut(tFileName, 6, Autodesk.AutoCAD.DatabaseServices.DwgVersion.Current)
   End Sub

 

- alfred -

-------------------------------------------------------------------------
Alfred NESWADBA
Ingenieur Studio HOLLAUS ... www.hollaus.at
-------------------------------------------------------------------------
Active Contributor
NayaraFJ
Posts: 42
Registered: ‎08-11-2011
Message 3 of 7 (297 Views)

Betreff: How to save a file in DXF?

10-11-2011 04:58 AM in reply to: Alfred.NESWADBA

I used this code:

 

        [CommandMethod("DrawingSaved")]
        public static void DrawingSaved()
        {
            Document acDoc = Application.DocumentManager.MdiActiveDocument;

            Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument.Database.DxfOut(acDoc.Name, 6, Autodesk.AutoCAD.DatabaseServices.DwgVersion.Current);

        }

 But it's giving error:  Exception was unhandles by user code

 

eFileAccessErr

*Expert Elite*
Alfred.NESWADBA
Posts: 8,892
Registered: ‎06-29-2007
Message 4 of 7 (294 Views)

Betreff: How to save a file in DXF?

10-11-2011 05:09 AM in reply to: NayaraFJ

Hi,

 

if you take acDoc.Name as name for your DXF-file you will recognize, that it will have included the extension ".DWG", but if you want to save it as DXF you should have DXF as extension :smileywink:

 

   <Runtime.CommandMethod("ADESK_saveAsDxf")> _
   Public Shared Sub ADESK_saveAsDxf()
      Dim tAcadDoc As ApplicationServices.Document = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument
      Dim tFileName As String = tAcadDoc.Name
      If tFileName.ToUpper.EndsWith(".DWG") Then tFileName = Left(tAcadDoc.Name, tAcadDoc.Name.Length - 4) & ".DXF"
      tAcadDoc.Database.DxfOut(tFileName, 6, Autodesk.AutoCAD.DatabaseServices.DwgVersion.Current)
   End Sub

 HTH, - alfred -

-------------------------------------------------------------------------
Alfred NESWADBA
Ingenieur Studio HOLLAUS ... www.hollaus.at
-------------------------------------------------------------------------
Active Contributor
NayaraFJ
Posts: 42
Registered: ‎08-11-2011
Message 5 of 7 (290 Views)

Re: How to save a file in DXF?

10-11-2011 05:59 AM in reply to: NayaraFJ

My file was already in the extension. Dxf

:smileyhappy: Since yesterday I'm puzzling over it but nothing works :smileysad:

 

It worked using the command line.

 

 

 

 acadDocument.SetVariable("FILEDIA", 0);

 acadDocument.SendCommand("SAVE " + FileTxt.FullName + "\nv\n2007\n16\nyes\n");

 acadDocument.SetVariable("FILEDIA", 1);

 

I was creating a dll just to save, so it is better not to have to create a dll.

 

 

Thank you!



*Expert Elite*
Alfred.NESWADBA
Posts: 8,892
Registered: ‎06-29-2007
Message 6 of 7 (286 Views)

Re: How to save a file in DXF?

10-11-2011 06:09 AM in reply to: NayaraFJ

Hi,

 

>> My file was already in the extension. Dxf

Ok, the more info, the better we can "debug" :smileywink:

 

Well the DXFOUT-function exports the current drawing, but it is not to compare with SAVEAS, it's more like WBLOCK. And for WBLOCK you know, that if you are working on a drawing AA.DWG you cannot start WBLOCK and export some elements to AA.DWG ==> you have to take another filename.

And same situation is to use for DXFOUT, you cannot use the same name as you already have opened.

 

- alfred -

-------------------------------------------------------------------------
Alfred NESWADBA
Ingenieur Studio HOLLAUS ... www.hollaus.at
-------------------------------------------------------------------------
Active Contributor
NayaraFJ
Posts: 42
Registered: ‎08-11-2011
Message 7 of 7 (284 Views)

Re: How to save a file in DXF?

10-11-2011 06:21 AM in reply to: Alfred.NESWADBA

That must be what was wrong then.
Good to know, I'll try!
 :smileyhappy:

 

 

You are not logged in.

Log into access your profile, ask and answer questions, share ideas and more. Haven't signed up yet? Register

Announcements
Are you familiar with the Autodesk Expert Elites? The Expert Elite program is made up of customers that help other customers by sharing knowledge and exemplifying an engaging style of collaboration. To learn more, please visit our Expert Elite website.

Need installation help?

Start with some of our most frequented solutions to get help installing your software.

Ask the Community