NewLISP-interpreter in SketchUp-Ruby
-
@unknownuser said:
do they have a Mac friendly version?
Lutz (creator of newLISP) wrote on the newLISP-forum:
@unknownuser said:
Should be possible, the newLISP library behaves like a normal C library on Mac OS X with cdecl calling conventions.
So can Ruby on the MAC import C librarys?
@unknownuser said:
But ultimately, you're right, if you find it useful for your work, knock yourself out.
That was my point here, I see it as an addition to ruby and not an replacement.
Of cource some kind of callback-possibilitys would be even better.
I have done this in enviroments like delphi and neobook.
So still room for improvments. -
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;0x813bb48> 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.
What is the return-type of ruby's VERSION?
Still searching to get values from ruby-calls back to newLISP. -
After making a helper-DLL RubyCall.dll I get further progress:
@unknownuser said:
require 'Win32API'
true
newLISP = Win32API.new("C:\Program Files\Google\Google SketchUp 7\Plugins\newlisp.dll", "newlispEvalStr", ['P'], 'P')
#Win32API:0x8d26ef8
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.
-
Hello,
After even more help from Dan with the pdScript-extension I ported the same module and language support to the newLISP extension and make a version 1.01
Still under the link above to download.Hans-Peter
-
@hpw said:
After even more help from Dan with the pdScript-extension I ported the same module and language support to the newLISP extension ...
I suppose we should make a Mixin Library module from that, so it can be mixed into any module, without "porting" (which is tweaking module wrapper name and file info in the doc header, [which still refers to PdScript in the NewLisp langLoad.rb file, BTW.])
That way there is only one copy of the code (in memory.)
-
NewLip_ext.rb
line 19, is like this (symbolic args.):
@@extension = SketchupExtension.new ( *arg1*, *arg2* )
Ruby 1.8.6 does not like a space between the method name and the
(
of the argument list. The interpreter will often spit out a warning, and sometimes refuse to load the file (causing aLoadError
exception to be raised.)Should be:
@@extension = SketchupExtension.new( *arg1*, *arg2* )
You should also get in the habit of wrapping all argument lists in
( )
, as they will be required in later versions of Ruby. -
Hello Dan,
Oops, typo on my side. Will correct it later.
Strange: It does work for me without errors.I hopy that ruby does not get more formating aware like for example python.
Hans-Peter
-
Hello,
I updated the ZIP with the latest corrections.
Hans-Peter
-
Hello,
After some deeper insights with ruby module with the pdScript-extension here:
http://forums.sketchucation.com/viewtopic.php?f=180&t=42730I make also the newLISP extension to a module.
Interested who want to try it can download here:
http://www.hpwsoft.de/anmeldung/html1/sketchup/sketchup2.html
The ZIP contains 1 file at the toplevel:
newLISP_ext.rbThe rb is the extension which must be activated in the preferences.
The subfolder contains the DLL's and samples. Preserve the folder when you unpack the ZIP.
The extension adds a menu to the plugins menu with some demo.The Win32API extension is needed from here:
http://forums.sketchucation.com/viewtopic.php?f=323&t=42732#p380121Regards
Hans-Peter
-
Hello,
I made a small page for the sketchup plugins on my website.
I updated the above link for the download.Hans-Peter
Advertisement