• Login
sketchucation logo sketchucation
  • Login
🤑 SketchPlus 1.3 | 44 Tools for $15 until June 20th Buy Now

Adding a callback when vray is dynamically loaded

Scheduled Pinned Locked Moved Developers' Forum
6 Posts 4 Posters 827 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.
  • C Offline
    CAUL
    last edited by 22 Aug 2016, 10:54

    I have an extension that adds a callback to vray. Currently the callback is added in an app observer which fires after all extensions have been loaded. However, if vray is loaded dynamically after Sketchup has started this doesn’t work.

    jiminy-billy-bob suggested using a timer which polls vray every N seconds and though this does work there is something not very pretty about it. Ideally I would like to passively listen to vray being enabled and then add the callback. The question is whether there is a way to accomplish this?

    1 Reply Last reply Reply Quote 0
    • T Offline
      thomthom
      last edited by 22 Aug 2016, 13:45

      You need to detect when VfSU loads?

      Or do you need to check if is loaded or not?

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

      1 Reply Last reply Reply Quote 0
      • C Offline
        CAUL
        last edited by 22 Aug 2016, 15:59

        @thomthom said:

        You need to detect when VfSU loads?[...]

        Exactly. When a user loads vfSU dynamically after Sketchup has launched I would like the extension to receive some kind of notification so that the callback can be added. Like an observer listening for an event.

        1 Reply Last reply Reply Quote 0
        • T Offline
          thomthom
          last edited by 23 Aug 2016, 09:26

          hm... that's a tricky one... There is an even for extensions being unloaded. But no generic load event...

          In what context is the callback used? Is this something you can lazy-load when your own extension is being interacted with?

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

          1 Reply Last reply Reply Quote 0
          • D Offline
            Dan Rathbun
            last edited by 24 Aug 2016, 12:36

            @thomthom said:

            hm... that's a tricky one... There is an event for extensions being unloaded. But no generic load event...

            What I have done in the past is create a custom subclass of the SketchupExtension class. In this subclass, I override the load() method being sure to first call super then do what I need to do when the extension has been loaded.

            require "extensions.rb"
            
            module CAUL;;VrayAware
            
              class VrExten < SketchupExtension
                def load()
                  super # call load() in superclass
                  #
                  # Do other on load stuff here.
                  #
                end
              end
            
              @@ext = VrExten.new("Vray","CAUL_VrayLoader")
            
              # Set the rest of the extension variables (version, creator, etc.)
            
              Sketchup.register_extension(@@ext)
            
            end
            
            

            I'm not here much anymore.

            1 Reply Last reply Reply Quote 0
            • D Offline
              dkendig
              last edited by 17 Oct 2016, 08:15

              ::sleepily opens one eye::

              hmmmmm?... this sounds like someone is dabbling with scary things...

              Devin Kendig
              Developer

              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