Passing array of doubles to COM object?

Martin Keefe martink at
Tue Apr 4 13:55:00 CEST 2000

I am trying to use an Automation server that has the following method (among 

  VARIANT_BOOL LoadFeature(
                            BSTR code, 
                            BSTR label, 
                            long size, 
                            VARIANT xArray, 
                            VARIANT yArray);

Its documentation assumes that the client will be written in VB and says that 
xArray and yArray are arrays of Doubles. And true enough, passing arrays of 
Doubles from VB works fine.

In Python, after creating the object with:

 mx = win32com.client.Dispatch("Maplex.Application")

I've tried the following:

 xa = [100000.0, 600000.0, 600000.0, 100000.0]
 ya = [100000.0, 100000.0, 900000.0, 900000.0]
 mx.LoadFeature( 'AREA', 'Simple', 4, xa, ya )


 xa = buffer( array('d',[100000.0, 600000.0, 600000.0, 100000.0]) )
 ya = buffer( array('d',[100000.0, 100000.0, 900000.0, 900000.0]) )
 mx.LoadFeature( 'AREA', 'Simple', 4, xa, ya )

without success. Both ran without errors or exceptions but the data didn't 
appear to get to the server intact. I've tried both dynamic and static dispatch 
with the same results. Can anybody shed some light on this please?

The system is NT4 Server SP3, Python 1.5.2, win32all-128. Thanks,

  ]\/[artin Keefe ][ Dorking,Surrey,UK ][ martink at

More information about the Python-list mailing list