.NET

Reply
Valued Contributor
RamanSBV
Posts: 86
Registered: ‎02-28-2012
Message 1 of 11 (305 Views)
Accepted Solution

Saving active drawing file.

305 Views, 10 Replies
05-17-2012 11:13 PM

Hi,

 

Could please any body give the suggestion on how to save active drawing file with filename..

 

Regards,

Raman

 

 

 

Mentor
BrentBurgess1980
Posts: 161
Registered: ‎06-16-2008
Message 2 of 11 (302 Views)

Re: Saving active drawing file.

05-17-2012 11:35 PM in reply to: RamanSBV

Take a look at the Database.SaveAs Method.

 

Using AcApp = Autodesk.AutoCAD.ApplicationServices.Application;

 

//Inside your function

AcApp.DocumentManager.MdiActiveDocument.Database.SaveAs();

 

Valued Contributor
RamanSBV
Posts: 86
Registered: ‎02-28-2012
Message 3 of 11 (300 Views)

Re: Saving active drawing file.

05-17-2012 11:36 PM in reply to: BrentBurgess1980

Thanks for your post

 

Please suggest me, how i can give the file name for un saved file.

 

Regards,

Raman

*Expert Elite*
Alfred.NESWADBA
Posts: 8,867
Registered: ‎06-29-2007
Message 4 of 11 (299 Views)

Re: Saving active drawing file.

05-17-2012 11:38 PM in reply to: RamanSBV

Hi,

 

if you want just to save a drawing:

  ApplicationServices.Application.DocumentManager.MdiActiveDocument.Database.Save

In this case you should first compare it the file already has an assigned name!

 

If you want to give the file a new name the use:

  Dim tFilename as String = "C:\TEMP\XX.DWG"

  Dim tVersion as DatabaseServices.DwgVersion = DatabaseServices.DwgVersion.Current

  ApplicationServices.Application.DocumentManager.MdiActiveDocument.Database.SaveAs(tFileName,tVersion)

In this case yo should first check that the file does not exist before you start save!

 

...assuming you have these Import-settings on top of your file:

Imports Autodesk.AutoCAD

 

HTH, - alfred -

-------------------------------------------------------------------------
Alfred NESWADBA
Ingenieur Studio HOLLAUS ... www.hollaus.at
-------------------------------------------------------------------------
Valued Contributor
RamanSBV
Posts: 86
Registered: ‎02-28-2012
Message 5 of 11 (294 Views)

Re: Saving active drawing file.

05-18-2012 12:15 AM in reply to: Alfred.NESWADBA

 

 

 

 

 

I am getting below error while saving autocad file with file name. Please help me on this.eRROR

*Expert Elite*
Alfred.NESWADBA
Posts: 8,867
Registered: ‎06-29-2007
Message 6 of 11 (292 Views)

Re: Saving active drawing file.

05-18-2012 12:17 AM in reply to: RamanSBV

Hi,

 

to be honest ... can you read the text on your screenshot within your post?

If so let me know what browser you are using.

 

- alfred -

-------------------------------------------------------------------------
Alfred NESWADBA
Ingenieur Studio HOLLAUS ... www.hollaus.at
-------------------------------------------------------------------------
Mentor
BrentBurgess1980
Posts: 161
Registered: ‎06-16-2008
Message 7 of 11 (288 Views)

Re: Saving active drawing file.

05-18-2012 12:24 AM in reply to: Alfred.NESWADBA

From what little I could make out of the screenshot, it looks like it was "eWasOpenForWrite". I could be mistaken though...

Valued Contributor
RamanSBV
Posts: 86
Registered: ‎02-28-2012
Message 8 of 11 (284 Views)

Re: Saving active drawing file.

05-18-2012 12:29 AM in reply to: Alfred.NESWADBA

Yeh.... Sorry....Please check this screen shot.ERROR.png

Mentor
BrentBurgess1980
Posts: 161
Registered: ‎06-16-2008
Message 9 of 11 (280 Views)

Re: Saving active drawing file.

05-18-2012 12:38 AM in reply to: RamanSBV

You might need to lry locking the document

 

using (DocumentLock dLock = AcApp.DocumentManager.MdiActiveDocument.LockDocument())
                {
                string tFilename = @"C:\TEMP\XX.DWG";
                Autodesk.AutoCAD.DatabaseServices.DwgVersion tVersion = Autodesk.AutoCAD.DatabaseServices.DwgVersion.Current;
                AcApp.DocumentManager.MdiActiveDocument.Database.SaveAs(tFilename, tVersion);
                }

 

 

 

*Expert Elite*
Alfred.NESWADBA
Posts: 8,867
Registered: ‎06-29-2007
Message 10 of 11 (278 Views)

Re: Saving active drawing file.

05-18-2012 12:42 AM in reply to: RamanSBV

Hi,

 

have you installed the latest servicepacks? Did you run any code before you try to save and does this error also occure if yo udefine a command just doing that save?

 

To the error itself: it may not be a coding-fault as >>>this search<<< shows multiple appearances of this message.

 

- alfred -

-------------------------------------------------------------------------
Alfred NESWADBA
Ingenieur Studio HOLLAUS ... www.hollaus.at
-------------------------------------------------------------------------

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