<?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 Modifying the Document with a Transaction before the built-in Print command in Revit API Forum</title>
    <link>https://forums.autodesk.com/t5/revit-api-forum/modifying-the-document-with-a-transaction-before-the-built-in/m-p/8794887#M42285</link>
    <description>&lt;P&gt;I am working on an add-in that improves the default settings for the built-in print command, based on the active view - the filename, the paper size, etc.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Right now I have it working as I want it to, however, it is hooked up to the ViewActivated event. It parses the activated view's properties and creates a Transaction to modify the PrintSetting and call PrintSetup.Save to apply those changes. I would like to optimize this so that on ViewActivated, the information is only collected, and then applied and saved in a Transaction only just before the actual Print command is executed. The performance hit might be negligible (though I'd like to improve it as a matter of principle), but more annoyingly the Transactions create undoable history steps for every view change, which I would like to prevent.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Hooking my code up to BeforeExecuted for the built-in Print command fails with an error about document modification not being allowed, and I gather from online documentation that the BeforeExecuted Event is indeed read-only.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;So, the approaches I'm considering:&lt;/P&gt;
&lt;OL&gt;
&lt;LI&gt;Override the actual Executed event for the built-in Print command - I would only do this if I can somehow easly re-conjure up the regular Print command after doing my own business. Is there a way to do this? Reposting a Command from within the overwritten execution of itself seems like a bad idea.&lt;/LI&gt;
&lt;LI&gt;Is there a way to Commit a Transaction without an entry in the user transaction history so it doesn't fill up? Seems like really bad practice, but it would be a hacky way to improve the experience.&lt;/LI&gt;
&lt;LI&gt;Hooking up to something else? I looked into the UIControlledApplication.DialogBoxShowing Event, but it seems like the print options window isn't considered a Dialog Box in that sense. Any other ideas?&lt;/LI&gt;
&lt;/OL&gt;
&lt;P&gt;Thanks!&lt;/P&gt;</description>
    <pubDate>Thu, 16 May 2019 09:31:47 GMT</pubDate>
    <dc:creator>Anonymous</dc:creator>
    <dc:date>2019-05-16T09:31:47Z</dc:date>
    <item>
      <title>Modifying the Document with a Transaction before the built-in Print command</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/modifying-the-document-with-a-transaction-before-the-built-in/m-p/8794887#M42285</link>
      <description>&lt;P&gt;I am working on an add-in that improves the default settings for the built-in print command, based on the active view - the filename, the paper size, etc.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Right now I have it working as I want it to, however, it is hooked up to the ViewActivated event. It parses the activated view's properties and creates a Transaction to modify the PrintSetting and call PrintSetup.Save to apply those changes. I would like to optimize this so that on ViewActivated, the information is only collected, and then applied and saved in a Transaction only just before the actual Print command is executed. The performance hit might be negligible (though I'd like to improve it as a matter of principle), but more annoyingly the Transactions create undoable history steps for every view change, which I would like to prevent.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Hooking my code up to BeforeExecuted for the built-in Print command fails with an error about document modification not being allowed, and I gather from online documentation that the BeforeExecuted Event is indeed read-only.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;So, the approaches I'm considering:&lt;/P&gt;
&lt;OL&gt;
&lt;LI&gt;Override the actual Executed event for the built-in Print command - I would only do this if I can somehow easly re-conjure up the regular Print command after doing my own business. Is there a way to do this? Reposting a Command from within the overwritten execution of itself seems like a bad idea.&lt;/LI&gt;
&lt;LI&gt;Is there a way to Commit a Transaction without an entry in the user transaction history so it doesn't fill up? Seems like really bad practice, but it would be a hacky way to improve the experience.&lt;/LI&gt;
&lt;LI&gt;Hooking up to something else? I looked into the UIControlledApplication.DialogBoxShowing Event, but it seems like the print options window isn't considered a Dialog Box in that sense. Any other ideas?&lt;/LI&gt;
&lt;/OL&gt;
&lt;P&gt;Thanks!&lt;/P&gt;</description>
      <pubDate>Thu, 16 May 2019 09:31:47 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/modifying-the-document-with-a-transaction-before-the-built-in/m-p/8794887#M42285</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2019-05-16T09:31:47Z</dc:date>
    </item>
    <item>
      <title>Re: Modifying the Document with a Transaction before the built-in Print command</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/modifying-the-document-with-a-transaction-before-the-built-in/m-p/8795610#M42286</link>
      <description>&lt;P&gt;&lt;SPAN&gt;Dear Harri,&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Thank you for your interesting query.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;That sounds like a challenging task you have set yourself, and good progress you have made already.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Regarding your suggestion 1., you can indeed redefine the behaviour of a built-in command. However, I think that you then lose access to the original implementation, and only have access to your own overriding behaviour, cf. replacing built-in commands and obtaining their ids:&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;&lt;A href="https://thebuildingcoder.typepad.com/blog/2012/06/replacing-built-in-commands-and-their-ids.html" target="_blank"&gt;https://thebuildingcoder.typepad.com/blog/2012/06/replacing-built-in-commands-and-their-ids.html&lt;/A&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Ad 2. I am not aware of any way to Commit a Transaction without an entry in the user transaction history, except enclosing it in a transaction group. However, I see no way to include an existing built-in command (e.g., Print) with its own transaction handling inside a transaction group that you control.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Ad 3. You can of course use the Windows API to hook up with any dialogue you please and execute any code you please. I show how in my discussion on dismissing a dialogue using Windows API:&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;&lt;A href="http://thebuildingcoder.typepad.com/blog/2009/10/dismiss-dialogue-using-windows-api.html" target="_blank"&gt;http://thebuildingcoder.typepad.com/blog/2009/10/dismiss-dialogue-using-windows-api.html&lt;/A&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;However, I don't see how you would gain access to a valid Revit API context in that scenario.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;I hope this helps.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Best regards,&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Jeremy&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 16 May 2019 14:09:49 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/modifying-the-document-with-a-transaction-before-the-built-in/m-p/8795610#M42286</guid>
      <dc:creator>jeremytammik</dc:creator>
      <dc:date>2019-05-16T14:09:49Z</dc:date>
    </item>
  </channel>
</rss>

