Unfortunately, there is no general panacea of all the events you are looking for.
BeforeDataProcessing/AfterDataProcessing event handlers are heavily used by TBC commands for handling the cases you are describing. These get fired before/after the processing is complete. See if this leads you anywhere.
Original Message:
Sent: 06-20-2024 02:07
From: Ronny Schneider
Subject: how to catch a general Undo/Redo/delete event?
Thanks Bryce.
I had seen that UndoWatcher, but didn't really look into it since it's only sending some strings and I'd have to monitor their change "manually".
It also doesn't cover if the user deleted/added entities with another function/macro, which would require my macro to reload some data.
I'm really surprised that the project doesn't fire those events automatically.
Not super critical right now. If I have more time I'll have another look.
------------------------------
Ronny Schneider
Original Message:
Sent: 06-19-2024 11:36
From: Bryce Haire
Subject: how to catch a general Undo/Redo/delete event?
Hi Ronny,
I would suggest looking at the IUndoWatcher service.
It should be (currently) located in Trimble.Sdk.UI namespace.
My gut tells me this is one of the types that moves around a lot (like InputMethod, MousePosition, UIEventArgs) between versions of TBC.
This has methods of OnUndo, OnRedo that fire when the buttons are clicked.
I believe you need to setup an observer (Reactive/Rx) on it, which you can do via the Subscribe method. It will have 2 args on the callback, 1 for type (Undo/Redo) and string (description from undo action).
If you setup an observer, it should allow you in the callback to monitor what happened.
Just a note on ITransactionTokenCommand, I do not think this is an interface provided from the TBC team.
It is definitely not in v2024.00 and I looked in v5.90 and couldn't find it. It may be something ANZ is doing themselves.
¯\_(ツ)_/¯
------------------------------
Bryce Haire
Original Message:
Sent: 06-17-2024 17:57
From: Ronny Schneider
Subject: how to catch a general Undo/Redo/delete event?
Would be interested in that topic as well. Especially for multithreading, since IronPython doesn't properly support it (it's slower than single threading).
Maybe Morteza can share a basic example?
------------------------------
Ronny Schneider
Original Message:
Sent: 06-17-2024 03:01
From: Fernando Calvo
Subject: how to catch a general Undo/Redo/delete event?
Hi,
is there any info in the community how to create macros with c# instead of IronPython? I would like to try that way too instead of all as until now via Python / IronPython.
Thanks.
Regards,
Fernando
------------------------------
Fernando Calvo
calvo@calvo-geospatial.com
Original Message:
Sent: 06-17-2024 02:36
From: ANZ Toolbox
Subject: how to catch a general Undo/Redo/delete event?
Hey Ronny, in C# we can implement the ITransactionTokenCommand interface. I am unsure how to do this using python macros. Hopefully you can figure it out or one of the Trimble guys can help you out!
------------------------------
https://tbcanz.com/anz-toolbox/
Original Message:
Sent: 06-17-2024 00:38
From: Ronny Schneider
Subject: how to catch a general Undo/Redo/delete event?
In some of the sample macros is shown how to catch the events for a single entity change. They use "Trimble.Vce.Core.ModelEvents".
ModelEvents.EntityAdded += self.test
But I don't want to use that, since that subroutine would be called potentially millions of times during a big Undo/Redo.
I just want the subroutine to run one time upon an Undo/Redo button click, or Ctrl+z or general delete (i.e. a file in the project explorer).
I couldn't find anything like "ProjectEvents".
Is "CalculateProject" always triggered in those cases and therefore
from Trimble.Vce.Core import CalculateProjectEventsCalculateProjectEvents.CalculateProjectEvent += self......
the proper way to go?
I'd prefer to distinguish between the different events though.
------------------------------
Ronny Schneider
------------------------------