Catch when Paste In Place is performed
-
I need to catch this command when it occurs so I can detect if an instance of a specific definition is added. With normal paste the PasteTool is triggered. But it doesn't when Paste In Place is invoked.
-
Any reason you don't just look for all instances being added and do something its "your" definition?
-
Don't see any event Observer that tells me when new instances are added globally. However, the DefinitionObserver would have been ideal for my use and I'm only interested in certain definition instances. But since it's borked I have to find other ways to find out when that happens.
By using the ToolObserver I can detect when a regular Paste is done and when a Move+Copy and RotateCopy is performed. But I find nothing to catch the Paste in Place. -
EntitiesObserver
onElementAdded
?
-
@tig said:
EntitiesObserver
onElementAdded
?
Then I'd have to monitor every group and component definition and the model object. I'm not that familiar with the overhead of Observers. But this sounds like it'd be quite a lot of observers running...
Anyone knows what the performance impact of doing this would be? -
Or you could monitor just the object being edited driven off onOpen, onClose ie dynamically add an observer then remove it on close.
Adam
But fundamentally, the semantics of some of the observer patterns is a bit pants. But the Boulder guys are well aware of this and I'm sure they'll get around to freshening it up.
-
@adamb said:
Or you could monitor just the object being edited driven off onOpen, onClose ie dynamically add an observer then remove it on close.
Adam
Well,.. in my experience,
onClose
doesn't trigger. OnlyonOpen
... Which is another thing I work around. Though, I'm currently usingModel.onActivePathChanged
for that.This might be something. With that, I might not need that many observers of various kinds. If I monitor the active entities for changes I might be able to simplify my script. Will give it a whack.
-
Or why not make it very simple and have a thread that wakes every few seconds to check whether XXX.instances.count has changed.
Probably computationally cheaper than having N instances of Observer.
Adam
-
I have been thinking of timers. But I like the idea of them less than observers.
Will have to see what I end up with. -
@thomthom said:
@tig said:
EntitiesObserver
onElementAdded
?
Then I'd have to monitor every group and component definition and the model object. I'm not that familiar with the overhead of Observers. But this sounds like it'd be quite a lot of observers running...
Anyone knows what the performance impact of doing this would be?I think it's a worthwhile experiment to create a meta-observer (built on the existing observers) that watches a "class" of entities - such as a GroupsObserver, or something like that.
Advertisement