Win32ole.so procedure/load issue
-
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.
-
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.
-
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 -
@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.
-
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? -
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.
-
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
-
I'm pretty sure that the problem is that you were using win32ole from Ruby 1.9.
Sketchup only uses 1.8.
-
-
@thomthom said:
@cjthompson said:
Sketchup only uses 1.8.
1.8.0 to be exact.
Thanks very much - that would certainly make sense!
Advertisement