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: rubylibruby1.8i386-mswin32Win32API.so)
In the ruby console in SketchUp:
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_windows.html#Win32API
See: class Win32API < Object
This is a working code example:
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.
After fiddeling a lot around I finally found the solution:
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/viewtopic.php?f=180&t=18127
Making slow progress with ruby calling after inspecting the exported functions from msvcrt-ruby18.dll:
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.
newLISPret = newLISP.Call("(setq rubyversion(get-string (rb_eval_string {VERSION})))")
" 07 04"
The ruby console shows normal:
VERSION
1.8.0
Quote
47157480
perhaps the memory address of the string coming back?
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. :)
Quote
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/embedding-ruby-in-kylix-delphi
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.
After making a helper-DLL RubyCall.dll I get further progress:
Here the ruby console log:
Quote
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!rn"
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.
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/sketchup/sketchup2.html
From that link you can download the extension.
Hans-Peter
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
Hello,
Finally I make a small website for the plugin:
http://www.hpwsoft.de/anmeldung/html1/sketchup/sketchup2.html
Hans-Peter