[pywin32-bugs] [ pywin32-Bugs-3603059 ] Cannot pass array of arrays
OLD project page for the Python extensions for Windows
Brought to you by:
mhammond
From: SourceForge.net <no...@so...> - 2013-02-03 21:37:38
|
Bugs item #3603059, was opened at 2013-02-01 19:19 Message generated for change (Comment added) made by mhammond You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=551954&aid=3603059&group_id=78018 Please note that this message will contain a full copy of the comment thread, including the initial issue submission, for this request, not just the latest update. Category: None Group: None Status: Open Resolution: None Priority: 5 Private: No Submitted By: Wesley Tanaka (wtanaka) Assigned to: Nobody/Anonymous (nobody) Summary: Cannot pass array of arrays Initial Comment: With code that looks like this: instance = win32com.client.gencache.EnsureDispatch("InDesign.Application") doc = instance.Open("some_path") pages = doc.Pages page0 = pages.FirstItem() opposing_corners=((0.0, 0.0), (72.0, 72.0)) page0.Reframe( In=2021222766, OpposingCorners=opposing_corners) The reframe method: http://cssdk.host.adobe.com/sdk/1.0/docs/WebHelp/references/csawlib/com/adobe/indesign/Page.html#reframe%28%29 expects an array containing two arrays, where each of those two arrays contains two doubles. If I pass in a scalar like 5.0 or a 1-D array like (1.0, 1.0) or even if I add an extra item to the array like ((0.0, 0.0), (72.0, 72.0), 5.0) or ((0.0, 0.0), (72.0, 72.0), None), the exception coming back from InDesign references the value that I passed to the Reframe method. However, if I pass ((0.0, 0.0), (72.0, 72.0)), then InDesign says that it is receiving "()" This thread looks similar: http://stackoverflow.com/questions/10166064/python-win32com-and-2-dimensional-arrays/10167882#10167882 and the solution there is to use comtypes instead of win32com. Is this a known issue with win32com? I tried looking at the underlying InvokeTypes call but stopped when I saw this mailing list post saying that it's poorly documented: http://mail.python.org/pipermail/python-win32/2005-December/004031.html ---------------------------------------------------------------------- >Comment By: Mark Hammond (mhammond) Date: 2013-02-03 13:37 Message: Multi-dimension arrays are covered by the tests and work fine with other objects. It might be that the COM object isn't given appropriate type information for the method, meaning python might be passing arrays of, eg, doubles or variants, where the object expects just floats. You could try something like: from win32com.client import VARIANT import pythoncom arg = VARIANT(pythoncom.VT_ARRAY | pythoncom.VT_DOUBLE, [(1.0, 1.0), (10.0, 10.0)) and pass 'arg' as the array argument - this will force the type of the param to double. Unfortunately the docs don't indicate what specific type is needed. ---------------------------------------------------------------------- You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=551954&aid=3603059&group_id=78018 |