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!
    🛣️ Road Profile Builder | Generate roads, curbs and pavements easily Download

    Win32ole.so procedure/load issue

    Scheduled Pinned Locked Moved Developers' Forum
    13 Posts 6 Posters 5.3k Views 6 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.
    • daikuD Offline
      daiku
      last edited by

      I haven't used it with Access, but I have used it with Excel. Here's a code snippet:

      		if excel_mode
      			require('win32ole')			
      			excel = WIN32OLE;;new('excel.Application')
      			print( "excel version; " + excel.version.to_s + "\n")
      			unless file_loaded?("excel_constants")
      				WIN32OLE.const_load(excel, ExcelConst)
      				file_loaded("excel_constants")
      			end
      			excel.visible = false
      			if excel.version.to_f >= 12 
      				then tl_file_name = UI.savepanel("Save Timber List", "","timber_list.xlsx")
      				else tl_file_name = UI.savepanel("Save Timber List", "","timber_list.xls")
      			end	
      		end
      
      

      Hope that's helpful. CB.

      Clark Bremer
      http://www.northernlightstimberframing.com

      1 Reply Last reply Reply Quote 0
      • K Offline
        khogg
        last edited by

        Clark,
        appreciate the reply - confirms that we should indeed be able to get this to fly. A few questions for you:

        1. Did you have to do anything special to get this work such as locate certain files in a particular location (i.e. win32ole.so, etc.) or maybe setup your PATH statement to look into a particular location?
        2. Assume you're running Windows - version...?
        3. Are you running the default Ruby installed with SketchUp - I think in SketchUp 7 it's Ruby 1.8.0?

        Bottom line is we need to get past the error on our require statement and looks like we'll probably be good. Any further thoughts would be greatly appreciated...!

        Thanks again,
        Kevin

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

          No, I didn't do anything special with the path. Just drop win32ole.so into the plugins folder. I'm running 64-bit vista, but I've tested this on XP as well, and with multiple versions of excel. Default Ruby installation that comes with SU. CB.

          Clark Bremer
          http://www.northernlightstimberframing.com

          1 Reply Last reply Reply Quote 0
          • M Offline
            MartinRinehart
            last edited by

            I have had good results using ACCESS to write Java. No reason to believe that the same doesn't apply with Ruby. Write the .rb with ACCESS (very capable report writing in ACCESS). Then run the .rb. No Windows-dependent issues.

            Author, Edges to Rubies - The Complete SketchUp Tutorial at http://www.MartinRinehart.com/models/tutorial.

            1 Reply Last reply Reply Quote 0
            • K Offline
              khogg
              last edited by

              Clark,
              thanks for the clarification on what it took to get win32ole to work. Sounds like it might be worth my time to do a complete reinstall of SU and try again.

              Martin,
              what you mention sounds interesting. We're basically trying to read the contents of an MDB file and use this information to draw objects. Is this the type of things you're doing with MS Access and Java, and if so, could you provide an example?

              Thanks to you both,
              Kevin

              1 Reply Last reply Reply Quote 0
              • M Offline
                MartinRinehart
                last edited by

                @khogg said:

                Is this the type of things you're doing with MS Access and Java, and if so, could you provide an example?

                Client-proprietary work, but I can say a little more. I assume your MDB has stuff you want sketched up. It must be some sort of table(s) listing type of thing, material, size, location, ... A finished Ruby program would be:

                Some preliminary stuff, comments, 'require "sketchup.rb"', etc. You put these where you would normally have a report header.

                for each record a call to "draw_whatever( size, material, location args from your database)"

                footer = Ruby code for "draw_this", "draw_that", etc.

                You code "draw_this" and "draw_that" the old-fashioned way. When the Ruby is tested, copy it into the report footer. Write the report body to output calls to the draw routines. Run the report. Look like code?

                Add more blank lines (one every five records? more between logical groups?) Add the header, run the report, writing it to "my_program.rb". SketchUp to the Ruby Console, 'load "my_program.rb"' and off you go!

                And if the Google Chrome OS catches fire (big Linux fan here!) you aren't facing a technological dead end with a Windows-locked-in system.

                Author, Edges to Rubies - The Complete SketchUp Tutorial at http://www.MartinRinehart.com/models/tutorial.

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

                  One quick note: Your intitial post says require <require 'Win32ole.so'>
                  Note that in my code, there is no .so file name extension. Perhaps that's the problem?

                  Clark Bremer
                  http://www.northernlightstimberframing.com

                  1 Reply Last reply Reply Quote 0
                  • M Offline
                    muchado
                    last edited by

                    Sorry about resurrecting this thread (or trying to, anyway).

                    I am also having problems in loading (or using) the win32ole module (on a WinXP PC). For those using Macs as I also do, I doubt there is any point in using win32ole. Presumably one would have to find some way of using the Automator or some other form of scripting.

                    On starting SketchUp, I opened the Ruby Console and listed the extensions (I have used prompt> to indicate the lines that I typed):

                    prompt> p $"
                    ["examples.rb", "sketchup.rb", "langhandler.rb", "extensions.rb", "LangHandler.rb", "ocean_extension.rb", "utilities.rb", "C;/Program Files/Google/Google SketchUp 7/Plugins/Utilities/utilitiesTools.rb", "dynamiccomponents.rb", "C;/Program Files/Google/Google SketchUp 7/Tools/DynamicComponents/ruby/dcloader.rb", "make_pano_pm.rb", "sandboxtools.rb", "C;/Program Files/Google/Google SketchUp 7/Tools/Sandbox/SandboxMenus.rb", "webtextures.rb", "C;/Program Files/Google/Google SketchUp 7/Tools/WebTextures/webtextures_loader.rb"]
                    nil
                    
                    

                    I then tried to load the win32ole module ("win32ole.so"), which I had extracted from the zip file "ruby-1.9.1-p376-i386-mswin32.zip" and had placed in the plugins directory. Note that I did not "install" ruby or do anything other than extract this file.

                    prompt> require 'win32ole'
                    Error; #<LoadError; C;/Program Files/Google/Google SketchUp 7/Plugins/win32ole.so; 126; The specified module could not be found.   - C;/Program Files/Google/Google SketchUp 7/Plugins/win32ole.so>
                    (eval);894
                    
                    

                    It seemed to me that I had therefore failed. I therefore tried a different format (not being sure of the difference between single and double quotes)

                    prompt> require "win32ole"
                    false
                    
                    

                    Now this was strange.. why was I getting a "false" response. Did this mean that win32ole was already loaded...?

                    prompt> p $"
                    ["examples.rb", "sketchup.rb", "langhandler.rb", "extensions.rb", "LangHandler.rb", "ocean_extension.rb", "utilities.rb", "C;/Program Files/Google/Google SketchUp 7/Plugins/Utilities/utilitiesTools.rb", "dynamiccomponents.rb", "C;/Program Files/Google/Google SketchUp 7/Tools/DynamicComponents/ruby/dcloader.rb", "make_pano_pm.rb", "sandboxtools.rb", "C;/Program Files/Google/Google SketchUp 7/Tools/Sandbox/SandboxMenus.rb", "webtextures.rb", "C;/Program Files/Google/Google SketchUp 7/Tools/WebTextures/webtextures_loader.rb", "win32ole.so"]
                    nil
                    prompt> require 'win32ole'
                    false
                    
                    

                    Hmmm... it seems that win32ole is loaded, but I never got a message to say that it was being loaded. Can I use it...

                    prompt> excel = WIN32OLE;;new('excel.Application')
                    excel = WIN32OLE;;new('excel.Application')
                    Error; #<NameError; (eval);894; uninitialized constant WIN32OLE>
                    (eval);894
                    prompt> print( "excel version; " + excel.version.to_s + "\n")
                    Error; #<NoMethodError; (eval);894; undefined method `version' for nil;NilClass>
                    (eval);894
                    

                    No... it seems not... so what am I doing wrong? I also tried WIN32OLE.new and win32ole.new and neither of them worked. If anyone can help me, I would appreciate it.

                    1 Reply Last reply Reply Quote 0
                    • M Offline
                      muchado
                      last edited by

                      OK - I still don't know what I was doing wrong last time, but it seems that there was a problem with the win32ole file that I was using.

                      I tried out the example called "excel_tests.zip" at http://www.crai.archi.fr/RubylibraryDepot/Ruby/em_fil_page.htm and this worked. The zip file contains a "win32ole.so" file which I have placed in the Plug-ins directory in place of the one I had before. [For those using Macs, there is an example for Macs, which (of course) does not require win32ole.]

                      As an aside... I found that I needed to place the win32ole.so file in the Plug-ins directory. I didn't appear to be able to "require" it from a sub-directory (but that might just be my own problem).

                      require 'subfolder/win32ole'
                      

                      Having placed the new win32ole.so file in the Plug-ins directory, I was then able to load it and I could then check out the loaded modules (using p $") which now included win32ole.so. In case anyone else is looking for help, I also found the following "methods" useful for listing the methods that the win32ole makes available to you:

                      GsaObj = WIN32OLE.new("Gsa.comAuto")
                      #<WIN32OLE;0xd883e30>
                      GsaObj.methods
                      ...
                      GsaObj.ole_methods
                      ...
                      GsaObj.ole_get_methods
                      ...
                      
                      

                      By way of explanation - I was creating a new GSA object (for structural analysis) by way of the COM commands that come with the program (from Oasys software). If you are creating an excel object, then it would look like this:

                      excel = WIN32OLE.new("excel.application")
                      excel.methods
                      excel.ole_methods
                      excel.ole_get_methods
                      
                      
                      1 Reply Last reply Reply Quote 0
                      • C Offline
                        cjthompson
                        last edited by

                        I'm pretty sure that the problem is that you were using win32ole from Ruby 1.9.

                        Sketchup only uses 1.8.

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

                          @cjthompson said:

                          Sketchup only uses 1.8.

                          1.8.0 to be exact.

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

                          1 Reply Last reply Reply Quote 0
                          • M Offline
                            muchado
                            last edited by

                            @thomthom said:

                            @cjthompson said:

                            Sketchup only uses 1.8.

                            1.8.0 to be exact.

                            Thanks very much - that would certainly make sense!

                            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