WIN32OLE return type USERDEFINED

I am trying to use WIN32OLE to automate Microstation

I have a function

I have an instantiated object
ole.ole_typelib // #<WIN32OLE_TYPELIB:Bentley MicroStation DGN 8.9
Object
Library>
app_type = .ole_type // #<WIN32OLE_TYPE:_Application>
method = WIN32OLE_METHOD.new(app,‘Point3dFromXYZ’)
method.params // [#<WIN32OLE_PARAM:Ax>, #<WIN32OLE_PARAM:Ay>,
#<WIN32OLE_PARAM:Az>]
meth.return_type_detail // [“USERDEFINED”, “Point3d”]

(rdb:1) ole.ole_type
#<WIN32OLE_TYPE:_Application>
(rdb:1) app_type = ole.ole_type
#<WIN32OLE_TYPE:_Application>
(rdb:1) WIN32OLE_METHOD.new(app_type,‘Point3dFromXYZ’)
#<WIN32OLE_METHOD:Point3dFromXYZ>
(rdb:1) meth = WIN32OLE_METHOD.new(app_type,‘Point3dFromXYZ’)
(rdb:1) meth.params
[#<WIN32OLE_PARAM:Ax>, #<WIN32OLE_PARAM:Ay>, #<WIN32OLE_PARAM:Az>]
(rdb:1) meth.return_type_detail
[“USERDEFINED”, “Point3d”]

so it takes three values and returns a Point3d object. How can I call
this?

if I do

ole.Point3dFromXYZ(3,3,2)
pt = WIN32OLE::ARGV
it gives me an array

(rdb:1) ole.Point3dFromXYZ(0,1,2)
nil
(rdb:1) pt = WIN32OLE::ARGV
[0, 1, 2]
(rdb:1) pt.class
Array

(rdb:1) pointClass = ole.ole_typelib.ole_classes.select{|c| c.name =~
/point3d/i}.first
#<WIN32OLE_TYPE:Point3d>
(rdb:1) point.guid
“{7B10D1D8-7A13-4AB2-8119-DFB0606C0C56}”
(rdb:1) WIN32OLE.new(point.guid)
WIN32OLERuntimeError Exception: failed to create WIN32OLE object from
`{7B10D1D8-7A13-4AB2-8119-DFB0606C0C56}’
HRESULT error code:0x80040154
Class not registered
(rdb:1)

Thanks,

Hello
On Fri, Nov 18, 2011 at 09:27:35AM +0900, Dominic S. wrote:

so it takes three values and returns a Point3d object. How can I call this?

if I do

ole.Point3dFromXYZ(3,3,2)
pt = WIN32OLE::ARGV
it gives me an array

Try the following.

pt = ole.Point3dFromXYZ(3,3,2)

Best Regards,
Masaki S.

Hello,

On Sat, Nov 19, 2011 at 02:11:18AM +0900, Dominic S. wrote:

Try the following.

pt = ole.Point3dFromXYZ(3,3,2)

pt = ole.Point3dFromXYZ(3,3,2)
-> nil
pt
-> nil

Ooops, sorry.
I’m not sure, but you might specify parameter type
when you call Point3dFromXYZ.
What is the result of the following?

meth = WIN32OLE_METHOD.new(app_type,‘Point3dFromXYZ’)
meth.params.map{|e| e.ole_type_detail}

Best Regards,
Masaki S.

Ooops, sorry.
I’m not sure, but you might specify parameter type
when you call Point3dFromXYZ.
What is the result of the following?

meth = WIN32OLE_METHOD.new(app_type,‘Point3dFromXYZ’)
meth.params.map{|e| e.ole_type_detail}

(rdb:1) meth = WIN32OLE_METHOD.new(app_type, ‘Point3dFromXYZ’)
#<WIN32OLE_METHOD:Point3dFromXYZ>
(rdb:1) meth.params.map{|e| e.ole_type_detail}
[[“R8”], [“R8”], [“R8”]

Thanks for your help

Hello,

On Sat, Nov 19, 2011 at 03:36:28PM +0900, Dominic S. wrote:

(rdb:1) meth = WIN32OLE_METHOD.new(app_type, ‘Point3dFromXYZ’)
#<WIN32OLE_METHOD:Point3dFromXYZ>
(rdb:1) meth.params.map{|e| e.ole_type_detail}
[[“R8”], [“R8”], [“R8”]

The all arguments of Point3dFromXYZ should be Float.
Try the following.

pt = ole.Point3dFromXYZ(3.0,3.0,2.0)

or

pt = ole.Point3dFromXYZ(3.to_f,3.to_f,2.to_f)

Best Regards,
Masaki S.

Try the following.

pt = ole.Point3dFromXYZ(3,3,2)

Best Regards,
Masaki S.

pt = ole.Point3dFromXYZ(3,3,2)
-> nil
pt
-> nil

2011/11/19 Masaki S. [email protected]

Try the following.

pt = ole.Point3dFromXYZ(3.0,3.0,2.0)

or

pt = ole.Point3dFromXYZ(3.to_f,3.to_f,2.to_f)

(rdb:1) pt = app.ole.Point3dFromXYZ(1.0,2.0,3.0)
nil
(rdb:1) pt
nil

(rdb:1) include WIN32OLE::VARIANT
Object
(rdb:1) a1 = WIN32OLE_VARIANT.new(1,VT_R8)
#<WIN32OLE_VARIANT:0x1780818>
(rdb:1) a2 = WIN32OLE_VARIANT.new(2,VT_R8)
#<WIN32OLE_VARIANT:0x11aed90>
(rdb:1) a3 = WIN32OLE_VARIANT.new(3,VT_R8)
#<WIN32OLE_VARIANT:0x1a8b540>
(rdb:1) pt = app.ole.Point3dFromXYZ(a1,a2,a3)
nil
(rdb:1) pt
nil

No luck again. Thanks again for all your help

Dominic S.

Hello,

On Wed, Nov 23, 2011 at 03:08:10PM +0900, Dominic S. wrote:

(rdb:1) pt
nil

No luck again. Thanks again for all your help

Hmmm…
Sorry, but I have no idea what to do.
Maybe you must call other methods before you call Point3dFromXYZ.
Or can you call Point3dFromXYZ from VBScript(not VB)?
If so, it helps to solve this issue.

Best Regards,
Masaki S.

2011/11/23 Masaki S. [email protected]

#<WIN32OLE_VARIANT:0x1a8b540>
Or can you call Point3dFromXYZ from VBScript(not VB)?
If so, it helps to solve this issue.

Best Regards,
Masaki S.

I will try other things and if I get it to work I will update this post.
Thanks for all your attention and help

Dominic S.

Hello,

On Tue, Nov 22, 2011 at 05:15:14PM +0900, Dominic S. wrote:

or

pt = ole.Point3dFromXYZ(3.to_f,3.to_f,2.to_f)

(rdb:1) pt = app.ole.Point3dFromXYZ(1.0,2.0,3.0)
nil
(rdb:1) pt
nil

Try to use WIN32OLE_VARIANT

include WIN32OLE::VARIANT
a1 = WIN32OLE_VARIANT.new(1, VT_R8)
a2 = WIN32OLE_VARIANT.new(2, VT_R8)
a3 = WIN32OLE_VARIANT.new(3, VT_R8)
pt = app.ole.Point3dFromXYZ(a1, a2, a3)

Best Regards,
Masaki S.

-----Messaggio originale-----
Da: Dominic S. [mailto:[email protected]]
Inviato: mercoled 23 novembre 2011 07:08
A: ruby-talk ML
Oggetto: Re: WIN32OLE return type USERDEFINED

(rdb:1) include WIN32OLE::VARIANT
Object
(rdb:1) a1 = WIN32OLE_VARIANT.new(1,VT_R8) #<WIN32OLE_VARIANT:0x1780818>
(rdb:1) a2 = WIN32OLE_VARIANT.new(2,VT_R8) #<WIN32OLE_VARIANT:0x11aed90>
(rdb:1) a3 = WIN32OLE_VARIANT.new(3,VT_R8) #<WIN32OLE_VARIANT:0x1a8b540>
(rdb:1) pt = app.ole.Point3dFromXYZ(a1,a2,a3) nil
(rdb:1) pt
nil

No luck again. Thanks again for all your help

Dominic S.


Caselle da 1GB, trasmetti allegati fino a 3GB e in piu’ IMAP, POP3 e
SMTP autenticato? GRATIS solo con Email.it http://www.email.it/f

Sponsor:
Conto Arancio al 4,20%. Soldi sempre disponibili, zero spese, aprilo in
due minuti!
Clicca qui: http://adv.email.it/cgi-bin/foclick.cgi?mid920&d)-12

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs