sketchucation logo sketchucation
    • Login
    ℹ️ Licensed Extensions | FredoBatch, ElevationProfile, FredoSketch, LayOps, MatSim and Pic2Shape will require license from Sept 1st More Info

    [Bug]Win32api.so and Sketchup7

    Scheduled Pinned Locked Moved Developers' Forum
    12 Posts 9 Posters 2.8k Views 9 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.
    • C Offline
      CPhillips
      last edited by

      I think there is a bug with using Win32api.so and Sketchup7. It looks like the Win32api.so links against msvcr71.dll which was included in Sketchup6 but not 7. Some users may have that .dll in there system directory and some dont. Especially on newly installed machines.

      I think the solution is to make sure the user has it installed either in the windows system directory or perhaps in the Sketchup directory.

      But a better solution might be to use RubyDL instead of win32api. It works under Sketchup and is like a zillion times better at interfacing between DLL's. It works on Mac and Windows and even seamlessly supports structs and function pointers.

      1 Reply Last reply Reply Quote 0
      • daikuD Offline
        daiku
        last edited by

        Chris:

        My plugins use Win32api.so, and so far I haven't seen any problems with SU7. But I upgraded from SU6, so that may be why. Tell us more about RubyDL - this is the first I've heard of it. CB.

        Clark Bremer
        http://www.northernlightstimberframing.com

        1 Reply Last reply Reply Quote 0
        • L Offline
          linea
          last edited by

          Although I don't really understand what you are talking about, you might be on to something that has been puzzling me since I bought SU Pro 6 and installed it on Vista 32 bit when it was first released (I have since installed service pack 1). I have a fairly powerful machine but SU has always seemed a bit clunky and I always have difficulty getting ruby scripts to run, and yes, I always folow the instructions. I have never got Sketchy physics or indigo to run. SU7 is no better.

          1 Reply Last reply Reply Quote 0
          • C Offline
            CPhillips
            last edited by

            @daiku said:

            Chris:

            My plugins use Win32api.so, and so far I haven't seen any problems with SU7. But I upgraded from SU6, so that may be why. Tell us more about RubyDL - this is the first I've heard of it. CB.

            Its part of the standard Ruby install and I just copied the files over. It is meant to do the same job as win32api.so except it has a much nicer interface.

            Here is code to call the getKeyState function in user32.dll using win32api.so

            require 'Win32API' 
            $win32GetKeyStateFunc=Win32API.new("user32.dll", "GetKeyState", ['N'], 'N')
            $win32GetKeyStateFunc.call(0)
            
            

            And the same thing with RubyDL.

            
            
            require "dl"
            require "dl/import"
            module KeyInput
                extend DL;;Importable
                dlload("user32.dll")
                extern "int getKeyState(short)"
            end
            KeyInput.getKeyState(0)
            

            The first good thing is the declaration of the function is more C like than the winapi method of passing the parameter types in a array. And you can call the function without the .Call().

            RubyDL also allows structures to be passed back and forth where win32api does not.

            favicon

            (www.jbrowse.com)

            Chris


            RubyDL-libs.zip

            1 Reply Last reply Reply Quote 0
            • fredo6F Offline
              fredo6
              last edited by

              Chris,

              Interesting.
              But how does it work on Mac?

              Fredo

              1 Reply Last reply Reply Quote 0
              • C Offline
                CPhillips
                last edited by

                @unknownuser said:

                Chris,

                Interesting.
                But how does it work on Mac?

                Fredo

                I wasnt clear. You still need a Mac .dylib that exports the same functions as a Win .DLL. But I did included the dl.bundle file that the Mac version needs use a .dylib.

                1 Reply Last reply Reply Quote 0
                • thomthomT Offline
                  thomthom
                  last edited by

                  This is very interesting.

                  Thomas Thomassen — SketchUp Monkey & Coding addict
                  List of my plugins and link to the CookieWare fund

                  1 Reply Last reply Reply Quote 0
                  • D Offline
                    dburdick
                    last edited by

                    @cphillips said:

                    @daiku said:

                    Chris:

                    My plugins use Win32api.so, and so far I haven't seen any problems with SU7. But I upgraded from SU6, so that may be why. Tell us more about RubyDL - this is the first I've heard of it. CB.

                    Its part of the standard Ruby install and I just copied the files over. It is meant to do the same job as win32api.so except it has a much nicer interface.

                    Here is code to call the getKeyState function in user32.dll using win32api.so

                    require 'Win32API' 
                    > $win32GetKeyStateFunc=Win32API.new("user32.dll", "GetKeyState", ['N'], 'N')
                    > $win32GetKeyStateFunc.call(0)
                    > 
                    

                    And the same thing with RubyDL.

                    
                    > 
                    > require "dl"
                    > require "dl/import"
                    > module KeyInput
                    >     extend DL;;Importable
                    >     dlload("user32.dll")
                    >     extern "int getKeyState(short)"
                    > end
                    > KeyInput.getKeyState(0)
                    

                    The first good thing is the declaration of the function is more C like than the winapi method of passing the parameter types in a array. And you can call the function without the .Call().

                    RubyDL also allows structures to be passed back and forth where win32api does not.

                    favicon

                    (www.jbrowse.com)

                    Chris

                    Hi Chris,

                    I tried your DL example in SU7.1 and it didn't work for some reason. The DL files are all installed correctly in the SU plugins folder. Here's the error:

                    load 'DLTest.rb'
                    Error: #<RuntimeError: C:/Program Files (x86)/Google/Google SketchUp 7/Plugins/dl/import.rb:126:in symbol': can't find the symbol getKeyState'>
                    C:/Program Files (x86)/Google/Google SketchUp 7/Plugins/dl/import.rb:126

                    Any idea why it's bombing on this?

                    1 Reply Last reply Reply Quote 0
                    • D Offline
                      dburdick
                      last edited by

                      I found the problem.

                      getKeyState should start with a caps GetKeyState

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

                        I had this problem when i installed RP Treemaker. Directly when i started SU 7 i get the sign that RP Treemaker wasn't loaded because of the WIN32API.

                        I searched my disc for the fle msvcr71.dll en copied this file into the plugins directory.

                        Now i have no problems, everything works perfectly. So the solution is copy the file to the plugins directory ☀

                        1 Reply Last reply Reply Quote 0
                        • C Offline
                          cjthompson
                          last edited by

                          Do you know which version of Ruby you took the Win32api from?

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

                            @cjthompson said:

                            Do you know which version of Ruby you took the Win32api from?

                            Just as a head's up, so you'll know... Win32API.so is not distributed with Ruby 1.9.x and up. It is replaced by Win32API.rb, which is a translator script, that 'fools' old calls to the Win32API.so, by translating those calls into DL library calls.
                            It is supposed to work transparently, because most uses would load the so by simply:
                            require 'Win32API'
                            The require method looks for .rbfiles first, so it would load the new translator, instead of the .so, ... in a normal ruby install.

                            I'm not here much anymore.

                            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