win32ole: Passing an Array to Autocad

  • Thread starter Michael Mueller
  • Start date
M

Michael Mueller

Hi!

I am (again - tried the same thing 2 years ago) trying to use ruby for
automating Autocad.
Win32ole is a great tool and basically allows me to program Autocad to
the same extent as when using Visual Basic....

Unfortunately there's one thing that absolutely doesn't work:
I can't call any methods that take an array as an argument - as you can
imagine that applies to almost every method that creates
Autocad-Objetcs...
say I wanted to insert a Text-Object like that:
@model.AddText("test",[0.0,0.0,0.0],10)
This doesn't work, all I get is a WIN32OLERuntimeError...

Methods that take Strings and Integers as Arguments work like a charm.

I really would appreciate any idea on how to solve this problem.

Michael
 
M

Masaki Suketa

In message "win32ole: Passing an Array to Autocad"
Unfortunately there's one thing that absolutely doesn't work:
I can't call any methods that take an array as an argument - as you can
imagine that applies to almost every method that creates
Autocad-Objetcs...
say I wanted to insert a Text-Object like that:
@model.AddText("test",[0.0,0.0,0.0],10)
This doesn't work, all I get is a WIN32OLERuntimeError...

Could you show me the result of the following script?

m = @model.ole_method_help('AddText')
puts m.name
puts " dispid:"
puts " #{m.dispid}"
puts " args:"
m.params.each do |p|
puts " #{p.ole_type} #{p.name}"
end

Regards,
Masaki Suketa
 
M

Michael Mueller

Could you show me the result of the following script?

m = @model.ole_method_help('AddText')
puts m.name
puts " dispid:"
puts " #{m.dispid}"
puts " args:"
m.params.each do |p|
puts " #{p.ole_type} #{p.name}"
end

Sure, the output is:
----------------
AddText
dispid:
1572
args:
BSTR TextString
VARIANT InsertionPoint
R8 Height
 
M

Masaki Suketa

Sorry for being too late to reply.
In message "Re: win32ole: Passing an Array to Autocad"
Sure, the output is:
----------------
AddText
dispid:
1572
args:
BSTR TextString
VARIANT InsertionPoint
R8 Height
----------------

Could you try _invoke method?

@model._invoke(1572, ["test", [0.0,0.0,0.0], 10],
[WIN32OLE::VARIANT::VT_BSTR,
WIN32OLE::VARIANT::VT_ARRAY,
WIN32OLE::VARIANT::VT_R8])
or
@model._invoke(1572, ["test", [0.0,0.0,0.0], 10],
[WIN32OLE::VARIANT::VT_BSTR,
WIN32OLE::VARIANT::VT_VARIANT,
WIN32OLE::VARIANT::VT_R8])

Regards,
Masaki Suketa
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,777
Messages
2,569,604
Members
45,212
Latest member
BrennaCaba

Latest Threads

Top