A common pitfall I see SketchUp plugin developers fall into is finding the correct path to where their plugin is installed. It is important to realise that a plugin might not be installed in SketchUp’s Plugins. The reasons are many, but a very common one, that’s becoming more popular these days, is using a shared external location in order to use the same plugins on multiple versions of SketchUp or even between multiple computers. With the appearance of services such as Dropbox, Sky Drive, Google Drive etc. many users have found it convenient to install their plugins to a folder using one of these services. Then there is a proxy loading script in the actual SketchUp plugins folder that will make SketchUp look for and load plugins in other locations.
Because of that you should never use
Sketchup.find_support_file when you need the path to your plugin and any accompanying files. Instead you should make use of the magic constant
__FILE__ which gives you the path and filename to the executing file. In order to get the path you simply use:
File.dirname( __FILE__ ). Follow this pattern and your plugin will be portable and can be installed from any location the user desires. And it makes the pandas happy. We want happy pandas.
Off course, a good advice is always accompanied by a caveat. When you use scrambled ruby file you cannot use the
__FILE__ contant since the code is evaluated after descrypting. For this I have another patten which I use and recommend. Use an unscrambled loader. This loader stores the path in an instance or class variable in your root module (because every plugin should be isolated) which then can be used in the scambled files to determine the base path of the plugin.