[Bug]Win32api.so and Sketchup7
-
I think there is a bug with using Win32api.so and Sketchup7. It looks like the Win32api.so links against msvcr71.dll which was included in Sketchup6 but not 7. Some users may have that .dll in there system directory and some dont. Especially on newly installed machines.
I think the solution is to make sure the user has it installed either in the windows system directory or perhaps in the Sketchup directory.
But a better solution might be to use RubyDL instead of win32api. It works under Sketchup and is like a zillion times better at interfacing between DLL's. It works on Mac and Windows and even seamlessly supports structs and function pointers.
-
Chris:
My plugins use Win32api.so, and so far I haven't seen any problems with SU7. But I upgraded from SU6, so that may be why. Tell us more about RubyDL - this is the first I've heard of it. CB.
-
Although I don't really understand what you are talking about, you might be on to something that has been puzzling me since I bought SU Pro 6 and installed it on Vista 32 bit when it was first released (I have since installed service pack 1). I have a fairly powerful machine but SU has always seemed a bit clunky and I always have difficulty getting ruby scripts to run, and yes, I always folow the instructions. I have never got Sketchy physics or indigo to run. SU7 is no better.
-
@daiku said:
Chris:
My plugins use Win32api.so, and so far I haven't seen any problems with SU7. But I upgraded from SU6, so that may be why. Tell us more about RubyDL - this is the first I've heard of it. CB.
Its part of the standard Ruby install and I just copied the files over. It is meant to do the same job as win32api.so except it has a much nicer interface.
Here is code to call the getKeyState function in user32.dll using win32api.so
require 'Win32API' $win32GetKeyStateFunc=Win32API.new("user32.dll", "GetKeyState", ['N'], 'N') $win32GetKeyStateFunc.call(0)
And the same thing with RubyDL.
require "dl" require "dl/import" module KeyInput extend DL;;Importable dlload("user32.dll") extern "int getKeyState(short)" end KeyInput.getKeyState(0)
The first good thing is the declaration of the function is more C like than the winapi method of passing the parameter types in a array. And you can call the function without the .Call().
RubyDL also allows structures to be passed back and forth where win32api does not.
http://www.jbrowse.com/text/rdl_en.html
Chris
-
Chris,
Interesting.
But how does it work on Mac?Fredo
-
@unknownuser said:
Chris,
Interesting.
But how does it work on Mac?Fredo
I wasnt clear. You still need a Mac .dylib that exports the same functions as a Win .DLL. But I did included the dl.bundle file that the Mac version needs use a .dylib.
-
This is very interesting.
-
@cphillips said:
@daiku said:
Chris:
My plugins use Win32api.so, and so far I haven't seen any problems with SU7. But I upgraded from SU6, so that may be why. Tell us more about RubyDL - this is the first I've heard of it. CB.
Its part of the standard Ruby install and I just copied the files over. It is meant to do the same job as win32api.so except it has a much nicer interface.
Here is code to call the getKeyState function in user32.dll using win32api.so
require 'Win32API' > $win32GetKeyStateFunc=Win32API.new("user32.dll", "GetKeyState", ['N'], 'N') > $win32GetKeyStateFunc.call(0) >
And the same thing with RubyDL.
> > require "dl" > require "dl/import" > module KeyInput > extend DL;;Importable > dlload("user32.dll") > extern "int getKeyState(short)" > end > KeyInput.getKeyState(0)
The first good thing is the declaration of the function is more C like than the winapi method of passing the parameter types in a array. And you can call the function without the .Call().
RubyDL also allows structures to be passed back and forth where win32api does not.
http://www.jbrowse.com/text/rdl_en.html
Chris
Hi Chris,
I tried your DL example in SU7.1 and it didn't work for some reason. The DL files are all installed correctly in the SU plugins folder. Here's the error:
load 'DLTest.rb'
Error: #<RuntimeError: C:/Program Files (x86)/Google/Google SketchUp 7/Plugins/dl/import.rb:126:insymbol': can't find the symbol
getKeyState'>
C:/Program Files (x86)/Google/Google SketchUp 7/Plugins/dl/import.rb:126Any idea why it's bombing on this?
-
I found the problem.
getKeyState should start with a caps GetKeyState
-
I had this problem when i installed RP Treemaker. Directly when i started SU 7 i get the sign that RP Treemaker wasn't loaded because of the WIN32API.
I searched my disc for the fle msvcr71.dll en copied this file into the plugins directory.
Now i have no problems, everything works perfectly. So the solution is copy the file to the plugins directory
-
Do you know which version of Ruby you took the Win32api from?
-
@cjthompson said:
Do you know which version of Ruby you took the Win32api from?
Just as a head's up, so you'll know... Win32API.so is not distributed with Ruby 1.9.x and up. It is replaced by Win32API.rb, which is a translator script, that 'fools' old calls to the Win32API.so, by translating those calls into DL library calls.
It is supposed to work transparently, because most uses would load the so by simply:
require 'Win32API'
The require method looks for .rbfiles first, so it would load the new translator, instead of the .so, ... in a normal ruby install.
Advertisement