sketchucation logo sketchucation
    • Login
    1. Home
    2. hanks
    ℹ️ Licensed Extensions | FredoBatch, ElevationProfile, FredoSketch, LayOps, MatSim and Pic2Shape will require license from Sept 1st More Info
    H
    Offline
    • Profile
    • Following 0
    • Followers 0
    • Topics 1
    • Posts 2
    • Groups 1

    hanks

    @hanks

    0
    Reputation
    1
    Profile views
    2
    Posts
    0
    Followers
    0
    Following
    Joined
    Last Online

    hanks Unfollow Follow
    registered-users

    Latest posts made by hanks

    • RE: Observer Usage

      Thanks Jim. Your intuition was right - a call from within a function worked. It's annoying that the API isn't a little clearer about this but I am a noob and there are many things that remain unclear to me.

      posted in Developers' Forum
      H
      hanks
    • Observer Usage

      This may be a stupid question to some of you wizards, but can anyone tell me why this code does not work when pasted into a .rb file and dropped into the plugins directory?

      straight out of the API...

      
      # This is an example of an observer that watches tool interactions.
           class MyToolsObserver < Sketchup;;ToolsObserver
             def onActiveToolChanged(tools, tool_name, tool_id)
               UI.messagebox("onActiveToolChanged; " + tool_name.to_s)
             end
           end
      
           # Attach the observer.
           Sketchup.active_model.tools.add_observer(MyToolsObserver.new)
      
      

      This is the resulting error...

      @unknownuser said:

      Error Loading File section_view.rb
      undefined method `tools' for nil:NilClass

      The script works perfectly however if I call the last part manually using the Ruby Console...

      Sketchup.active_model.tools.add_observer(MyToolsObserver.new)
      

      I suspect that my inability to understand this line of the class intro from the API is why I'm lost...

      @unknownuser said:

      To implement this observer, create a Ruby class of this type, override the desired methods, and add an instance of the observer to the Tools object.

      WTF does override the desired methods mean!!??

      posted in Developers' Forum
      H
      hanks