Set path for request dlls
-
I created mymodule.so. I put it in plugins/myplugin folder. Created myplugin.rb in plugins.
myplugin.rbrequire 'myplugin/mymodule.so'If I run myplugin.rb, I get a message box that is not found mylib1.dll and mylib2.dll.
How to specify where to find dlls?
Copying mylib1.dll and mylib2.dll in sketchup folder solves this problem, but I would like to specify the location of the directory with dlls. -
Solution
require 'myplugin/Win32API' LoadLibrary = Win32API.new("kernel32","LoadLibrary",["P"],"I") path='' # set path to dir with dlls dllname=path+'mylib1.dll' LoadLibrary.call(dllname) dllname=path+'mylib2.dll' LoadLibrary.call(dllname) -
Most people (who run Su on PC,) already have a copy of Win32API.so where their $LOAD_PATH array can find it, so you should only need to:
require 'Win32API'
if it's already loaded, require will skip reloading it.You can even get more fancy, by first checking if it's loaded, because it defines the class Win32API, and classnames are constants ie:
unless (defined? Win32API)=='constant' %(#F0F0F0)[__]require 'Win32API' endAlso.. I think you must unload those DLLs when your plugin is done with them. Perhaps you might need to use a custom AppObserver implementing the onQuit callback, with your plugin.
Hello! It looks like you're interested in this conversation, but you don't have an account yet.
Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.
With your input, this post could be even better π
Register LoginAdvertisement