<?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: how update dwg files values linkend to excel table. in .NET Forum</title>
    <link>https://forums.autodesk.com/t5/net-forum/how-update-dwg-files-values-linkend-to-excel-table/m-p/9574609#M19640</link>
    <description>&lt;P&gt;While this thread is about DataLink, it seems to me that your issue has nothing to do with calling DataLinkManager.Update().&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Do you use plain AutoCAD, or AutoCAD vertical (Arch/MEP/Mech/Plant3D... especially the one used to create those drawings)? Version?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You may want to do some test to narrow the scope of possible reason(s).&lt;/P&gt;
&lt;P&gt;1. You can comment out db.DataLinkManager.Update() to confirm if the issue is related to DataLink updating.&lt;/P&gt;
&lt;P&gt;2. You can open multiple drawings in AutoCAD, and loop though the opened drawing to update DataLinks and save the change. Verify if the issue occurs or not.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Thu, 11 Jun 2020 15:27:00 GMT</pubDate>
    <dc:creator>norman.yuan</dc:creator>
    <dc:date>2020-06-11T15:27:00Z</dc:date>
    <item>
      <title>how update dwg files values linkend to excel table.</title>
      <link>https://forums.autodesk.com/t5/net-forum/how-update-dwg-files-values-linkend-to-excel-table/m-p/9505859#M19635</link>
      <description>&lt;P&gt;Dear all,&lt;/P&gt;&lt;P&gt;I have several dwg files linked to an excel table.&lt;/P&gt;&lt;P&gt;When I update some values into the exel I need to open each dwg file, than save and close in order to change the values linked&amp;nbsp; (foreach dwg file the commands are: open + _DATALINKUPDATE _U _K +save +close).&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I wonder if there is a way throught .net (C#) in order to handle the whole dwg list once&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Any suggestion will be appreciated&lt;/P&gt;&lt;P&gt;cheers&lt;/P&gt;&lt;P&gt;M.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 11 May 2020 05:57:39 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/how-update-dwg-files-values-linkend-to-excel-table/m-p/9505859#M19635</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2020-05-11T05:57:39Z</dc:date>
    </item>
    <item>
      <title>Re: how update dwg files values linkend to excel table.</title>
      <link>https://forums.autodesk.com/t5/net-forum/how-update-dwg-files-values-linkend-to-excel-table/m-p/9507119#M19636</link>
      <description>&lt;P&gt;Since you are asking in AutoCAD .NET API forum, I assume you are to run some code in AutoCAD to batch updating drawings for the DataLinks in them. Yes, it can be done rather easily. Something like:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;1. Obtain a drawing file list; Then for each drawing;&lt;/P&gt;
&lt;P&gt;2. Open the drawing file as side database;&lt;/P&gt;
&lt;P&gt;3. Call atabase.DataLinkManager.Update() to update all DataLinks; or&lt;/P&gt;
&lt;P&gt;4. Open DataLinkDictionary (by database.DataLinkDictionaryId), and loop through DataLinks and call DataLink.Update() as needed;&lt;/P&gt;
&lt;P&gt;5. Call Database.SaveAs() to save changes made to the side database.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;HTH&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 11 May 2020 15:26:12 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/how-update-dwg-files-values-linkend-to-excel-table/m-p/9507119#M19636</guid>
      <dc:creator>norman.yuan</dc:creator>
      <dc:date>2020-05-11T15:26:12Z</dc:date>
    </item>
    <item>
      <title>Re: how update dwg files values linkend to excel table.</title>
      <link>https://forums.autodesk.com/t5/net-forum/how-update-dwg-files-values-linkend-to-excel-table/m-p/9508925#M19637</link>
      <description>&lt;P&gt;Hi Norman&amp;nbsp;&lt;/P&gt;&lt;P&gt;thank you for your attention. You are right, currently I'm using Autocad commands but my wish is update the links throught .net, the program could work in Autocad or (better) stand alone.&lt;/P&gt;&lt;P&gt;I had some programming experiences for other issues (solved thanks to the forum) but I'm not so skilled and&amp;nbsp; I wonder if is possible to have a draft of the method I should use,&amp;nbsp; could it looks like the follow?&lt;/P&gt;&lt;P&gt;Cheers&lt;/P&gt;&lt;P&gt;M.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="general"&gt;            try
            {
                LogMessageToFile("\n##### START PROCESS #####\n");
                string[] dwgFiles = Directory.GetFiles(pathDwgFiles, "*.dwg", SearchOption.AllDirectories);
                foreach (var dwgfile in dwgFiles)
                {
                    LogMessageToFile("\nProcessing: " + Path.GetFileName(dwgfile));

                    using (var db = OpenSideDatabase(dwgfile))
                    {
                        HostApplicationServices.WorkingDatabase = db;
                        db.RetainOriginalThumbnailBitmap = true;
                        db.Database.DatalinkManager.Update();
                        db.SaveAs(dwgfile, true, DwgVersion.Current, null);
                    }  
                }
            }
            catch (System.Exception ex)
            {
                CadApp.ShowAlertDialog("Error:\r\n" + ex.Message);
            }
            finally
            {
                LogMessageToFile("\n##### END PROCESS #####");
                HostApplicationServices.WorkingDatabase = workingDb;
                Autodesk.AutoCAD.Internal.Utils.PostCommandPrompt();
            }&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 12 May 2020 07:03:05 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/how-update-dwg-files-values-linkend-to-excel-table/m-p/9508925#M19637</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2020-05-12T07:03:05Z</dc:date>
    </item>
    <item>
      <title>Re: how update dwg files values linkend to excel table.</title>
      <link>https://forums.autodesk.com/t5/net-forum/how-update-dwg-files-values-linkend-to-excel-table/m-p/9509827#M19638</link>
      <description>&lt;P&gt;I think your code logic is right (I am sure you know DataLinkManager.Update() has 2 arguments to be supplied: UpdateDirection and UpdateOption).&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Additional things:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;1. You may want to limit how many drawings to be processed in an AutoCAD session, if you have hundreds or even thousands files to update, because of inevitable memory fragment due to repeatedly opening/closing drawing files;&lt;/P&gt;
&lt;P&gt;2. You may want to show some kind of visual progress indicator, such as progress bar UI, so that user knows AutoCAD is doing something as expected.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You cannot do it directly from stand-alone EXE, because there is AutoCAD COM API to access DataLink.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 12 May 2020 13:06:27 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/how-update-dwg-files-values-linkend-to-excel-table/m-p/9509827#M19638</guid>
      <dc:creator>norman.yuan</dc:creator>
      <dc:date>2020-05-12T13:06:27Z</dc:date>
    </item>
    <item>
      <title>Re: how update dwg files values linkend to excel table.</title>
      <link>https://forums.autodesk.com/t5/net-forum/how-update-dwg-files-values-linkend-to-excel-table/m-p/9573647#M19639</link>
      <description>&lt;P&gt;Dear all, I would like to go ahaed with this method so this is my code:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="csharp"&gt;//current session
var openedDb = HostApplicationServices.WorkingDatabase;
try
{
	string[] dwgFiles = Directory.GetFiles(PathDwgFiles, "*.dwg", SearchOption.AllDirectories);
	foreach (var dwgfile in dwgFiles)
	{	
		var db = new Database(false, true);
		db.ReadDwgFile(dwgFileName, FileOpenMode.OpenForReadAndWriteNoShare, false, null);
		using (db)
		{
			HostApplicationServices.WorkingDatabase = db;
			db.RetainOriginalThumbnailBitmap = true;
			
			db.DataLinkManager.Update(UpdateDirection.SourceToData, UpdateOption.None);

			db.SaveAs(dwgfile,true,DwgVersion.Current,null);

			//back to current session
			HostApplicationServices.WorkingDatabase = openedDb;
		}

	}
}&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;the results are quite odd...&lt;/P&gt;&lt;P&gt;I have always the same base-drawing file1.dwg, file2.dwg.... all linked to a common excel file but to different cells. During the process something strange happen: Autocad sorts a message like: "impossible save the file into the speficied format..." and when I open that file all drawing is missing. Follow a image (blue square all is ok, red square drawing is missing)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="HappyEnding.png" style="width: 999px;"&gt;&lt;img src="https://forums.autodesk.com/t5/image/serverpage/image-id/782459i301EE3C25F88B6B7/image-size/large?v=v2&amp;amp;px=999" role="button" title="HappyEnding.png" alt="HappyEnding.png" /&gt;&lt;/span&gt;more and more weird if I test again the same 4 files what was ok and at the first stroke is not ok at the second. Example I test 4 files:&lt;/P&gt;&lt;P&gt;First test File 1, 2 and 4 ok, but 4 wasn't.&lt;/P&gt;&lt;P&gt;Second test File 1 and 3 ok, but 2 and 4 wasn't.&lt;/P&gt;&lt;P&gt;What happen?&lt;/P&gt;&lt;P&gt;Thanks in advance&lt;/P&gt;</description>
      <pubDate>Thu, 11 Jun 2020 07:59:22 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/how-update-dwg-files-values-linkend-to-excel-table/m-p/9573647#M19639</guid>
      <dc:creator>micle.space</dc:creator>
      <dc:date>2020-06-11T07:59:22Z</dc:date>
    </item>
    <item>
      <title>Re: how update dwg files values linkend to excel table.</title>
      <link>https://forums.autodesk.com/t5/net-forum/how-update-dwg-files-values-linkend-to-excel-table/m-p/9574609#M19640</link>
      <description>&lt;P&gt;While this thread is about DataLink, it seems to me that your issue has nothing to do with calling DataLinkManager.Update().&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Do you use plain AutoCAD, or AutoCAD vertical (Arch/MEP/Mech/Plant3D... especially the one used to create those drawings)? Version?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You may want to do some test to narrow the scope of possible reason(s).&lt;/P&gt;
&lt;P&gt;1. You can comment out db.DataLinkManager.Update() to confirm if the issue is related to DataLink updating.&lt;/P&gt;
&lt;P&gt;2. You can open multiple drawings in AutoCAD, and loop though the opened drawing to update DataLinks and save the change. Verify if the issue occurs or not.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 11 Jun 2020 15:27:00 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/how-update-dwg-files-values-linkend-to-excel-table/m-p/9574609#M19640</guid>
      <dc:creator>norman.yuan</dc:creator>
      <dc:date>2020-06-11T15:27:00Z</dc:date>
    </item>
    <item>
      <title>Re: how update dwg files values linkend to excel table.</title>
      <link>https://forums.autodesk.com/t5/net-forum/how-update-dwg-files-values-linkend-to-excel-table/m-p/9575748#M19641</link>
      <description>&lt;P&gt;Hi Norman thank for your comment.&lt;/P&gt;&lt;P&gt;The main wpf window has a progressbar, just indeterminate.&lt;/P&gt;&lt;P&gt;The visibility is visible before the UpadateProcess and then Hidden when the process is ended.&lt;/P&gt;&lt;P&gt;The process is in an await Task, this is the code:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="csharp"&gt;            MyUtilsCad myUcad = new MyUtilsCad();
            //some settings of my utility class
            myUcad.PathDwgFiles = Path.....;
            
            //progressbar pbProcess visibility and task run for 
            //updateExcellLinks
            pbProcess.Visibility = Visibility.Visible;
            await Task.Run(() =&amp;gt; myUcad.UpdateExcelLinks());
            pbProcess.Visibility = Visibility.Hidden;&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;today I will try to remove the task, I think this odd behaviour could be due to this.&lt;/P&gt;&lt;P&gt;If I solve, at least I will open a new 3d in order to understand how manage the tasks with autocad process.&lt;/P&gt;</description>
      <pubDate>Fri, 12 Jun 2020 05:30:15 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/how-update-dwg-files-values-linkend-to-excel-table/m-p/9575748#M19641</guid>
      <dc:creator>micle.space</dc:creator>
      <dc:date>2020-06-12T05:30:15Z</dc:date>
    </item>
    <item>
      <title>Re: how update dwg files values linkend to excel table.</title>
      <link>https://forums.autodesk.com/t5/net-forum/how-update-dwg-files-values-linkend-to-excel-table/m-p/9575923#M19642</link>
      <description>&lt;P&gt;yes, the problem is the thread.&lt;/P&gt;</description>
      <pubDate>Fri, 12 Jun 2020 08:04:12 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/how-update-dwg-files-values-linkend-to-excel-table/m-p/9575923#M19642</guid>
      <dc:creator>micle.space</dc:creator>
      <dc:date>2020-06-12T08:04:12Z</dc:date>
    </item>
  </channel>
</rss>

