<?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 to update Database when user copy Revit element? in Revit API Forum</title>
    <link>https://forums.autodesk.com/t5/revit-api-forum/how-to-update-database-when-user-copy-revit-element/m-p/8668438#M43668</link>
    <description>&lt;P&gt;You might be able to snoop the journal file to determine whether a copy operation has been performed.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Tue, 19 Mar 2019 12:37:58 GMT</pubDate>
    <dc:creator>jeremytammik</dc:creator>
    <dc:date>2019-03-19T12:37:58Z</dc:date>
    <item>
      <title>How to update Database when user copy Revit element?</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/how-to-update-database-when-user-copy-revit-element/m-p/8660559#M43665</link>
      <description>&lt;P&gt;Here is my situation:&amp;nbsp;&lt;BR /&gt;I using Extensible storage to add data to some element in a Revit document. However, when user copy the element and place it some where else (in the same Revit document, of course), the data needs to be updated (new Id, new location etc...). I have been scratching my head with this problem, and the closest things I have come across are:&lt;BR /&gt;1. Document Changed event:&lt;BR /&gt;&amp;nbsp; &amp;nbsp; With this event, I can detect when user performs a copy operation through transaction name and get all the elements I want, but I can not modify them because this is an read only event =&amp;gt; no transaction allowed.&lt;/P&gt;
&lt;P&gt;2. IUpdater implementation&lt;BR /&gt;&amp;nbsp;&amp;nbsp; With this interface, I can modify a certain type of elements, but I can not tell if the added elements are from an user copy operation. Therefore, my updater might update all the new element with new data that was created by my external command, which is not what I want.&lt;BR /&gt;How can I modify only the targeted elements from user copy operation? Is there any way that combine these 2 solutions to solve my problem (something like an updater delegate that provide the context for modification and can be call from/ right after the documents changed event)?.&lt;BR /&gt;Thank you very much. Any suggestion is much appreciated.&lt;/P&gt;</description>
      <pubDate>Fri, 15 Mar 2019 03:50:12 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/how-to-update-database-when-user-copy-revit-element/m-p/8660559#M43665</guid>
      <dc:creator>longt61</dc:creator>
      <dc:date>2019-03-15T03:50:12Z</dc:date>
    </item>
    <item>
      <title>Re: How to update Database when user copy Revit element?</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/how-to-update-database-when-user-copy-revit-element/m-p/8661116#M43666</link>
      <description>&lt;P&gt;Thank you for this very relevant and interesting question.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You are correct in your analysis.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I think the best solution is probably to implement the updater and define very strict conditions so that it is only triggered when really needed. For instance, the trigger might include a check that ensures that your extensible storage is indeed present on the source element.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I may be wrong, however.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you wish to implement the DocumentChanged event handler instead, you can do so as follows: in the document changed event, check whether you really need to react to the changes. That can be done in a read-only operation. If you do, subscribe to the Idling event. In the Idling event handler, unsubscribe from the event, open a transaction, and make the required modifications.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The disadvantage of DocumentChanged is that it is called on every document modification.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Another disadvantage is that you have the copy operation and the extensible storage update in two separate transactions, so some confusion might be possible if you start undoing and redoing and larking around like that.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I hope this helps.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Cheers,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Jeremy&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 15 Mar 2019 11:40:42 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/how-to-update-database-when-user-copy-revit-element/m-p/8661116#M43666</guid>
      <dc:creator>jeremytammik</dc:creator>
      <dc:date>2019-03-15T11:40:42Z</dc:date>
    </item>
    <item>
      <title>Re: How to update Database when user copy Revit element?</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/how-to-update-database-when-user-copy-revit-element/m-p/8668236#M43667</link>
      <description>&lt;P&gt;Thank you for your suggestion. I just thought about the Idling event, yet it share the same problem with the IUpdater interface:&lt;BR /&gt;1. don't know if user just perform a copy operation&amp;nbsp;&lt;/P&gt;
&lt;P&gt;2. can not determine the elements I want because the user could create new/ add extensible storage to new elements or copy existing ones. Beside, I currently depend on the copy operation to detect the extensible storage that needed update, since all other elements still have the entity with the same schema (even same entity if user copy them).&lt;/P&gt;
&lt;P&gt;My time for the project is running short, but I guess I have to tackle with this problem for quite a while.&lt;/P&gt;
&lt;P&gt;Thanks again for always there to help.&lt;/P&gt;</description>
      <pubDate>Tue, 19 Mar 2019 11:38:17 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/how-to-update-database-when-user-copy-revit-element/m-p/8668236#M43667</guid>
      <dc:creator>longt61</dc:creator>
      <dc:date>2019-03-19T11:38:17Z</dc:date>
    </item>
    <item>
      <title>Re: How to update Database when user copy Revit element?</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/how-to-update-database-when-user-copy-revit-element/m-p/8668438#M43668</link>
      <description>&lt;P&gt;You might be able to snoop the journal file to determine whether a copy operation has been performed.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 19 Mar 2019 12:37:58 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/how-to-update-database-when-user-copy-revit-element/m-p/8668438#M43668</guid>
      <dc:creator>jeremytammik</dc:creator>
      <dc:date>2019-03-19T12:37:58Z</dc:date>
    </item>
    <item>
      <title>Re: How to update Database when user copy Revit element?</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/how-to-update-database-when-user-copy-revit-element/m-p/8670330#M43669</link>
      <description>&lt;P&gt;It seems to me, you have to use an Updater.&lt;/P&gt;
&lt;P&gt;For every added element in the Updater.Execute method, check if the element has your&amp;nbsp;&lt;SPAN&gt;Extensible storage&amp;nbsp;scheme applied.&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;
&lt;PRE&gt;if&amp;nbsp; (&amp;nbsp; &amp;nbsp; elem.GetEntitySchemaGuids().Contains(YourScheme_GUID))
{
//   elem is copy of an element with your Extensible Storage scheme )
}
else
{
// elem is newly placed in the model,
// OR elem is copy of an element without your Extensible Storage Scheme )
}&lt;/PRE&gt;</description>
      <pubDate>Wed, 20 Mar 2019 00:20:24 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/how-to-update-database-when-user-copy-revit-element/m-p/8670330#M43669</guid>
      <dc:creator>FAIR59</dc:creator>
      <dc:date>2019-03-20T00:20:24Z</dc:date>
    </item>
  </channel>
</rss>

