Adding a callback when vray is dynamically loaded
-
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?
-
You need to detect when VfSU loads?
Or do you need to check if is loaded or not?
-
@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.
-
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?
-
@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 theload()
method being sure to first callsuper
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
-
::sleepily opens one eye::
hmmmmm?... this sounds like someone is dabbling with scary things...
Advertisement