Hello all,
I’m trying to make an API call for an application designed to work with
VB code, but I’m running into issues with variable types of an API
function that has 6 input args (STRING, 4 INT4s, BOOL) and 2 output args
(2 OBJECTs).
Here’s my code and everything I’ve tried thus far based on what I’ve
read from other posts with similar issues:
require ‘win32ole’
include WIN32OLE::VARIANT
femap = WIN32OLE::connect(‘femap.model’)
#Would like to do this:
vset, oset = femap.feSet, femap.feSet
arg0 = ‘some string’
arg1, arg2, arg3, arg4 = 0, 0, 4, 7
arg5 = true
femap.feSelectOutput( arg0, arg1, arg2, arg3, arg4, arg5, vset, oset )
#results in:
#WIN32OLERuntimeError: (in OLE method `feSelectOutput’: )
OLE error code:0 in
HRESULT error code:0x80020005
Type mismatch.
from interfaceloads.rb:30:in `method_missing’
from interfaceloads.rb:30:in `<top (required)>’
from (irb):49:in `load’
from (irb):49
from C:/Ruby/bin/irb:12:in `’
#Have tried this as well: (20426 is the dispid)
femap._invoke( 20426, [ ‘’, 0, 0, 4, 7, true, nil, nil ],
[ VT_BSTR, VT_I4, VT_I4, VT_I4, VT_I4, VT_BOOL, VT_BYREF|VT_VARIANT,
VT_BYREF|VT_VARIANT ] )
#results in same error
#(1)If I change the VT_VARIANTs to VT_NULL or VT_EMPTY I get the same
error.
#(2)If I change the nils to Object.new I get the same error.
#(3)If I do both (1) & (2) I get a different error:
#WIN32OLERuntimeError: (in OLE method `’: )
OLE error code:0 in
HRESULT error code:0x80020008
Bad variable type.
from interfaceloads.rb:24:in `_invoke’
from interfaceloads.rb:24:in `<top (required)>’
from (irb):54:in `load’
from (irb):54
from C:/Ruby/bin/irb:12:in `’
Please help!!!
Thank you,
Jeff S
Edit: I can’t count