arrayOfVariantOfBSTR in Python
OLD project page for the Python extensions for Windows
Brought to you by:
mhammond
Hi,
I have problem with an application which I try to automate with win32com. My problem is now, that a GetListOfDependantFile expects a arrayOfVariantOfBSTR byreference. I think this must be a list of strings. The VB Code is this:
Set Send1 = CATIA.CreateSendTo()
Call Send.SetInitialFile(myfile)
ReDim arrayOfVariantOfBSTR(500)
Call Send1.GetListOfDependantFile(arrayOfVariantOfBSTR)
How can I write this in Python for win32com ?
best regards
Mustafa Görmezer
Logged In: YES
user_id=14198
Originator: NO
If you run makepy, you should be able to pass no params - the strings will be returned. Please show the code you use and the exception you see.
Logged In: YES
user_id=1525528
Originator: YES
Hi marc,
this is my code:
import win32com.client
app=win32com.client.Dispatch('Catia.Application')
sendto=app.CreateSendTo()
sendto.SetInitialFile('c:\\...igteil.CATPart')
refs=sendto.GetListOfDependantFile()
print refs
When I use no params I get a type error or type conflict (with makepy):
Traceback (most recent call last):
File "C:\Python25\Lib\site-packages\pythonwin\pywin\framework\scriptutils.py", line 310, in RunScript
exec codeObject in __main__.__dict__
File "C:\Dokumente und Einstellungen\mgo\Desktop\px1.py", line 9, in <module>
refs=sendto.GetListOfDependantFile()
File "C:\DOKUME~1\mgo\LOKALE~1\Temp\gen_py\2.5\14F197B2-0771-11D1-A5B1-00A0C9575177x0x0x0\SendToService.py", line 49, in GetListOfDependantFile
return self._ApplyTypes_(1610940417, 1, (24, 0), ((8204, 3),), 'GetListOfDependantFile', None,oDependant
File "C:\Python25\Lib\site-packages\win32com\client\__init__.py", line 448, in _ApplyTypes_
dispid, 0, wFlags, retType, argTypes, *args),
com_error: (-2147352571, 'Typkonflikt.', None, 1)
When I give a list as the param, the function returns the param as a tuple:
GetListOfDependantFile([])
returns ()
GetListOfDependantFile(['hello'])
returns (u'hello',)
Here is the traceback without makepy:
Traceback (most recent call last):
File "C:\Dokumente und Einstellungen\mgo\Desktop\px1.py", line 6, in <module>
refs=sendto.GetListOfDependantFile()
File "<COMObject CreateSendTo>", line 2, in GetListOfDependantFile
File "C:\Python25\Lib\site-packages\win32com\client\dynamic.py", line 258, in
_ApplyTypes_
result = self._oleobj_.InvokeTypes(*(dispid, LCID, wFlags, retType, argTypes
) + args)
pywintypes.com_error: (-2147352567, 'Ausnahmefehler aufgetreten.', (0, 'CATIASen
dToService', 'Das Verfahren GetListOfDependantFile ist fehlgeschlagen', None, 0,
-2147024809), None)
Logged In: YES
user_id=14198
Originator: NO
Just noting this is also being discussed in http://www.mail-archive.com/comtypes-users@lists.sourceforge.net/msg00144.html
It isn't clear this is still a problem - and the new builtin VARIANT support should make things easier.