After using win32com for years, I stumbled across comtypes earlier tonight. My tests indicate that comtypes is significantly faster than win32com for reading/writing large arrays of data between Python and the COM object. So far, all of the methods on the COM object work nicely with comtypes except for one called WriteTagV. The signature of this method is: long WriteTagV(LPCTSTR Name, long nOS, Variant &buffer);
When I attempt to execute the following code: from comtypes import client from numpy import array interface = client.CreateObject('RPco.X') data = array([1, 2, 3, 4, 5], dtype='f4') interface.WriteTagV('data', 0, data) I get the following error: TypeError: Cannot put array([ 1., 2., 3., 4., 5.], dtype=float32) in VARIANT Traceback is below my signature. However, when I try the following from array import array data = array('d', [1, 2, 3, 4, 5]) interface.WriteTagV('data', 0, data) It works just fine! Is there something I need to do to get this working with Numpy ndarray objects? This method worked just fine with win32com and Numpy arrays. Thanks! Brad Full traceback for the Numpy array case: c:\experiments\programs\python_lib\tdt\<ipython console> in <module>() C:\Python26\lib\site-packages\comtypes\__init__.pyc in func(obj, *args, **kw) 515 else: 516 def func(obj, *args, **kw): --> 517 return self.Invoke(obj, memid, _invkind=1, *args, **kw) # DISPATCH_METHOD 518 return func 519 C:\Python26\lib\site-packages\comtypes\automation.pyc in Invoke(self, dispid, *a rgs, **kw) 699 700 for i, a in enumerate(args[::-1]): --> 701 array[i].value = a 702 703 dp = DISPPARAMS() C:\Python26\lib\site-packages\comtypes\automation.pyc in _set_value(self, value) 298 self._.VT_R4 = value 299 else: --> 300 raise TypeError("Cannot put %r in VARIANT" % value) 301 # buffer -> SAFEARRAY of VT_UI1 ? 302 ------------------------------------------------------------------------------ Special Offer-- Download ArcSight Logger for FREE (a $49 USD value)! Finally, a world-class log management solution at an even better price-free! Download using promo code Free_Logger_4_Dev2Dev. Offer expires February 28th, so secure your free ArcSight Logger TODAY! http://p.sf.net/sfu/arcsight-sfd2d _______________________________________________ comtypes-users mailing list comtypes-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/comtypes-users