Hi Thomas, that wasn`t it. Your example returns me a list of 500 Nones. It`s right, the method expects a list or a tuple. But it does not matter what is in the list. It returns me everything.
Hint: The number 500 was to initialize the BSTR array with a size of 500. Do I need it in Python ?! The problem is the same with win32com, here: https://sourceforge.net/tracker/?func=detail&atid=551954&aid=1920299&group_id=78018 Any other ideas ? best regards Mustafa Görmezer Thomas Heller schrieb: > Mustafa Görmezer schrieb: >> Hello, >> >> I am automating a CAD System which expects a so called >> CATSafeArrayVariant. This is defined as one-dimensional arrays of >> CATVariants. When I am right, this should work now with comtypes. But >> how do I use it when a method expects it by reference ? >> >> In pure Python (where no "by reference" exists) I would simply use this >> to get a list of file names: >> >> myrefs = Send.GetListOfDependantFiles() >> >> In VB (which works) it looks like: >> >> Dim arrayOfVariantOfBSTR() >> ReDim arrayOfVariantOfBSTR(500) >> Call Send.GetListOfDependantFiles(arrayOfVariantOfBSTR) >> >> After this I can find the results in the arrayOfVariantOfBSTR, which can >> be used in a for each loop. > > I looked into the generated file that you sent me offline. The > GetListOfDependantFiles() > method uses an [in, out] parameter, apparently a SAFEARRAY of BSTR (an array > of strings). > > You must call the method with a list (or tuple) containing strings, comtypes > will > pack these automatically into a safearray, the com object will insert its > results > into the safearray, and comtypes will unpack it again and return a them as a > sequence. > > So I assume that something like this *should* work: > > result = send.GetListOfDependantFiles([None] * 500) > for item in result: > print item > > Thomas > > > ------------------------------------------------------------------------- > This SF.net email is sponsored by the 2008 JavaOne(SM) Conference > Don't miss this year's exciting event. There's still time to save $100. > Use priority code J8TL2D2. > http://ad.doubleclick.net/clk;198757673;13503038;p?http://java.sun.com/javaone > _______________________________________________ > comtypes-users mailing list > comtypes-users@lists.sourceforge.net > https://lists.sourceforge.net/lists/listinfo/comtypes-users ------------------------------------------------------------------------- This SF.net email is sponsored by the 2008 JavaOne(SM) Conference Don't miss this year's exciting event. There's still time to save $100. Use priority code J8TL2D2. http://ad.doubleclick.net/clk;198757673;13503038;p?http://java.sun.com/javaone _______________________________________________ comtypes-users mailing list comtypes-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/comtypes-users