[英]Exception occured during using python 64bit win32com (Solidworks-API): Exception SldWorks.Application.InvokeTypes
I have on my Windows Server 2003, Standard x64 Edition a 64 bit Python 2.7 (python-2.7.3.amd64.msi) and a 64 bit win32-Extension (pywin32-218.win-amd64-py2.7.exe). 我在Windows Server 2003 Standard x64 Edition上具有64位Python 2.7(python-2.7.3.amd64.msi)和64位win32-Extension(pywin32-218.win-amd64-py2.7.exe)。 My Application is SolidWorks 2012 x64 Edition.
我的应用程序是SolidWorks 2012 x64版。 Then I generate with
然后我生成
C:\Python27\Lib\site-packages\win32com\client\makepy.py "D:\Program Files\SolidWorks Corp\SolidWorks\sldworks.tlb" the file 83A33D31-27C5-11CE-BFD4-00400513BB57x0x20x0.py
and with 与
C:\Python27\Lib\site-packages\win32com\client\makepy.py "D:\Program Files\SolidWorks Corp\SolidWorks\swconst.tlb" the file 4687F359-55D0-4CD3-B6CF-2EB42C11F989x0x20x0.py
My following code works fine on 32 bit Windowes XP with 32bit Python 2.4 and 32 bit win32-Extension. 我的以下代码在具有32位Python 2.4和32位win32-Extension的32位Windowes XP上可以正常工作。 But on my 64 bit server I get an exception "SldWorks.Application.InvokeTypes" by call ExitApp()-method.
但是在我的64位服务器上,我通过调用ExitApp()方法得到了“ SldWorks.Application.InvokeTypes”异常。 What is the reason and how can I resolve this problem?
原因是什么,我该如何解决? Thanks for your hints, Thomas
谢谢你的提示,托马斯
try:
pythoncom.CoInitializeEx(pythoncom.COINIT_APARTMENTTHREADED)
sldworks = gencache.EnsureModule('{83A33D31-27C5-11CE-BFD4-00400513BB57}', 0x0, 20, 0)
print "sldworks = " + str(sldworks)
swconst = gencache.EnsureModule('{4687F359-55D0-4CD3-B6CF-2EB42C11F989}', 0x0, 20, 0)
print "swconst = " + str(swconst)
sw = sldworks.ISldWorks(DispatchEx('SldWorks.Application'))
print "sw = " + str(sw)
sw.ExitApp()
except Exception, value:
print "Exception occured, value = ", value
here the prints: 这里的照片:
sldworks = module 'win32com.gen_py.83A33D31-27C5-11CE-BFD4-00400513BB57x0x20x0' from 'C:\Python27\lib\site-packages\win32com\gen_py\83A33D31-27C5-11CE-BFD4-00400513BB57x0x20x0.pyc'
swconst = module 'win32com.gen_py.4687F359-55D0-4CD3-B6CF-2EB42C11F989x0x20x0' from 'C:\Python27\lib\site-packages\win32com\gen_py\4687F359-55D0-4CD3-B6CF-2EB42C11F989x0x20x0.pyc'
sw = win32com.gen_py.SldWorks 2012 Type Library.ISldWorks instance at 0x82548360
Exception occured, value = SldWorks.Application.InvokeTypes
With 用
sw = win32com.client.Dispatch("SldWorks.Application")
instead 代替
sw = sldworks.ISldWorks(DispatchEx('SldWorks.Application'))
and with Python 2.4 32bit and win32 extension 32bit it works fines. 并且使用Python 2.4 32bit和win32扩展32bit可以正常工作。
Thomas 汤玛士
Diesen Beitrag melden Beitrag löschen 迪森·贝特拉格(Diesen Beitrag)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.