WIN32OLE_RECORD and WIN32OLE_VARIANT

Dominic Sisneros <[email protected]> Wed, 23 Oct 2019 15:13:33 -0600
Newsgroups gmane.comp.lang.ruby.general
Message-ID <CABdJ6sx4zm+Q0PjhEUjVwifP7AzU+n53hL1Ksc1xO8seVAkn6Q@mail.gmail.com>
I have an array of WIN32OLE_RECORD objects

ole_pts = pts.map{|pt| app.to_ole_point3d(pt)}
=> [#<WIN32OLE_RECORD(Point3d) {"X"=>0.0, "Y"=>0.0, "Z"=>0.0}>,
 #<WIN32OLE_RECORD(Point3d) {"X"=>10.0, "Y"=>0.0, "Z"=>0.0}>,
 #<WIN32OLE_RECORD(Point3d) {"X"=>10.0, "Y"=>10.0, "Z"=>0.0}>,
 #<WIN32OLE_RECORD(Point3d) {"X"=>0.0, "Y"=>10.0, "Z"=>0.0}>,
 #<WIN32OLE_RECORD(Point3d) {"X"=>0.0, "Y"=>0.0, "Z"=>0.0}>]

When I try to convert it to a WIN32OLE_VARIANT array it gives an error

[80] pry(main)> obj = WIN32OLE_VARIANT.new(ole_pts)
TypeError: can not convert WIN32OLE_VARIANT from type WIN32OLE_RECORD

I think I need to convert it to a VARIANT ARRAY because I have the
following ole function - function signature from olegen.rb

 # _LineElement CreateLineElement1
  #   _Element arg0 --- Template [IN]
  #   Point3d arg1 --- Vertices [IN/OUT]
  def CreateLineElement1(arg0, arg1)
    ret = _invoke(1610743981, [arg0, arg1], [VT_BYREF|VT_DISPATCH,
VT_BYREF|VT_ARRAY|VT_DISPATCH])
    @lastargs = WIN32OLE::ARGV
    ret
  end

when called it gives me a HRESULT error code:0x80020005 Type mismatch


Unsubscribe: <mailto:[email protected]?subject=unsubscribe>
<http://lists.ruby-lang.org/cgi-bin/mailman/options/ruby-talk>