sketchucation logo sketchucation
    • Login
    Oops, your profile's looking a bit empty! To help us tailor your experience, please fill in key details like your SketchUp version, skill level, operating system, and more. Update and save your info on your profile page today!
    🫛 Lightbeans Update | Metallic and Roughness auto-applied in SketchUp 2025+ Download

    NewLISP-interpreter in SketchUp-Ruby

    Scheduled Pinned Locked Moved Developers' Forum
    16 Posts 4 Posters 3.3k Views 4 Watching
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • H Offline
      HPW
      last edited by

      @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.

      1 Reply Last reply Reply Quote 0
      • H Offline
        HPW
        last edited by

        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.

        1 Reply Last reply Reply Quote 0
        • H Offline
          HPW
          last edited by

          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.

          1 Reply Last reply Reply Quote 0
          • H Offline
            HPW
            last edited by

            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

            1 Reply Last reply Reply Quote 0
            • Dan RathbunD Offline
              Dan Rathbun
              last edited by

              @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.)

              I'm not here much anymore.

              1 Reply Last reply Reply Quote 0
              • Dan RathbunD Offline
                Dan Rathbun
                last edited by

                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 a LoadError 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.

                I'm not here much anymore.

                1 Reply Last reply Reply Quote 0
                • H Offline
                  HPW
                  last edited by

                  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

                  1 Reply Last reply Reply Quote 0
                  • H Offline
                    HPW
                    last edited by

                    Hello,

                    I updated the ZIP with the latest corrections.

                    Hans-Peter

                    1 Reply Last reply Reply Quote 0
                    • H Offline
                      HPW
                      last edited by

                      Hello,

                      After some deeper insights with ruby module with the pdScript-extension here:
                      http://forums.sketchucation.com/viewtopic.php?f=180&t=42730

                      I make also the newLISP extension to a module.

                      Interested who want to try it can download here:

                      HPW's newLISP page

                      favicon

                      (www.hpwsoft.de)

                      The ZIP contains 1 file at the toplevel:
                      newLISP_ext.rb

                      The 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#p380121

                      Regards

                      Hans-Peter

                      1 Reply Last reply Reply Quote 0
                      • H Offline
                        HPW
                        last edited by

                        Hello,

                        I made a small page for the sketchup plugins on my website.
                        I updated the above link for the download.

                        Hans-Peter

                        1 Reply Last reply Reply Quote 0
                        • 1 / 1
                        • First post
                          Last post
                        Buy SketchPlus
                        Buy SUbD
                        Buy WrapR
                        Buy eBook
                        Buy Modelur
                        Buy Vertex Tools
                        Buy SketchCuisine
                        Buy FormFonts

                        Advertisement