<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Doc with changed xrefs not saved in .NET Forum</title>
    <link>https://forums.autodesk.com/t5/net-forum/doc-with-changed-xrefs-not-saved/m-p/12433316#M6331</link>
    <description>&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Do you Commit the transaction before saving the Database?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Another thing:&lt;/P&gt;
&lt;PRE&gt;doc.Database.Purge(instances)&lt;/PRE&gt;
&lt;P&gt;does not 'purge' anything. The &lt;A href="https://help.autodesk.com/view/OARX/2023/ENU/?guid=OARX-ManagedRefGuide-Autodesk_AutoCAD_DatabaseServices_Database_Purge_ObjectIdCollection" target="_blank" rel="noopener"&gt;Database.Purge method&lt;/A&gt; only filters the objectIdCollection to return the 'purgeable' ObjectIds. &lt;/P&gt;</description>
    <pubDate>Mon, 11 Dec 2023 14:53:37 GMT</pubDate>
    <dc:creator>_gile</dc:creator>
    <dc:date>2023-12-11T14:53:37Z</dc:date>
    <item>
      <title>Doc with changed xrefs not saved</title>
      <link>https://forums.autodesk.com/t5/net-forum/doc-with-changed-xrefs-not-saved/m-p/12432913#M6330</link>
      <description>&lt;P&gt;I am coding an addin that scans a folder of dwg files recursively and checks if the xrefs need to be set to a new location or have to be removed entirely. The end result should be that each dwg file is ready for importing into a Vault (which will not process dwg files if they have unresolved references).&lt;/P&gt;&lt;P&gt;The code I am using here is based on example code from this forum as well as the example projects in the SDK, where they appear to be working as intended.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am using Application.DocumentManager.Open() to open each of the dwg files in turn (in an autocad session with an empty drawing so I can netload the command and run it. This works as expected, and the first dwg file is opened in the Autocad editor.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I then use this function to get all xrefs in the document that are marked as xref and as unresolved&lt;/P&gt;&lt;PRE&gt;&lt;SPAN&gt;private&lt;/SPAN&gt;&amp;nbsp;List&amp;lt;BlockTableRecord&amp;gt;&amp;nbsp;GetAllXRefs(Document&amp;nbsp;doc,&amp;nbsp;Transaction&amp;nbsp;trans)
{
	List&amp;lt;BlockTableRecord&amp;gt;&amp;nbsp;res&amp;nbsp;=&amp;nbsp;&lt;SPAN&gt;new&lt;/SPAN&gt;&amp;nbsp;List&amp;lt;BlockTableRecord&amp;gt;();
	&lt;SPAN&gt;if&lt;/SPAN&gt;&amp;nbsp;(&lt;SPAN&gt;null&lt;/SPAN&gt;&amp;nbsp;==&amp;nbsp;doc&amp;nbsp;||&amp;nbsp;&lt;SPAN&gt;null&lt;/SPAN&gt;&amp;nbsp;==&amp;nbsp;trans)&amp;nbsp;&lt;SPAN&gt;return&lt;/SPAN&gt;&amp;nbsp;res;
 
	&lt;SPAN&gt;try&lt;/SPAN&gt;
	{
		doc.Database.ResolveXrefs(&lt;SPAN&gt;true&lt;/SPAN&gt;,&amp;nbsp;&lt;SPAN&gt;false&lt;/SPAN&gt;);&amp;nbsp;&lt;SPAN&gt;//&amp;nbsp;try&amp;nbsp;to&amp;nbsp;resolve&amp;nbsp;any&amp;nbsp;unresolved&amp;nbsp;xrefs&amp;nbsp;in&amp;nbsp;the&amp;nbsp;database&lt;/SPAN&gt;
		XrefGraph&amp;nbsp;graph&amp;nbsp;=&amp;nbsp;doc.Database.GetHostDwgXrefGraph(&lt;SPAN&gt;true&lt;/SPAN&gt;);
		List&amp;lt;BlockTableRecord&amp;gt;&amp;nbsp;xrefs&amp;nbsp;=&amp;nbsp;FindUnresolvedXrefs(graph.RootNode,&amp;nbsp;trans);
		&lt;SPAN&gt;if&lt;/SPAN&gt;&amp;nbsp;(&lt;SPAN&gt;null&lt;/SPAN&gt;&amp;nbsp;!=&amp;nbsp;xrefs&amp;nbsp;&amp;amp;&amp;amp;&amp;nbsp;xrefs.Count&amp;nbsp;&amp;gt;&amp;nbsp;0)&amp;nbsp;res.AddRange(xrefs);
	}
	&lt;SPAN&gt;catch&lt;/SPAN&gt;&amp;nbsp;(Exception&amp;nbsp;ex)
	{
		MessageBox.Show(&lt;SPAN&gt;$"Problem&amp;nbsp;in&amp;nbsp;GetAllXRefs&amp;nbsp;(&lt;/SPAN&gt;{ex.Message}&lt;SPAN&gt;)"&lt;/SPAN&gt;);
	}
 
	&lt;SPAN&gt;return&lt;/SPAN&gt;&amp;nbsp;res;
}&lt;/PRE&gt;&lt;P&gt;This function works as well. In my test dwg I have 3 xrefs, one of which is resolved, one of which has been moved to a different folder and one which has been deleted in the folder.&lt;BR /&gt;I then go through these blocktablerecords one at a time and use this function to try and find the unresolved xref in any of a given number of paths, and if that fails remove it from the dwg&lt;/P&gt;&lt;PRE&gt;&lt;SPAN&gt;private&lt;/SPAN&gt;&amp;nbsp;&lt;SPAN&gt;bool&lt;/SPAN&gt;&amp;nbsp;ProcessUnresolved(BlockTableRecord&amp;nbsp;btr,&amp;nbsp;List&amp;lt;ObjectId&amp;gt;&amp;nbsp;toPurge)
{
	&lt;SPAN&gt;if&lt;/SPAN&gt;&amp;nbsp;(btr.XrefStatus&amp;nbsp;!=&amp;nbsp;XrefStatus.Unresolved)&amp;nbsp;&lt;SPAN&gt;return&lt;/SPAN&gt;&amp;nbsp;&lt;SPAN&gt;false&lt;/SPAN&gt;;
 
	Messages.Add(&lt;SPAN&gt;$"XRef&amp;nbsp;&lt;/SPAN&gt;{btr.Name}&lt;SPAN&gt;&amp;nbsp;was&amp;nbsp;unresolved&amp;nbsp;or&amp;nbsp;not&amp;nbsp;found.&amp;nbsp;It&amp;nbsp;was&amp;nbsp;unloaded&amp;nbsp;from&amp;nbsp;the&amp;nbsp;document"&lt;/SPAN&gt;);
 
	&lt;SPAN&gt;//&amp;nbsp;Unresolved&amp;nbsp;should&amp;nbsp;not&amp;nbsp;be&amp;nbsp;possible,&amp;nbsp;we&amp;nbsp;force&amp;nbsp;a&amp;nbsp;resolve&amp;nbsp;of&amp;nbsp;the&amp;nbsp;xrefs&amp;nbsp;earlier.&amp;nbsp;In&amp;nbsp;theory&amp;nbsp;the&amp;nbsp;state&amp;nbsp;should&amp;nbsp;either&amp;nbsp;be&amp;nbsp;Resolved&amp;nbsp;or&amp;nbsp;FileNotFound&lt;/SPAN&gt;
	&lt;SPAN&gt;string&lt;/SPAN&gt;&amp;nbsp;xpath&amp;nbsp;=&amp;nbsp;Cmd.General.FindFilesInFolders(Path.GetFileName(btr.PathName));
	&lt;SPAN&gt;if&lt;/SPAN&gt;&amp;nbsp;(&lt;SPAN&gt;string&lt;/SPAN&gt;.IsNullOrEmpty(xpath)&amp;nbsp;||&amp;nbsp;!File.Exists(xpath))
	{
		&lt;SPAN&gt;//&amp;nbsp;xref&amp;nbsp;could&amp;nbsp;not&amp;nbsp;be&amp;nbsp;resolved&lt;/SPAN&gt;
		Messages.Add(&lt;SPAN&gt;$"XRef&amp;nbsp;&lt;/SPAN&gt;{btr.Name}&lt;SPAN&gt;&amp;nbsp;could&amp;nbsp;not&amp;nbsp;be&amp;nbsp;found&amp;nbsp;in&amp;nbsp;any&amp;nbsp;of&amp;nbsp;the&amp;nbsp;search&amp;nbsp;locations.&amp;nbsp;It&amp;nbsp;will&amp;nbsp;be&amp;nbsp;removed&amp;nbsp;from&amp;nbsp;the&amp;nbsp;document&amp;nbsp;(including&amp;nbsp;the&amp;nbsp;instances&amp;nbsp;of&amp;nbsp;this&amp;nbsp;xref!)"&lt;/SPAN&gt;);
		toPurge.Add(btr.Id);
		&lt;SPAN&gt;return&lt;/SPAN&gt;&amp;nbsp;&lt;SPAN&gt;true&lt;/SPAN&gt;;
	}
 
	&lt;SPAN&gt;//&amp;nbsp;the&amp;nbsp;path&amp;nbsp;was&amp;nbsp;changed&lt;/SPAN&gt;
	btr.UpgradeOpen();
	btr.PathName&amp;nbsp;=&amp;nbsp;xpath;
	btr.DowngradeOpen();
	&lt;SPAN&gt;return&lt;/SPAN&gt;&amp;nbsp;&lt;SPAN&gt;true&lt;/SPAN&gt;;&amp;nbsp;&lt;SPAN&gt;//&amp;nbsp;and&amp;nbsp;this&amp;nbsp;document&amp;nbsp;was&amp;nbsp;modified&lt;/SPAN&gt;
 
	&lt;SPAN&gt;//&amp;nbsp;there&amp;nbsp;should&amp;nbsp;be&amp;nbsp;a&amp;nbsp;valid&amp;nbsp;path&amp;nbsp;now,&amp;nbsp;but&amp;nbsp;the&amp;nbsp;xref&amp;nbsp;is&amp;nbsp;still&amp;nbsp;unloaded.&amp;nbsp;Assume&amp;nbsp;that&amp;nbsp;Vault&amp;nbsp;will&amp;nbsp;resolve&amp;nbsp;this&amp;nbsp;correctly.&lt;/SPAN&gt;
	&lt;SPAN&gt;//&amp;nbsp;if&amp;nbsp;we&amp;nbsp;need&amp;nbsp;to&amp;nbsp;move&amp;nbsp;the&amp;nbsp;xref&amp;nbsp;location&amp;nbsp;we&amp;nbsp;do&amp;nbsp;that&amp;nbsp;here&amp;nbsp;(and&amp;nbsp;mark&amp;nbsp;the&amp;nbsp;document&amp;nbsp;as&amp;nbsp;modified&amp;nbsp;again)&lt;/SPAN&gt;
}&lt;/PRE&gt;&lt;P&gt;xrefs that can be found in a new location have their Pathname changed, the ones that cannot be found are added to the toPurge list.&lt;/P&gt;&lt;P&gt;After processing all unresolved xrefs this way the function is called to handle the xrefs that have to be removed entirely&lt;/P&gt;&lt;PRE&gt;&lt;SPAN&gt;private&lt;/SPAN&gt;&amp;nbsp;&lt;SPAN&gt;bool&lt;/SPAN&gt;&amp;nbsp;ProcessPurges(List&amp;lt;ObjectId&amp;gt;&amp;nbsp;toPurge,&amp;nbsp;Document&amp;nbsp;doc,&amp;nbsp;Transaction&amp;nbsp;trans)
{
	&lt;SPAN&gt;if&lt;/SPAN&gt;&amp;nbsp;(&lt;SPAN&gt;null&lt;/SPAN&gt;&amp;nbsp;==&amp;nbsp;toPurge&amp;nbsp;||&amp;nbsp;toPurge.Count&amp;nbsp;&amp;lt;=&amp;nbsp;0)&amp;nbsp;&lt;SPAN&gt;return&lt;/SPAN&gt;&amp;nbsp;&lt;SPAN&gt;false&lt;/SPAN&gt;;
	&lt;SPAN&gt;if&lt;/SPAN&gt;&amp;nbsp;(&lt;SPAN&gt;null&lt;/SPAN&gt;&amp;nbsp;==&amp;nbsp;doc&amp;nbsp;||&amp;nbsp;&lt;SPAN&gt;null&lt;/SPAN&gt;&amp;nbsp;==&amp;nbsp;trans)&amp;nbsp;&lt;SPAN&gt;return&lt;/SPAN&gt;&amp;nbsp;&lt;SPAN&gt;false&lt;/SPAN&gt;;
 
	Messages.Add(&lt;SPAN&gt;$"Purge&amp;nbsp;&lt;/SPAN&gt;{toPurge.Count}&lt;SPAN&gt;&amp;nbsp;missing/unresolved&amp;nbsp;xrefs&amp;nbsp;from&amp;nbsp;the&amp;nbsp;database"&lt;/SPAN&gt;);
	&lt;SPAN&gt;//&amp;nbsp;these&amp;nbsp;have&amp;nbsp;to&amp;nbsp;be&amp;nbsp;removed&amp;nbsp;more&amp;nbsp;thoroughly.&amp;nbsp;not&amp;nbsp;just&amp;nbsp;the&amp;nbsp;btr,&amp;nbsp;but&amp;nbsp;also&amp;nbsp;the&amp;nbsp;references&amp;nbsp;to&amp;nbsp;it&lt;/SPAN&gt;
	ObjectIdCollection&amp;nbsp;instances&amp;nbsp;=&amp;nbsp;&lt;SPAN&gt;new&lt;/SPAN&gt;&amp;nbsp;ObjectIdCollection();
	&lt;SPAN&gt;foreach&lt;/SPAN&gt;&amp;nbsp;(ObjectId&amp;nbsp;id&amp;nbsp;&lt;SPAN&gt;in&lt;/SPAN&gt;&amp;nbsp;toPurge.Distinct())
	{
		BlockTableRecord&amp;nbsp;btr&amp;nbsp;=&amp;nbsp;trans.GetObject(id,&amp;nbsp;OpenMode.ForWrite)&amp;nbsp;&lt;SPAN&gt;as&lt;/SPAN&gt;&amp;nbsp;BlockTableRecord;
		&lt;SPAN&gt;if&lt;/SPAN&gt;&amp;nbsp;(&lt;SPAN&gt;null&lt;/SPAN&gt;&amp;nbsp;==&amp;nbsp;btr)&amp;nbsp;&lt;SPAN&gt;continue&lt;/SPAN&gt;;
 
		instances.Add(id);&amp;nbsp;&lt;SPAN&gt;//&amp;nbsp;we&amp;nbsp;will&amp;nbsp;want&amp;nbsp;to&amp;nbsp;eventually&amp;nbsp;purge&amp;nbsp;the&amp;nbsp;master&amp;nbsp;btr&lt;/SPAN&gt;
		ObjectIdCollection&amp;nbsp;refs&amp;nbsp;=&amp;nbsp;btr.GetBlockReferenceIds(&lt;SPAN&gt;true&lt;/SPAN&gt;,&amp;nbsp;&lt;SPAN&gt;true&lt;/SPAN&gt;);
		&lt;SPAN&gt;foreach&lt;/SPAN&gt;&amp;nbsp;(ObjectId&amp;nbsp;objId&amp;nbsp;&lt;SPAN&gt;in&lt;/SPAN&gt;&amp;nbsp;refs)
		{
			DBObject&amp;nbsp;inst&amp;nbsp;=&amp;nbsp;trans.GetObject(objId,&amp;nbsp;OpenMode.ForWrite);
			inst.Erase();
			instances.Add(objId);
		}
 
		&lt;SPAN&gt;//&amp;nbsp;we&amp;nbsp;removed&amp;nbsp;the&amp;nbsp;instances&amp;nbsp;of&amp;nbsp;this&amp;nbsp;record,&amp;nbsp;we&amp;nbsp;can&amp;nbsp;now&amp;nbsp;also&amp;nbsp;remove&amp;nbsp;the&amp;nbsp;reference&amp;nbsp;itself&lt;/SPAN&gt;
		DB.DetachXref(id);
		btr.Erase();
	}
 
	doc.Database.Purge(instances);
	&lt;SPAN&gt;return&lt;/SPAN&gt;&amp;nbsp;&lt;SPAN&gt;true&lt;/SPAN&gt;;&amp;nbsp;&lt;SPAN&gt;//&amp;nbsp;mark&amp;nbsp;the&amp;nbsp;database&amp;nbsp;as&amp;nbsp;modified&lt;/SPAN&gt;
}&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;The code finds any references to the unresolvable xrefs and removes them, then detaches the xref and marks the btr as erased.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;At this point when I call GetAllXRefs() again I get only 2 childnodes, both of which are marked as resolved. This suggests that the functions that fixed/removed the xrefs have worked correctly.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;However, when I then try to save the modified document with Document.CloseAndSave() it is not saved. if I save it under a different name it is saved, but the unresolved xrefs are still in that copy. If I use Database.SaveAs() instead it again is saved but with the unresolved xrefs still present.&lt;/P&gt;&lt;P&gt;And when I do none of this and leave the document open the GUI xref manager will also show both the original unresolved xrefs as still present in the drawing and both still unresolved.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I must be missing something fairly simple, but it has been a while since I last programmed in the AutoCAD API and that was with C++ so there may be something that does not translate directly to the C# version of the API. Or I just overlooked a detail here.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 11 Dec 2023 12:27:18 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/doc-with-changed-xrefs-not-saved/m-p/12432913#M6330</guid>
      <dc:creator>m.de.vriesTH5VM</dc:creator>
      <dc:date>2023-12-11T12:27:18Z</dc:date>
    </item>
    <item>
      <title>Re: Doc with changed xrefs not saved</title>
      <link>https://forums.autodesk.com/t5/net-forum/doc-with-changed-xrefs-not-saved/m-p/12433316#M6331</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Do you Commit the transaction before saving the Database?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Another thing:&lt;/P&gt;
&lt;PRE&gt;doc.Database.Purge(instances)&lt;/PRE&gt;
&lt;P&gt;does not 'purge' anything. The &lt;A href="https://help.autodesk.com/view/OARX/2023/ENU/?guid=OARX-ManagedRefGuide-Autodesk_AutoCAD_DatabaseServices_Database_Purge_ObjectIdCollection" target="_blank" rel="noopener"&gt;Database.Purge method&lt;/A&gt; only filters the objectIdCollection to return the 'purgeable' ObjectIds. &lt;/P&gt;</description>
      <pubDate>Mon, 11 Dec 2023 14:53:37 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/doc-with-changed-xrefs-not-saved/m-p/12433316#M6331</guid>
      <dc:creator>_gile</dc:creator>
      <dc:date>2023-12-11T14:53:37Z</dc:date>
    </item>
    <item>
      <title>Re: Doc with changed xrefs not saved</title>
      <link>https://forums.autodesk.com/t5/net-forum/doc-with-changed-xrefs-not-saved/m-p/12433491#M6332</link>
      <description>&lt;P&gt;Thank you for your answer.&lt;/P&gt;&lt;P&gt;I am closing both the document lock and the transaction before attempting to save&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This is the code with error handling and such removed.&lt;/P&gt;&lt;P&gt;using (DocumentLock dlock = doc.LockDocument())&lt;BR /&gt;{&lt;BR /&gt;List&amp;lt;BlockTableRecord&amp;gt; xrefs = new List&amp;lt;BlockTableRecord&amp;gt;();&lt;/P&gt;&lt;P&gt;using (Transaction trans = DB.TransactionManager.StartTransaction())&lt;BR /&gt;{&lt;BR /&gt;xrefs = GetAllXRefs(doc, trans);&lt;BR /&gt;List&amp;lt;ObjectId&amp;gt; toPurge = new List&amp;lt;ObjectId&amp;gt;();&lt;BR /&gt;foreach (BlockTableRecord btr in xrefs)&lt;BR /&gt;{&lt;BR /&gt;if (ProcessUnresolved(btr, toPurge)) mod = true;&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;if (ProcessPurges(toPurge, doc, trans)) mod = true;&lt;BR /&gt;}&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;// if anything was changed, save the document (at this point the transaction and lock are already removed)&lt;BR /&gt;if (mod)&lt;BR /&gt;{&lt;BR /&gt;doc.CloseAndSave(path);&lt;BR /&gt;}&lt;BR /&gt;else&lt;BR /&gt;{&lt;BR /&gt;doc.CloseAndDiscard();&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I will remove the calls to Purge() from my code to improve its runtime (when it has to process 35,000+ files)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 11 Dec 2023 15:52:48 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/doc-with-changed-xrefs-not-saved/m-p/12433491#M6332</guid>
      <dc:creator>m.de.vriesTH5VM</dc:creator>
      <dc:date>2023-12-11T15:52:48Z</dc:date>
    </item>
    <item>
      <title>Re: Doc with changed xrefs not saved</title>
      <link>https://forums.autodesk.com/t5/net-forum/doc-with-changed-xrefs-not-saved/m-p/12433565#M6333</link>
      <description>&lt;P&gt;&amp;lt;QUOTE&amp;gt;&lt;/P&gt;
&lt;P&gt;&lt;EM&gt;I am &lt;FONT color="#FF0000"&gt;closing&lt;/FONT&gt; both the document lock and the transaction before attempting to save&lt;/EM&gt;&lt;/P&gt;
&lt;P&gt;&amp;lt;/QUOTE&amp;gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Your code indeed closes the Transaction by the "using (Transaction tran=....){.....}. However, closing DOES NOT MEAN the transaction is committed. if you do not call Transaction.Commit() EXPLICITLY, it is aborted at the end of "using..." block. That is why&amp;nbsp;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/109424"&gt;@_gile&lt;/a&gt;&amp;nbsp;asked you if you commit the transaction or not. It seems you did not.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 11 Dec 2023 16:20:06 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/doc-with-changed-xrefs-not-saved/m-p/12433565#M6333</guid>
      <dc:creator>norman.yuan</dc:creator>
      <dc:date>2023-12-11T16:20:06Z</dc:date>
    </item>
    <item>
      <title>Re: Doc with changed xrefs not saved</title>
      <link>https://forums.autodesk.com/t5/net-forum/doc-with-changed-xrefs-not-saved/m-p/12435789#M6334</link>
      <description>&lt;P&gt;I added the trans.Commit() but still needed to make one more additional change to the code.&lt;/P&gt;&lt;P&gt;Rather than using DocumentManager.Open(path) to load a dwg file in the editor I had to create an empty database and read the dwg file into that.&amp;nbsp; Database.SaveAs(path, version) correctly overwrote the file where Document.Save() did not.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;So&lt;/P&gt;&lt;P&gt;using(Database db = new Database(false, true))&lt;/P&gt;&lt;P&gt;{&lt;BR /&gt;&amp;nbsp;&amp;nbsp; db.ReadDwgFile(path, mode, false, null);&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; ...&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; if (modified) db.SaveAs(path, DwgVersion.CurrentVersion);&lt;/P&gt;&lt;P&gt;}&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;worked for opening, modifying and saving an existing dwg file.&lt;/P&gt;</description>
      <pubDate>Tue, 12 Dec 2023 11:22:48 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/doc-with-changed-xrefs-not-saved/m-p/12435789#M6334</guid>
      <dc:creator>m.de.vriesTH5VM</dc:creator>
      <dc:date>2023-12-12T11:22:48Z</dc:date>
    </item>
  </channel>
</rss>

