> -----Original Message----- > From: [EMAIL PROTECTED] > [mailto:[EMAIL PROTECTED] Behalf Of > jelle > Sent: Tuesday, April 26, 2005 12:31 PM > To: python-list@python.org > Subject: how to pass an array to a VB array via COM > > > 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: > > > >>>s = RS.GetPoints() > >>>print s > ((-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 > > -- > http://mail.python.org/mailman/listinfo/python-list >
The problem you see here is the automatic calculation of the dimension for SafeArrays in Pythoncom. The array shown above could be transported either as a 2-dim Array (3x3) or as a 1-dim array (1x3) with elements which are also 1-dim arrays. Since the automatic calculation always tries to find the highest dimensionality the Rhino program will get a 2-Dim array which it does not support. In VB you can define the dimension of such a array in Python we must guess. I'm just working on a PySafeArray implementation for PythonCom which should give you also the opportunity to define the dimension via Python. Until then you have no luck. Stefan -- http://mail.python.org/mailman/listinfo/python-list