DefinitionObserver doesn't trigger
-
I made an
DefinitionObserver
where I added some puts statement for theonComponentInstanceAdded
andonComponentInstanceRemoved
events.
I then attach it to the definition I want to observe. But they never trigger. Is it that the event name is different from what the manual claims? Or must there be something else I've done wrong? -
I dont think so...
p.s. its 'lose' not 'loose'
-
I think we did. I bumped this thread earlier. And I posted a post in this thread right after Scott's post: http://www.sketchucation.com/forums/scf/viewtopic.php?f=180&t=17047&st=0&sk=t&sd=a&start=30#p141244
which also is gone. -
I'll investigate
-
Hm. I don't know about anything. I'll also see...
(Thanks Remus for warning )
Edit: well, I had a look at both the moderator log and the admin log and there are no traces of posts having been deleted from here or a system backup (which would also explain it although I should definitely know about that).
I don't know, Thom.
And yes, it's "lose" (as a verb). "Loose" would be an adjective meaning something is not tight.
-
There was a time at around 16:00 GMT+1 that the forum returned PHP errors on and off for about half an hour.
-
Did we lose some posts?
[Edit: Spelling correction. ]
-
Did you post what's lost then? Or4 do you suspect then something happened that "deleted" the posts?
Actually I was online at around then (maybe doing something else that checking the forums)
-
Could be. I've had SCU on my second monitor all day. it might in fact be anywhere between 15:00-17:00 GMT. I'm not 100% about the time. but it was a 30 min gap when SCF would return errors. The missing posts might have been done at that time, but I'm not sure here either. It's quite plausible. There was no error when I posted, when the forum redirected back to my post I could see it. So the errors I saw might have been SCF resetting or something...
Oh well. Nothing major was lost anyway. -
I left my browser on SCF for a while and it had an error when i came back, so im guessing it was the same thing you saw thomthom.
If i remember correctly it was a mysql error of some description.
-
@remus said:
If i remember correctly it was a mysql error of some description.
Yes. I didn't pay too much attention to what it specifically said.
When I followed a link to the Tutorial pages I was faced with a messages saying SCF was down for half and hour due to scheduled maintenance. -
But... has anyone any answers to my original question...?
-
No good answer. I was able to get
onComponentInstanceRemoved
to fire when I removed all instances from the model, then selected Purge from the Component Browser.Couldn't get
onComponentInstanceAdded
to fire. -
hmm... sounds like it reacted to the definition being removed instead of the instance... wonder if this observers is buggered...
Work around is to use ModelObserver to detect when instances are placed. Though with the overhead of observing all components... And there's no alternative to when a instance is removed other than the Entity observer. But the entity returned for the erase even returns an instance with
.definition
returningnil
and all attribute dictionaries are gone... -
I really need to make this observer work now. the model.onPlaceComponent only triggers when you take a component from the component browser and place it in the model. But it doesn't trigger when you do a move+copy of an existing component.
Anyone?
-
I looks like it's some wires crossed in the backend. I made a typo when I wanted a
DefinitionsObserver
, where I instead wroteDefinitionObserver
. But the code still worked.So while the
DefinitionObserver
doesn't trigger the events it's supposed to, it triggers all ofDefinitionsObserver
's events.Example code:
class TestDefinitionsObserver < Sketchup;;DefinitionsObserver def onComponentPropertiesChanged(definitions, definition) puts 'DefinitionsObserver - onComponentPropertiesChanged' end def onComponentRemoved(definitions, definition) puts 'DefinitionsObserver - onComponentRemoved' end def onComponentAdded(definitions, definition) puts 'DefinitionsObserver - onComponentAdded' end end class TestDefinitionObserver < Sketchup;;DefinitionObserver def onComponentPropertiesChanged(definitions, definition) puts 'DefinitionObserver - onComponentPropertiesChanged' end def onComponentRemoved(definitions, definition) puts 'DefinitionObserver - onComponentRemoved' end def onComponentAdded(definitions, definition) puts 'DefinitionObserver - onComponentAdded' end end module TestDefOb def self.test r = Sketchup.active_model.definitions.add_observer(TestDefinitionObserver.new) puts 'Sketchup;;DefinitionObserver - ' + r.to_s r = Sketchup.active_model.definitions.add_observer(TestDefinitionsObserver.new) puts 'Sketchup;;DefinitionsObserver - ' + r.to_s end end
Type
TestDefOb.test
in the console and add/remove some component definitions. Notice how both observers trigger.
Advertisement