0

I am working on a project that rebars to host elements in Revit 2018 and Revit 2019. After my code regenerates the rebar reinforcement for the host element, I can not know if the user has manually edited my host or my rebars (generated by my code, of course). I just come up with these 2 ideas:

  1. Store all rebar and host info into the host 's extensible storage (literally every property, ids, ….) at the time the rebars are generated by my code. When I call my code to work on the host again, I am going to compare all the current info with the saved info in the host 's entity to find out what has been changed. Clearly, this approach is going to cost me a lot and has a huge penalty on performance.

  2. Catch all the change the user might do to my rebars and hosts through an "Element - edited - event". However, I can't seem to find the right event that suits my need. I 've tried Element and Document events and ITransactionFinalizer class without results.

Where can I find the event I want or how to achieve what I wanted? Another and better approach is much welcome. Thank you all in advance.

DasSoftware
  • 964
  • 10
  • 19
Thế Long
  • 516
  • 7
  • 19
  • 1
    I just found a very interesting way that may get me what I wanted. I will make it an official solution after I have tested it. Here is the link for someone encounter the same problem: [link](https://thebuildingcoder.typepad.com/blog/2016/01/tracking-element-modification.html) – Thế Long Nov 05 '18 at 04:23

2 Answers2

1

Congratulations on spotting the link to Tracking Element Modification yourself. I would have pointed to that too. You might also want to check out the GitHub repository for that project, plus a follow-up project idea:

Looking forward to hearing about your final solution. If it is generic enough to be of interest to others as well, I would love to share it on the blog for you. Thank you!

Jeremy Tammik
  • 7,333
  • 2
  • 12
  • 17
  • Thank you for you reply. Your mentioned solution did solve my problem, but something cross my mind though: Let just say that I want to take a snapshot then update the current state to my database, does this approach take much time incase the project contains many models? It may make a good solution to "appears bad" to end user. – Thế Long Nov 07 '18 at 03:57
  • Do you think that the little over head to update database when subscribe to "Document changed" event for every little change end user make to document can make up to this? I really appreciate your thought on the matter of this scale. – Thế Long Nov 07 '18 at 04:03
  • 1
    you can try using the `DocumentChanged` event to be notified on every modification. How much time that will cost will depend on your exact implementation. I think it can be made very fast and unobtrusive. However, do you really need notification on eveery single modification? How about just implementing a Windows timer event that triggers a Revit API external event every 15 minutes or so? Or any other time interval you prefer? That will have almost zero performance impact. – Jeremy Tammik Nov 08 '18 at 13:37
0

The solution I (as well as Mr. Jeremy Tammik) have mentioned Tracking Element Modification

is what I need, but it is a little too generic though.

For a more detailed solution to this specific problem, I filtered for my rebar host (beam, column, wall …) , get all the hosted rebars then take a snapshot of their parameters.

Some small notes for newbies like me though:

  1. Some of the parameters will change depends on other ones. If user modification is what you are after, filter out the ReadOnly parameter that has been changed will narrow the list down quite a bit.

  2. If you delete all rebar from host, or add rebar to an empty host, some parameters will be removed or added accordingly.

Thế Long
  • 516
  • 7
  • 19