NewLISP-interpreter in SketchUp-Ruby
-
Sounds neat! PC onl then I'm guessing? do they have a Mac friendly version? (not that I need it, but there are lots of Mac people around).
Chris
-
newLISP runs on the MAC and on a lot other plattforms.
I am not sure about the DLL/SO-calling from ruby to modules on the MAC.
I posted a related question to the OSX section in the newLISP forum. -
Am I missing something here? If it has no bindings to the underlying SU objects, whats the point?
-
@unknownuser said:
If it has no bindings to the underlying SU objects, whats the point?
First it can be usefull for someone who wants to import lisp-base data into SU.
And when there would be any DLL which would export such command for accessing the SU objects newlISP could '(import ....)' this command.
Are there other extensions with bindings to SU?
-
I should explain. The Ruby in SU isn't just a Ruby interpreter included in the package - in the same way as newLISP is an interpreter. The Ruby you get in SU is integrated into SU, so SU data structures appear as first class objects in Ruby. Without this, there is just not a lot you can do with newLISP. Sure, you can create some strings that you can pass to Ruby but you get no advantage to running newLISP in the SU environment compared to running outside and writing to a file.
But ultimately, you're right, if you find it useful for your work, knock yourself out.
Adam
-
@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