how to pass an array to a VB array via COM

J

jelle

Hi,

I'm trying to script Rhino -the nurbs modeller, not the server soft-
via COM.
Which is good fun, except i cant seem to pass arrays to the program.
I suppose its expecting VB arrays, and is not to keen when i send a
tuple:

RS.AddCurve(((1,2,3),(4,5,6),(7,8,9)),3)
---
Traceback (most recent call last):
File "<input> ", line 1, in ?
File "c:\Python23\lib\site-packages\jf\interface\RhinoScript.py",
line 48,
in AddCurve
return self._ApplyTypes_(77, 1, (12, 0), ((12, 0), (12, 16)),
'AddCurve', None,vaPoints, vaDegree)
File "c:\Python23\lib\site-packages\win32com\client\__init__.py",
line
446, in _ApplyTypes_
return self._get_good_object_(
com_error: (-2147352567, 'Exception occurred.', (6, 'RhinoScript_m',
'Type
mismatch in parameter. One-dimensional array required.', 'C:\\Program
Files\\Rhinoceros 3.0\\RhinoScript_m.HLP', 393222, 0), None)
---

This is somewhat puzzling, since when i define points in the
application, these are returned as a tuple of tuples:

((-7.0, -30.0, 0.0), (15.0, -24.0, 0.0), (-7.0, 12.0, 0.0), (14.0,
29.0,
0.0), (28.0, 10.0, 0.0), (20.0, 1.0, 0.0))

I've been searching this list for a solution, but didnt find anything i
could use. Any ideas?

Cheers,

Jelle
 
S

Steve Holden

jelle said:
Hi,

I'm trying to script Rhino -the nurbs modeller, not the server soft-
via COM.
Which is good fun, except i cant seem to pass arrays to the program.
I suppose its expecting VB arrays, and is not to keen when i send a
tuple:

RS.AddCurve(((1,2,3),(4,5,6),(7,8,9)),3)
---
Traceback (most recent call last):
File "<input> ", line 1, in ?
File "c:\Python23\lib\site-packages\jf\interface\RhinoScript.py",
line 48,
in AddCurve
return self._ApplyTypes_(77, 1, (12, 0), ((12, 0), (12, 16)),
'AddCurve', None,vaPoints, vaDegree)
File "c:\Python23\lib\site-packages\win32com\client\__init__.py",
line
446, in _ApplyTypes_
return self._get_good_object_(
com_error: (-2147352567, 'Exception occurred.', (6, 'RhinoScript_m',
'Type
mismatch in parameter. One-dimensional array required.', 'C:\\Program
Files\\Rhinoceros 3.0\\RhinoScript_m.HLP', 393222, 0), None)
---

This is somewhat puzzling, since when i define points in the
application, these are returned as a tuple of tuples:




((-7.0, -30.0, 0.0), (15.0, -24.0, 0.0), (-7.0, 12.0, 0.0), (14.0,
29.0,
0.0), (28.0, 10.0, 0.0), (20.0, 1.0, 0.0))

I've been searching this list for a solution, but didnt find anything i
could use. Any ideas?
Have you tried wrapping them? One of the win32all modules lets you wrap
a Python object so it can be accessed by COM interfaces. Not sure
whether this will help, but it's a possibility.

regards
Steve
 
J

jelle

No I haven't, it might be an idea.
Would it be an effective method though?
I have little experience working with COM, but i suppose writing an
(VB!) array wouldnt be the most challenging problem, though browsing
through this list it looks like no good solution arrived yet.

Cheers,

Jelle
 
T

Thomas Heller

jelle said:
Hi,

I'm trying to script Rhino -the nurbs modeller, not the server soft-
via COM.
Which is good fun, except i cant seem to pass arrays to the program.
I suppose its expecting VB arrays, and is not to keen when i send a
tuple:

RS.AddCurve(((1,2,3),(4,5,6),(7,8,9)),3)

To me it looks like you should try this instead, although this is pure
speculation:

RS.AddCurve(((1,2,3),(4,5,6),(7,8,9)))

Thomas
 
J

jelle

Thomas,

No, i went over the syntax extensively. The syntax is
RS.AddCurve(points, degree), so 3 represents the degree of a bezier
curve. I'm doing fine with all types of functions which use 2 x,y,z
coords, but all arrays -tuple of tuples- fail. The odd thing is that
when i use RS.GetPoints() which is a method to get back user-defines
x,y,z points, i get a tuple of tuples containing these points. Though
when i write these back to the program, all fails:

I admit posting this problem also to the more specific python-win32
group, though no response there yet...
((-7.0, -30.0, 0.0), (15.0, -24.0, 0.0), (-7.0, 12.0, 0.0), (14.0,
29.0,
0.0), (28.0, 10.0, 0.0), (20.0, 1.0, 0.0))

Cool, I get to choose points in the GUI, right back into python,
wicked!
Though when I send these points back to the app:
RS.AddPolyline(s)
The same error all over again:
---
Traceback (most recent call last):
File "<input> ", line 1, in ?
File "c:\Python23\lib\site-packages\jf\interface\RhinoScript.py",
line
129, in AddPolyline
return self._ApplyTypes_(85, 1, (12, 0), ((12, 0),), 'AddPolyline',
None,vaPoints)
File "c:\Python23\lib\site-packages\win32com\client\__init__.py",
line
446, in _ApplyTypes_
return self._get_good_object_(
com_error: (-2147352567, 'Exception occurred.', (6, 'RhinoScript_m',
'Type
mismatch in parameter. One-dimensional array required.', 'C:\\Program
Files\\Rhinoceros 3.0\\RhinoScript_m.HLP', 393222, 0), None)
---
 

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

No members online now.

Forum statistics

Threads
473,743
Messages
2,569,478
Members
44,899
Latest member
RodneyMcAu

Latest Threads

Top