[pywin32-bugs] [ pywin32-Bugs-3591103 ] Dynamic dispatch and passing arguments by reference
OLD project page for the Python extensions for Windows
Brought to you by:
mhammond
From: SourceForge.net <no...@so...> - 2012-11-29 17:22:58
|
Bugs item #3591103, was opened at 2012-11-29 09:22 Message generated for change (Tracker Item Submitted) made by n-perestoronin You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=551954&aid=3591103&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: com Group: None Status: Open Resolution: None Priority: 5 Private: No Submitted By: Nikita Perestoronin (n-perestoronin) Assigned to: Nobody/Anonymous (nobody) Summary: Dynamic dispatch and passing arguments by reference Initial Comment: I have the following problem when calling methods that accept arguments passed by reference. Consider the following code: import win32com.client import pythoncom sldworks = win32com.client.gencache.EnsureModule('{83A33D31-27C5-11CE-BFD4-00400513BB57}', 0, 21, 0) swconst = win32com.client.gencache.EnsureModule('{4687F359-55D0-4CD3-B6CF-2EB42C11F989}', 0, 21, 0) sw = sldworks.SldWorks() model_path = 'C:\Demo\model.SLDPRT' model, errors, warnings = sw.OpenDoc6(model_path, swconst.constants.swDocPART, swconst.constants.swOpenDocOptions_Silent, '', pythoncom.Missing, pythoncom.Missing) ext = model.Extension In case of static dispatch it works correctly: >>> ext >>> <win32com.gen_py.SldWorks 2013 Type Library.IModelDocExtension instance at 0x206388400> >>> ext.GetAdvancedSpotLightProperties('Ambient') >>> (0.0, 1.0, 0.0, 0.0) In case of dynamic dispatch it sets wrong value for the last argument: dext = win32com.client.dynamic.DumbDispatch(ext) arg1 = win32com.client.VARIANT(pythoncom.VT_BYREF | pythoncom.VT_R8, 0.0) arg2 = win32com.client.VARIANT(pythoncom.VT_BYREF | pythoncom.VT_R8, 0.0) arg3 = win32com.client.VARIANT(pythoncom.VT_BYREF | pythoncom.VT_R8, 0.0) arg4 = win32com.client.VARIANT(pythoncom.VT_BYREF | pythoncom.VT_R8, 0.0) >>> dext >>> <COMObject <unknown>> >>> dext.GetAdvancedSpotLightProperties('Ambient', arg1, arg2, arg3, arg4) >>> arg1.value, arg2.value, arg3.value, arg4.value >>> (0.0, 1.0, 0.0, u'Ambient') I've checked more methods in SolidWorks API: in case of dynamic dispatch, when arguments are passed by reference, value of the last argument equals to the value of the first argument after call. Since pywin32 fails to provide static dispatch object in some cases, (for example, if I call model.SelectionManager, it returns <COMObject SelectionManager>), I can't use some methods in SolidWorks API. ---------------------------------------------------------------------- You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=551954&aid=3591103&group_id=78018 |