几年前,我用Python编写了脚本,以自动化我在SolidWorks_2012中所做的几个乏味的过程。我在Win7 32位和python2732位以及SolidWorks_2012 32位上运行了这个脚本。
现在,我面临着完全相同的问题,我尝试使用旧脚本,但在OpenDoc6 (以及其他函数,其中值通过ref传递)上,它会引发异常:
"Objects of type 'PyOleMissing' can not be converted to a COM VARIANT"以下是一些我无法制作的样本:
import win32com.client as win32
import pythoncom
sw = win32.Dispatch('SldWorks.Application')
path_to_file = "some_path"
sw_asm = sw.OpenDoc6(path_to_file, 2, 1, "", pythoncom.Missing, pythoncom.Missing)以下是用于VBA的docs中有关此函数的一些规范:
Function OpenDoc6( _
ByVal FileName As System.String, _
ByVal Type As System.Integer, _
ByVal Options As System.Integer, _
ByVal Configuration As System.String, _
ByRef Errors As System.Integer, _
ByRef Warnings As System.Integer _
) As ModelDoc2正如您所看到的,最近的两个正在传递引用。
而且,here也是同样的问题,没有任何解决方案。万一这很重要,我现在运行的是win 8 64,python 27 32/64和SolidWorks 2014 64。
预先谢谢你!
发布于 2015-02-19 15:02:35
只需插入空变量即可。如果在VBA中出现相同的错误,您必须传递声明为LONG的变量,否则它将无法工作。
https://stackoverflow.com/questions/28330460
复制相似问题