Observers WhishList
-
Dan: Thank you for your detailed explanation. Early on when I first looked at Ruby scripting, I knew nothing about Ruby and I still know very little. Many of the examples I used were from donated scripts, from which I borrowed and referenced code to develop my own self taught scripts, there were no module examples to speak or copy from. Its easy to see why not more people get engaged with Ruby.
To a novice trying to make sense of the current SU Ruby API descriptions and examples, is like shining a light on a subject without a battery in the flashlight. -
@tomot said:
Many of the examples I used were from donated scripts, from which I borrowed and referenced code to develop my own self taught scripts, there were no module examples to speak or copy from.
See this thread at GoogleGroups, begining with post 4, in which Harald asks the question "... so, are all my .rb scripts really just one huge script?"
He was having trouble with the Ruby environment getting corrupted with classes, objects, methods and so forth.. that he didn't want loaded.
Read my detailed responces, which explain how things get loaded (both in Sketchup Ruby, and Ruby in general,) and an example of file spanning. -
Unfortunately, the Google examples does not encapsulate their code. But you'll find most plugins here at SCF are. Usually it's the older ones that doesn't.
The norm is encapsulate the script in a module which is prefixed with your initials - that goes a long way to prevent namespace collisions. I use TT_, Jim use JF_, Chris use Clf_, etc. -
@tomot said:
To a novice trying to make sense of the current SU Ruby API descriptions and examples, is like shining a light on a subject without a battery in the flashlight.
Yea - - that description sounds just about right.
-
+1 for EntityObserver currently it's pretty much unusable as it crashes SU when it intercepts anything and tries to perform more than a single printout to the console.
-
I definitely add my vote for an onBeforeSave for the Model Observer. Right now, I am doing some stuff and then re-saving...
A few things I came across:
-
re-saving triggers the onSave method in your application, and in any other plugins that have a Model Observer. This can lead to an annoying infinite loop. I fixed this problem by requiring that the times between saves be greater than a certain set time.
-
Once you re-save your model, the model observer immediately calls the onSave method. This means that any code below Sketchup.active_model.save "my model.skp" will not be executed until after the onSave is called and executed again... so any infinite loop prevention should be above the save command.
--
Karen -
-
When hiding a layer that contains selected entities, these entities get un-selected. This seems not to trigger
onSelectionBulkChange
(or evenonSelectionCleared
). -
The
SelectionObserver
still seems to be the most problematic of all the observers.
http://www.thomthom.net/software/sketchup/observers/#note_SelectionObserver -
Hi, ViewObserver works on mac?
-
@havanasud said:
Hi, ViewObserver works on mac?
Hi
Are you experiencing any problems or unforeseen behavior?
I've not heard of any issues. Think I've used it a couple of times and so far not received any reports of issues.
http://www.thomthom.net/software/sketchup/observers/#ViewObserver (Note - not everything here is tested. So if you find an issue, please let me know so I can update the chart.)
-
onCopyElement
an observer that would detect when something is being copied
i have not find anything doing that among the existing obsersers
-
Would that be at the event of copying? Or when pasting?
Can you describe the scenario you'd use it in? -
@thomthom said:
Would that be at the event of copying? Or when pasting?
Can you describe the scenario you'd use it in?when copying
i am trying to find a way to control the difusion of dynamic components
if such an observer would be available, it would be easy to prevent unauthorized copies
selection observer can be used, but it is less direct, and probably less efficient than an observer on copying
more dynamic components would be created if there was a way to crypt them, just as ruby plugins
Advertisement