Saving an external/side Database

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hey all,
I've been coming up with issues writing changes to an external database (one that is lazy-loaded via Database.readDwgFile()).
While constructing this post I decided to do a couple more tests to make sure that my setup was not working.
What I found is that it was working!
Regardless, I would still like to add to the .NET forums by creating some documentation in case someone else needs it.
When working with an external database or side database that is NOT loaded into the AutoCAD editor, I needed to save changes that were made. Normally, I'd expect that after a transaction is commited, then the changes would reflect... this is NOT what happened.
So I've added this line of code in order to save the database after all changes were committed:
database.SaveAs(drawing.FullName, true, DwgVersion.Current, database.SecurityParameters);
This method works as described in ObjectARX - Managed Class Reference documentation:
Database.SaveAs MethodRuns the save process on the database and writes the drawing information out to fileName. The fileName argument is taken as is. If no file extension is present, .dwg is not appended.
If the database executing the SaveAs() function is not the current database in the AutoCAD editor, then the thumbnail preview image is not saved to fileName.
To specify security parameters, set security that conveys your preferences.If the security is not properly initialized, the method fails. See SecurityParameters for more information on initializing this struct.
If bBakAndRename is false, then no .bak file is created, a full save is always done, and if the Database being saved is the main database for a document in AutoCAD, then the document's filename will NOT change to the saved name.
Now, when I open the drawing manually, I notice the changes made by the .NET assembly.
I also want to put up here, since it is partially relevant, that I am NOT required to Commit the Transaction for changes to take effect. This appears to be the default behavior upon the closing of a transaction. However, if the transaction is aborted, then no changes are made.