Pascal wrote on 3/5/2015 2:22 PM:Hello, I'm not much of an expert either, but I also use an API with many ByRef parameters in its method calls. The way I solved the problem was to use "early binding" of the COM objects. To do that, you must first find the Type Library for your API. For SolidWorks, this may be "sldworks.tlb", although I can't really be sure. I see 20 "tlb" files in my [SolidWorks_path]\SolidWorks folder, and I have no idea which one you might need, or even if you need all of them. I would start with "sldworks.tlb". Next, from that type library, you create a Python file that you can import into your code. You do that with the "makepy" utility that comes with the Python COM package. 1. Open a command window in the folder where you keep the Python code you're developing. 2. Enter the command [Python_path]\Lib\site-packages\win32com\client\makepy.py -v -o PySldworks.py [SolidWorks_path]\SolidWorks\sldworks.tlb This will create a file called PySldworks.py (you can name it whatever you want, of course). Now you can just add "Import PySldworks" to all the Import statements you already use. Instead of app = win32com.client.Dispatch('Sldworks.Application') you have something like app = PySldworks.SldWorks Now those calls that return data using ByRef parameters should work with the Python-like form you tried because PySldworks.py has already defined it: var1, var2, var3 = custPropMgr.Get5(item, False) If that method has a return code, it will appear before the ByRef parameters: rc, var1, var2, var3 = custPropMgr.Get5(item, False) If that doesn't work, you can look in PySldworks.py to understand exactly what it thinks it should do with that method; it is, after all, just another Python file. If there is another way to solve this problem, I don't know what it is. One of the real experts who monitor this list will have to help you with that. - Greg Antal ------------------
Gregory W. Antal Senior Technical Advisor ATA Engineering, Inc. 13290 Evening Creek Drive South, Suite 250 San Diego, CA 92128 www.ata-e.com greg.an...@ata-e.com 858-480-2072 (Phone) 858-792-8932 (Fax) ------------------ |
_______________________________________________ python-win32 mailing list python-win32@python.org https://mail.python.org/mailman/listinfo/python-win32