<?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: Database.SaveComplete event is not fired in Civil3D 2014 and 2015 in .NET Forum</title>
    <link>https://forums.autodesk.com/t5/net-forum/database-savecomplete-event-is-not-fired-in-civil3d-2014-and/m-p/5166129#M43210</link>
    <description>I'm not sure you can add the SaveComplete handler inside the OnBeginSave event... isn't too close a call?&lt;BR /&gt;I cannot debug your code, but I can say you what I normally do and works well:&lt;BR /&gt;- in the plugin init I attach an event handler to the Application.DocumentManager.DocumentCreated event;&lt;BR /&gt;- in the DocumentCreated handler I add alla the handler needed, in my case both BeginSave and SaveComplete&lt;BR /&gt;&lt;BR /&gt;Only drawback, the plugin may start after the first document load, so you also need to cycle through the DocumentManager and attach the handlers to the already loaded documents.&lt;BR /&gt;I assure you this works.</description>
    <pubDate>Tue, 22 Jul 2014 08:34:48 GMT</pubDate>
    <dc:creator>Anonymous</dc:creator>
    <dc:date>2014-07-22T08:34:48Z</dc:date>
    <item>
      <title>Database.SaveComplete event is not fired in Civil3D 2014 and 2015</title>
      <link>https://forums.autodesk.com/t5/net-forum/database-savecomplete-event-is-not-fired-in-civil3d-2014-and/m-p/5164807#M43207</link>
      <description>&lt;P&gt;In my code as shown below I try to cath the SaveComplete event:&lt;/P&gt;&lt;PRE&gt;       public void Request()
        {
            try
            {
                Database db = HostApplicationServices.WorkingDatabase;
                Document current_doc = Application.DocumentManager.GetDocument(db);
                current_doc.Database.BeginSave += OnBeginSave;
                current_doc.Database.SaveAs(drawing_path, DwgVersion.Current);
            }
            catch (System.Exception)
            {
            }
        }

        void OnSaveComplete(object sender, DatabaseIOEventArgs e)
        {
            try
            {
                Database db = sender as Database;
                if (db != null)
                {
                    db.SaveComplete -= OnSaveComplete;
                }
            }
            catch (System.Exception)
            {
            }
        }

        void OnBeginSave(object sender, DatabaseIOEventArgs e)
        {
            try
            {
                Database db = sender as Database;
                if (db != null)
                {
                    db.BeginSave -= OnBeginSave;
                    db.SaveComplete += OnSaveComplete;
                }
            }
            catch (System.Exception)
            {
            }
        }&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;But it looks as it works fine in Civil3D up to version 2013. In later versions the SaveComplete event is not fired or something. Any suggestions?&lt;/P&gt;</description>
      <pubDate>Mon, 21 Jul 2014 16:59:30 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/database-savecomplete-event-is-not-fired-in-civil3d-2014-and/m-p/5164807#M43207</guid>
      <dc:creator>aknigin</dc:creator>
      <dc:date>2014-07-21T16:59:30Z</dc:date>
    </item>
    <item>
      <title>Re: Database.SaveComplete event is not fired in Civil3D 2014 and 2015</title>
      <link>https://forums.autodesk.com/t5/net-forum/database-savecomplete-event-is-not-fired-in-civil3d-2014-and/m-p/5164967#M43208</link>
      <description>&lt;P&gt;If the code you showed here is the same in your project for Acad (or Civil3d, not different here) 2014/15, and 2013, the code in the OnSaveComplete() would never run, regardless AutoCAD's version: you did not hook the event handler (OnSaveComplete()) to any event that might be fired by Document/Database. That is, whatever event AutoCAD exposed ALWAYS fires, your code only responds to a event when your code hooks an event handler to the event. Just as you did with Database.BeginSave event. You need to add&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;current_Doc.Database.SaveComplete+=OnSaveComplete;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Isn't it quite obvious?&lt;/P&gt;</description>
      <pubDate>Mon, 21 Jul 2014 17:56:41 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/database-savecomplete-event-is-not-fired-in-civil3d-2014-and/m-p/5164967#M43208</guid>
      <dc:creator>norman.yuan</dc:creator>
      <dc:date>2014-07-21T17:56:41Z</dc:date>
    </item>
    <item>
      <title>Re: Database.SaveComplete event is not fired in Civil3D 2014 and 2015</title>
      <link>https://forums.autodesk.com/t5/net-forum/database-savecomplete-event-is-not-fired-in-civil3d-2014-and/m-p/5166007#M43209</link>
      <description>&lt;P&gt;Norman,&lt;/P&gt;&lt;P&gt;I do subscribe to the SaveComplete event - in OnBeginSave handler, which you can see in the code snippet. But whatever - I tried to subscribe to both events in the Request() method and got the same results, of course: it does work in Civil3D up to version 2013, and in the versions 2014 and 2015 only BeginSave event is fired.&lt;/P&gt;</description>
      <pubDate>Tue, 22 Jul 2014 07:27:51 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/database-savecomplete-event-is-not-fired-in-civil3d-2014-and/m-p/5166007#M43209</guid>
      <dc:creator>aknigin</dc:creator>
      <dc:date>2014-07-22T07:27:51Z</dc:date>
    </item>
    <item>
      <title>Re: Database.SaveComplete event is not fired in Civil3D 2014 and 2015</title>
      <link>https://forums.autodesk.com/t5/net-forum/database-savecomplete-event-is-not-fired-in-civil3d-2014-and/m-p/5166129#M43210</link>
      <description>I'm not sure you can add the SaveComplete handler inside the OnBeginSave event... isn't too close a call?&lt;BR /&gt;I cannot debug your code, but I can say you what I normally do and works well:&lt;BR /&gt;- in the plugin init I attach an event handler to the Application.DocumentManager.DocumentCreated event;&lt;BR /&gt;- in the DocumentCreated handler I add alla the handler needed, in my case both BeginSave and SaveComplete&lt;BR /&gt;&lt;BR /&gt;Only drawback, the plugin may start after the first document load, so you also need to cycle through the DocumentManager and attach the handlers to the already loaded documents.&lt;BR /&gt;I assure you this works.</description>
      <pubDate>Tue, 22 Jul 2014 08:34:48 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/database-savecomplete-event-is-not-fired-in-civil3d-2014-and/m-p/5166129#M43210</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2014-07-22T08:34:48Z</dc:date>
    </item>
    <item>
      <title>Re: Database.SaveComplete event is not fired in Civil3D 2014 and 2015</title>
      <link>https://forums.autodesk.com/t5/net-forum/database-savecomplete-event-is-not-fired-in-civil3d-2014-and/m-p/5166383#M43211</link>
      <description>&lt;P&gt;&lt;SPAN class="UserName lia-user-name"&gt;&lt;SPAN&gt;Your post gave me some idea, I made investigations and it seems that the Database.SaveAs method should be called from the main thread to the events work properly.&lt;BR /&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 22 Jul 2014 11:16:44 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/database-savecomplete-event-is-not-fired-in-civil3d-2014-and/m-p/5166383#M43211</guid>
      <dc:creator>aknigin</dc:creator>
      <dc:date>2014-07-22T11:16:44Z</dc:date>
    </item>
  </channel>
</rss>

