<?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: catch events about saving a document. in .NET Forum</title>
    <link>https://forums.autodesk.com/t5/net-forum/catch-events-about-saving-a-document/m-p/11158551#M34943</link>
    <description>&lt;P&gt;yes, maybe it's not allowed to execute lengthy procedures inside an event, but AutoCAD is quite tolerant to multithreading and you may open a modeless form, or maybe you can run a custom command of your own through sending a string to the command window... both ways are non-blocking and the event handler will end smoothly...&lt;/P&gt;&lt;P&gt;There are quite a number of options indeed...&lt;/P&gt;</description>
    <pubDate>Tue, 10 May 2022 07:04:37 GMT</pubDate>
    <dc:creator>m.cicognani</dc:creator>
    <dc:date>2022-05-10T07:04:37Z</dc:date>
    <item>
      <title>catch events about saving a document.</title>
      <link>https://forums.autodesk.com/t5/net-forum/catch-events-about-saving-a-document/m-p/6507145#M34937</link>
      <description>&lt;P&gt;Hi.&lt;/P&gt;
&lt;P&gt;Is there any API event about "saving a document"? I refer about the 3 types: quick save, save and "save as".&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Maybe, I could catch them when if it is typed the command to save the document, but.. what I do with &lt;STRONG&gt;AUTO-SAVE&lt;/STRONG&gt;?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The issue in my app, is that my app throws messagebox when an object is modified and when the document is saved the object modified event is fired, so I get those messagebox every time that I save the drawing file.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks in advance.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 18 Aug 2016 03:27:17 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/catch-events-about-saving-a-document/m-p/6507145#M34937</guid>
      <dc:creator>joantopo</dc:creator>
      <dc:date>2016-08-18T03:27:17Z</dc:date>
    </item>
    <item>
      <title>Re: catch events about saving a document.</title>
      <link>https://forums.autodesk.com/t5/net-forum/catch-events-about-saving-a-document/m-p/6507188#M34938</link>
      <description>&lt;P&gt;OK, with this works.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;  doc.CommandWillStart += OnCommandWillStart;
            doc.CommandEnded += OnCommandEnded;
            doc.CommandCancelled += OnCommandEnded;
            doc.CommandFailed += OnCommandEnded;

  static void OnCommandWillStart(object sender, CommandEventArgs e)
        {
            string comando = e.GlobalCommandName.ToLower();

           if (comando.Contains("save"))
            {
                variables_globales.GuardadoDibujo = true;
            }
        }

       static void OnCommandEnded(object sender, CommandEventArgs e)
       {
           string comando = e.GlobalCommandName.ToLower();
           if (e.GlobalCommandName.Contains("save"))
           {
               variables_globales.GuardadoDibujo = false;
           }
       }&lt;/PRE&gt;
&lt;P&gt;I have a bool global var ( GuardadoDibujo) which is true or false (if the command is not a command related to Save operation), this way, I reject the ObjectModified event if this bool var is false.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;However, I have to add a Document closed event because if you press the button (YES) in the dialog box when you close a drawing file, any command about save is called.&lt;/P&gt;</description>
      <pubDate>Thu, 18 Aug 2016 04:20:53 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/catch-events-about-saving-a-document/m-p/6507188#M34938</guid>
      <dc:creator>joantopo</dc:creator>
      <dc:date>2016-08-18T04:20:53Z</dc:date>
    </item>
    <item>
      <title>Re: catch events about saving a document.</title>
      <link>https://forums.autodesk.com/t5/net-forum/catch-events-about-saving-a-document/m-p/6536838#M34939</link>
      <description>&lt;P&gt;You can also work exclusively with event handlers...&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;As a general guide, the scheme may be:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;When your application starts, you can attach an handler when documents are added to the DocumentManager (new or open) with&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;Application.DocumentManager.DocumentCreated += new DocumentCollectionEventHandler(DocumentManager_DocumentCreated);&lt;/PRE&gt;&lt;P&gt;Inside this handler, you can attach other specific document events handler, as for your needs, like:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;void DocumentManager_DocumentCreated(object sender, DocumentCollectionEventArgs e)
{
    if (e.Document != null)
    {
        e.Document.Database.BeginSave += new DatabaseIOEventHandler(Database_BeginSave);

        e.Document.Database.SaveComplete += new DatabaseIOEventHandler(Database_SaveComplete);

        e.Document.BeginDocumentClose += new DocumentBeginCloseEventHandler(doc_BeginDocumentClose);
     }
}&lt;/PRE&gt;&lt;P&gt;These events will be called for user commands, user interaction (closing application), system shutdown or auto-saving...&lt;/P&gt;&lt;P&gt;Inside these events you may check the application variable CMDNAMES to check if a user command has run and which, or you may check the filename if contains '.sv$', meaning it's an autosave...&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;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 01 Sep 2016 15:03:16 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/catch-events-about-saving-a-document/m-p/6536838#M34939</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2016-09-01T15:03:16Z</dc:date>
    </item>
    <item>
      <title>Re: catch events about saving a document.</title>
      <link>https://forums.autodesk.com/t5/net-forum/catch-events-about-saving-a-document/m-p/11158258#M34940</link>
      <description>&lt;P&gt;i'm trying to find out when the REFEDIT has finished (that is when the user edits the reference and then the changes are saved). the reason is we would like to pop up a message from our software to prompt the user to check in the file after the save.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;i've used the below snippet to catch the event&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;LI-CODE lang="general"&gt;reference.Database.SaveComplete += new AcDB.DatabaseIOEventHandler(Xref_SaveComplete);&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;but it takes a long time for my handler to get hit (the last time i tried it was 10 minutes after i clicked save changes). is there a quicker way i can get this information back?&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 10 May 2022 03:04:49 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/catch-events-about-saving-a-document/m-p/11158258#M34940</guid>
      <dc:creator>koan.stevenson</dc:creator>
      <dc:date>2022-05-10T03:04:49Z</dc:date>
    </item>
    <item>
      <title>Re: catch events about saving a document.</title>
      <link>https://forums.autodesk.com/t5/net-forum/catch-events-about-saving-a-document/m-p/11158422#M34941</link>
      <description>&lt;P&gt;10 minutes you say? maybe that's an autosave call...&lt;/P&gt;&lt;P&gt;I'd go for monitoring the CommandStart/CommandEnd event, and maybe check the external xref datetime to check if it's been actually saved...&lt;/P&gt;</description>
      <pubDate>Tue, 10 May 2022 05:18:52 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/catch-events-about-saving-a-document/m-p/11158422#M34941</guid>
      <dc:creator>m.cicognani</dc:creator>
      <dc:date>2022-05-10T05:18:52Z</dc:date>
    </item>
    <item>
      <title>Re: catch events about saving a document.</title>
      <link>https://forums.autodesk.com/t5/net-forum/catch-events-about-saving-a-document/m-p/11158507#M34942</link>
      <description>&lt;P&gt;thanks for the quick reply. it sounds like a good way to try it, i'll put your suggestions in our ticket. i think we're going to shelve this one anyway. the guidelines say not to attempt 'interactive functions within an event handler' so we'll try to stick to stuff we have better control over for now.&lt;/P&gt;</description>
      <pubDate>Tue, 10 May 2022 06:36:59 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/catch-events-about-saving-a-document/m-p/11158507#M34942</guid>
      <dc:creator>koan.stevenson</dc:creator>
      <dc:date>2022-05-10T06:36:59Z</dc:date>
    </item>
    <item>
      <title>Re: catch events about saving a document.</title>
      <link>https://forums.autodesk.com/t5/net-forum/catch-events-about-saving-a-document/m-p/11158551#M34943</link>
      <description>&lt;P&gt;yes, maybe it's not allowed to execute lengthy procedures inside an event, but AutoCAD is quite tolerant to multithreading and you may open a modeless form, or maybe you can run a custom command of your own through sending a string to the command window... both ways are non-blocking and the event handler will end smoothly...&lt;/P&gt;&lt;P&gt;There are quite a number of options indeed...&lt;/P&gt;</description>
      <pubDate>Tue, 10 May 2022 07:04:37 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/catch-events-about-saving-a-document/m-p/11158551#M34943</guid>
      <dc:creator>m.cicognani</dc:creator>
      <dc:date>2022-05-10T07:04:37Z</dc:date>
    </item>
    <item>
      <title>Re: catch events about saving a document.</title>
      <link>https://forums.autodesk.com/t5/net-forum/catch-events-about-saving-a-document/m-p/11158557#M34944</link>
      <description>&lt;P&gt;good to know!&lt;/P&gt;</description>
      <pubDate>Tue, 10 May 2022 07:07:02 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/catch-events-about-saving-a-document/m-p/11158557#M34944</guid>
      <dc:creator>koan.stevenson</dc:creator>
      <dc:date>2022-05-10T07:07:02Z</dc:date>
    </item>
  </channel>
</rss>

