sketchucation logo sketchucation
    • Login
    ℹ️ Licensed Extensions | FredoBatch, ElevationProfile, FredoSketch, LayOps, MatSim and Pic2Shape will require license from Sept 1st More Info

    DefinitionObserver doesn't trigger

    Scheduled Pinned Locked Moved Developers' Forum
    16 Posts 4 Posters 1.5k Views 4 Watching
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • GaieusG Offline
      Gaieus
      last edited by

      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.

      Gai...

      1 Reply Last reply Reply Quote 0
      • thomthomT Offline
        thomthom
        last edited by

        There was a time at around 16:00 GMT+1 that the forum returned PHP errors on and off for about half an hour.

        Thomas Thomassen β€” SketchUp Monkey & Coding addict
        List of my plugins and link to the CookieWare fund

        1 Reply Last reply Reply Quote 0
        • thomthomT Offline
          thomthom
          last edited by

          Did we lose some posts?

          [Edit: Spelling correction. πŸ˜‰ ]

          Thomas Thomassen β€” SketchUp Monkey & Coding addict
          List of my plugins and link to the CookieWare fund

          1 Reply Last reply Reply Quote 0
          • GaieusG Offline
            Gaieus
            last edited by

            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)

            Gai...

            1 Reply Last reply Reply Quote 0
            • thomthomT Offline
              thomthom
              last edited by

              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.

              Thomas Thomassen β€” SketchUp Monkey & Coding addict
              List of my plugins and link to the CookieWare fund

              1 Reply Last reply Reply Quote 0
              • R Offline
                remus
                last edited by

                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.

                http://remusrendering.wordpress.com/

                1 Reply Last reply Reply Quote 0
                • thomthomT Offline
                  thomthom
                  last edited by

                  @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.

                  Thomas Thomassen β€” SketchUp Monkey & Coding addict
                  List of my plugins and link to the CookieWare fund

                  1 Reply Last reply Reply Quote 0
                  • thomthomT Offline
                    thomthom
                    last edited by

                    But... has anyone any answers to my original question...?

                    Thomas Thomassen β€” SketchUp Monkey & Coding addict
                    List of my plugins and link to the CookieWare fund

                    1 Reply Last reply Reply Quote 0
                    • J Offline
                      Jim
                      last edited by

                      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.

                      Hi

                      1 Reply Last reply Reply Quote 0
                      • thomthomT Offline
                        thomthom
                        last edited by

                        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 returning nil and all attribute dictionaries are gone...

                        Thomas Thomassen β€” SketchUp Monkey & Coding addict
                        List of my plugins and link to the CookieWare fund

                        1 Reply Last reply Reply Quote 0
                        • thomthomT Offline
                          thomthom
                          last edited by

                          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?

                          Thomas Thomassen β€” SketchUp Monkey & Coding addict
                          List of my plugins and link to the CookieWare fund

                          1 Reply Last reply Reply Quote 0
                          • thomthomT Offline
                            thomthom
                            last edited by

                            I looks like it's some wires crossed in the backend. I made a typo when I wanted a DefinitionsObserver, where I instead wrote DefinitionObserver. But the code still worked.

                            So while the DefinitionObserver doesn't trigger the events it's supposed to, it triggers all of DefinitionsObserver'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.

                            Thomas Thomassen β€” SketchUp Monkey & Coding addict
                            List of my plugins and link to the CookieWare fund

                            1 Reply Last reply Reply Quote 0
                            • 1 / 1
                            • First post
                              Last post
                            Buy SketchPlus
                            Buy SUbD
                            Buy WrapR
                            Buy eBook
                            Buy Modelur
                            Buy Vertex Tools
                            Buy SketchCuisine
                            Buy FormFonts

                            Advertisement