Override Save command

Override Save command

Anonymous
Not applicable
1,976 Views
9 Replies
Message 1 of 10

Override Save command

Anonymous
Not applicable

Hello,

Because a lot of our users are still on AutoCAD 2010, I have the requirement to be able to always save the drawings that are being worked on in 2015 down to 2010.  I want to make AutoCAD always save down to 2010 when using my .NET app.  I searched but could not find anything on exactly how you would accomplish that.  I can't just put a button on my form for user to push as I cannot be certain that they won't press the AutoCAD save instead.

 

Thanks!

0 Likes
1,977 Views
9 Replies
Replies (9)
Message 2 of 10

Keith.Brown
Advisor
Advisor
Try the DefaultFormatForSave system variable. Just trap the save command using an event handler and set the variable before the save begins.

http://knowledge.autodesk.com/support/autocad/troubleshooting/caas/sfdcarticles/sfdcarticles/Changin...
0 Likes
Message 3 of 10

Anonymous
Not applicable

Hi there,

I cannot seem to find that setvar variable in the list.  When i try to type it in, AutoCAD 2015 does not recognize it.  Could it be called something else in 2015?

 

Thanks

0 Likes
Message 4 of 10

Keith.Brown
Advisor
Advisor

It is a environment variable and not a system variable so you will not see it.

 

Check out this link.

 

http://blog.jtbworld.com/2005/11/set-environment-variable-using-vbnet.html

 

 

You might also check out this link.

 

https://msdn.microsoft.com/en-us/library/z46c489x.aspx

 

 

 

 

0 Likes
Message 5 of 10

Anonymous
Not applicable

I tried to make the environment variable idea work, but for some reason it is not reading it when it attempts to save.  Instead I am just going to wrap the save command into a function I have, but when I do a

acCurdb.SaveAs(acCurdb.Filename,DwgVersion.AC1024)

I get an error of eFileSharingViolation.  I am guessing because I am trying to do a saveas over the existing drawing.  If I cannot do a saveas over the existing drawing, how can I save the current drawing to 2010 format without renaming it as an alternate name.  That just won't work if I have to name the filename something else.

 

Thanks

 

0 Likes
Message 6 of 10

Anonymous
Not applicable

Any ideas on this?

 

Thanks

0 Likes
Message 7 of 10

Keith.Brown
Advisor
Advisor

Try saving the document instead of the database.

 

Here is a link to some code that does just that.

 

http://www.theswamp.org/index.php?topic=42016.0

 

p.s.  a simple google search of autocad .net save database turned up this answer.

0 Likes
Message 8 of 10

Anonymous
Not applicable

I am just finding that it does not help with the fact that I have to save the current document in a lower version.  See my code below to see what I am trying to do.  For the time being, all drawing files must be saved down to acad2010, and I cannot rely on the users to save down to 2010 on each exit... I am lucky to get them to save it period.  It causes massive problems specifically in the batch processing I run in acad2010 routines.  

 

So I am trying to save down to 2010 through the document as you had suggested, and there is a function for doc.formatforsave, but I cannot find any help or details on this anywhere.  Could you please take a look at my code below and suggest what I should do to make it save down to 2010?

 

Thanks

 

Dim acdoc As Document = Application.DocumentManager.MdiActiveDocument

Dim acCurdb As Database = acdoc.Database

Dim ed As Editor = acdoc.Editor


Using acdoc.LockDocument()
Dim acadDoc As Object = acdoc.FormatForSave()
acadDoc.Save()
end using

0 Likes
Message 9 of 10

Anonymous
Not applicable

Or could we use

Autodesk.AutoCAD.ApplicationServices.DocumentSaveFormat()?  Not sure which way makes the most sense.

0 Likes
Message 10 of 10

Anonymous
Not applicable

Is there a reason you don't just do it this way..?

 

<CommandMethod("CustomSave")> _
    Sub CSave()
        Dim CurDWG As Database = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument.Database
        CurDWG.SaveAs(CurDWG.Filename, True, DwgVersion.AC1024, CurDWG.SecurityParameters)
    End Sub

 

 

 

?

 

just curious..

 

 

 

dwgversion list can be found here:

http://forums.autodesk.com/t5/net/how-to-determine-the-version-of-autocad-dwg-file-using-vb-net/td-p...

0 Likes