Page 1 of 1
Loading newLISP.dll in Google SketchUp 7 Ruby problem
Posted: Sat Apr 04, 2009 6:19 pm
by HPW
I tried to load newLISP.dll on Google SketchUp 7 in the Ruby console.
I do:
I copy "Win32API.so" and the newLISP.dll to the Sketchup Plugins folder
(The library can be found in ruby distribution: \ruby\lib\ruby\1.8\i386-mswin32\Win32API.so)
In the ruby console in SketchUp:
Code: Select all
require 'Win32API'
true
newLISP = Win32API.new("newlisp.dll", "newlispEvalStr", ['P'], 'V')
Error: #<RuntimeError: (eval):131:in `initialize': LoadLibrary: newlisp.dll
>
(eval):131
Some doku here:
http://phrogz.net/ProgrammingRuby/lib_w ... l#Win32API
See: class Win32API < Object
This is a working code example:
Code: Select all
findWindow = Win32API.new("user32.dll", "FindWindow", ['P','P'], 'N')
window_id = findWindow.call(0, sketchup_title)
sendMessage = Win32API.new("user32.dll", "SendMessage", ['N','N','N','P'], 'N')
sendMessage.call(window_id, 0x0010, 0, "")
Not sure if I make a mistake with the calling parameters or what else cause the error.
Posted: Sat Apr 04, 2009 7:22 pm
by HPW
After fiddeling a lot around I finally found the solution:
Code: Select all
require 'Win32API'
true
newLISP = Win32API.new("C:\\Program Files\\Google\\Google SketchUp 7\\Plugins\\newlisp.dll", "newlispEvalStr", ['P'], 'P')
#<Win32API>
newLISP.Call("(sys-info)")
(363 268435456 360 1 0 2048 6064 10003 70)
newLISP.Call("(setq a(+ 10 10))")
20
newLISP.Call("(setq b(+ a 10))")
30
This is a great new option.
Posted this news to:
http://www.sketchucation.com/forums/scf ... 80&t=18127
Posted: Sun Apr 05, 2009 10:22 am
by HPW
Making slow progress with ruby calling after inspecting the exported functions from msvcrt-ruby18.dll:
Code: Select all
require 'Win32API'
true
newLISP = Win32API.new("C:\\Program Files\\Google\\Google SketchUp 7\\Plugins\\newlisp.dll", "newlispEvalStr", ['P'], 'P')
#<Win32API>
newLISP.Call("(import {C:\\Program Files\\Google\\Google SketchUp 7\\msvcrt-ruby18.dll} {rb_eval_string})")
rb_eval_string <1CF2F30>
newLISPret = newLISP.Call("(rb_eval_string {puts \"Ruby called from Lisp\"})")
Ruby called from Lisp
4
newLISP.Call("(rb_eval_string {VERSION})")
47157480
Not sure what the return-value 4 or 47157480 from rb_eval_string means.
Still searching to get values from ruby-calls back to newLISP.
Code: Select all
newLISPret = newLISP.Call("(setq rubyversion(get-string (rb_eval_string {VERSION})))")
"\007\004"
The ruby console shows normal:
Posted: Sun Apr 05, 2009 12:14 pm
by Lutz
47157480
perhaps the memory address of the string coming back?
Posted: Mon Apr 06, 2009 6:14 pm
by m35
This is some neat stuff HPW. I use a little SU, although I try to keep Blender as my primary tool (all my scripts are in Blender). If SU ends up playing a bigger role, I may be back to see how this pans out. :)
Posted: Mon Apr 06, 2009 7:47 pm
by HPW
perhaps the memory address of the string coming back?
Some ruby people told me that it is an ruby object-ID.
This seems a more complex thing.
I am considering to build a helper DLL with delphi using:
http://www.sourcepole.ch/2006/9/1/embed ... lix-delphi
Posted: Tue Apr 07, 2009 7:58 am
by HPW
For someone familar with C/C++ maybe this can help to get a similar newLISP function:
http://www.sourcepole.com/2004/1/21/embedding-ruby-in-c
The delphi version does currently only work from an EXE, so I am in trouble with an helper DLL.
Posted: Tue Apr 14, 2009 7:19 am
by HPW
After making a helper-DLL RubyCall.dll I get further progress:
Here the ruby console log:
require 'Win32API'
true
newLISP = Win32API.new("C:\\Program Files\\Google\\Google SketchUp 7\\Plugins\\newlisp.dll", "newlispEvalStr", ['P'], 'P')
#<Win32API>
newLISP.Call("(import {C:\\Program Files\\Google\\Google SketchUp 7\\RubyCall.dll} {CreateRuby})")
CreateRuby <499C1B4>
newLISP.Call("(import {C:\\Program Files\\Google\\Google SketchUp 7\\RubyCall.dll} {EvalRuby})")
EvalRuby <499C23C>
newLISP.Call("(get-string(CreateRuby \"\"))")
"Ruby interpreter loaded!"
newLISP.Call("(get-string(EvalRuby {name = Sketchup.app_name}))")
"Google SketchUp"
newLISP.Call("(import {C:\\Program Files\\Google\\Google SketchUp 7\\RubyCall.dll} {GetRubyOutput})")
GetRubyOutput <499C338>
newLISP.Call("(get-string(EvalRuby {puts \"Hello World!\";test = 2+2}))")
"4"
newLISP.Call("(get-string(GetRubyOutput \"\"))")
"Hello World!\r\n"
So now I get back all kind (types) of return-values and the accumulated consol-output form ruby's puts commands.
When it is finished I will add it to my newLISP extension page.
Re: Loading newLISP.dll in Google SketchUp 7 Ruby problem
Posted: Sun Jan 22, 2012 10:47 am
by HPW
Hello,
After some more learning about ruby modules with my new pdSript-extension for Sketchup 7/8 I converted the newLISP extension also into a module so it gets its own namespace etc.
http://www.hpwsoft.de/anmeldung/html1/s ... chup2.html
From that link you can download the extension.
Hans-Peter
Re: Loading newLISP.dll in Google SketchUp 7 Ruby problem
Posted: Mon Jan 23, 2012 8:35 pm
by HPW
Hello,
After more improvments/language support to the ruby-module of the newlisp extension for Sketchup 7/8 I upload a new 1.01 version to the above link.
Hans-Peter
Re: Loading newLISP.dll in Google SketchUp 7 Ruby problem
Posted: Tue Jan 24, 2012 9:41 pm
by HPW
Hello,
Finally I make a small website for the plugin:
http://www.hpwsoft.de/anmeldung/html1/s ... chup2.html
Hans-Peter