Definition Observer
-
Hello,
I'm trying to use definition observers in a script instead of multiple entities observers because they seem to be a little more stable. There are a number of quirky things about it, but one that I haven't been able to work around is as follows:
When I add a component instance to the model, the onComponentInstanceAdded method fires. However, if I delete the component instance and then undo, onComponentInstance added does NOT fire. I need to be notified both of new instances and of instances that are back from the dead.
Any ideas?
Thanks a bunch,
Karen
-
Use a combination of definitions observer and definition observer.
Add a definition observers to each of the definitions.
When a definition is added/deleted to/from definitions you know.
You now know that definition - add an observer to that too.
When any definition has instances added/removed you know as its observer tells you... -
...
except that onInstanceRemoved doesn't fire
and onInstanceAdded doesn't fire for a delete-undo event... I think I'm going back to entities observers... seems more stable in SU8
-
Yea - definition observer has been troublesome all along: http://www.thomthom.net/software/sketchup/observers/#DefinitionObserver
-
Crib from my '#HolePunchTool.rb'...
That uses definition and definitions [and several other] observers, and a global [$] array of things that is adjusted as we go...
It seems to work OK for me, to keep track of Hole-Punching Instances etc and control copying, etc...
Have a look - the observers code is near the end of the script...
You might be able to adjust its ideas to your needs...
-
Thanks TIG.
TT - I revisited your observers chart page after posting the initial message. Definitely very helpful. Thanks for maintaining it.
--
Karen
Hello! It looks like you're interested in this conversation, but you don't have an account yet.
Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.
With your input, this post could be even better π
Register LoginAdvertisement