Win32ole.so procedure/load issue

Win32ole.so procedure/load issue

Postby khogg » Wed Aug 19, 2009 6:48 pm

Hello,
been searching the forums for a while now without luck, so decided to post a new topic. What we're trying to do is utilize MS Access mdb files as a basis to do some drawing within SketchUp. As such, we've read to use Win32ole.so, etc. The problem we're experiencing is when the command <require 'Win32ole.so'> is executed, it comes back with the following error (note we have no problems with the same line of code when executing in pure Ruby, outside of SketchUp):

Error: #<LoadError: D:/apps/SketchUp/Plugins/Win32OLE.so: 127: The specified procedure could not be found. - Init_Win32OLE
D:/apps/SketchUp/Plugins/Win32OLE.so>

Note one post mentioned capitalization which I tried with no luck. For reference, I'm running Win XP. Any help would be greatly appreciated!!

Thanks,
Kevin
0

khogg 
 

Re: Win32ole.so procedure/load issue

Postby daiku » Wed Aug 19, 2009 9:20 pm

I haven't used it with Access, but I have used it with Excel. Here's a code snippet:
Code: Select all
      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.
0
User avatar
daiku 
PluginStore Author
PluginStore Author
 

Re: Win32ole.so procedure/load issue

Postby khogg » Wed Aug 19, 2009 10:26 pm

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
0

khogg 
 

Re: Win32ole.so procedure/load issue

Postby daiku » Thu Aug 20, 2009 2:21 pm

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.
0
User avatar
daiku 
PluginStore Author
PluginStore Author
 

Re: Win32ole.so procedure/load issue

Postby MartinRinehart » Thu Aug 20, 2009 2:30 pm

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.
0
Author, Edges to Rubies - The Complete SketchUp Tutorial at http://www.MartinRinehart.com/models/tutorial.

MartinRinehart 
 

Re: Win32ole.so procedure/load issue

Postby khogg » Thu Aug 20, 2009 7:36 pm

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
0

khogg 
 

Re: Win32ole.so procedure/load issue

Postby MartinRinehart » Thu Aug 20, 2009 8:41 pm

khogg wrote: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.
0
Author, Edges to Rubies - The Complete SketchUp Tutorial at http://www.MartinRinehart.com/models/tutorial.

MartinRinehart 
 

Re: Win32ole.so procedure/load issue

Postby daiku » Fri Aug 21, 2009 3:12 pm

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?
0
User avatar
daiku 
PluginStore Author
PluginStore Author
 

Re: Win32ole.so procedure/load issue

Postby muchado » Thu Feb 18, 2010 4:32 am

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):

Code: Select all
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.
Code: Select all
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)
Code: Select all
prompt> require "win32ole"
false

Now this was strange.. why was I getting a "false" response. Did this mean that win32ole was already loaded...?
Code: Select all
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...

Code: Select all
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.
0

muchado 
 

Re: Win32ole.so procedure/load issue

Postby muchado » Thu Feb 18, 2010 5:16 am

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

Code: Select all
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:
Code: Select all
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:
Code: Select all
excel = WIN32OLE.new("excel.application")
excel.methods
excel.ole_methods
excel.ole_get_methods
0

muchado 
 

Re: Win32ole.so procedure/load issue

Postby cjthompson » Thu Feb 18, 2010 2:06 pm

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

Sketchup only uses 1.8.
0

cjthompson 
 

Re: Win32ole.so procedure/load issue

Postby thomthom » Thu Feb 18, 2010 2:12 pm

cjthompson wrote:Sketchup only uses 1.8.


1.8.0 to be exact.
0
Thomas Thomassen — SketchUp Monkey & Coding addict
List of my plugins and link to the CookieWare fund
User avatar
thomthom 
PluginStore Author
PluginStore Author
 

Re: Win32ole.so procedure/load issue

Postby muchado » Mon Mar 22, 2010 9:27 pm

thomthom wrote:
cjthompson wrote:Sketchup only uses 1.8.


1.8.0 to be exact.


Thanks very much - that would certainly make sense!
0

muchado 
 

SketchUcation One-Liner Adverts

by Ad Machine » 5 minutes ago



Ad Machine 
Robot
 



 

Return to Developers' Forum

cron

Who is online

Users browsing this forum: No registered users and 11 guests

Visit our sponsors: