我正在尝试将一些旧的VBA代码移植到Python。在
在VBA中,我添加Geo3D.dll
作为项目引用,然后使用以下内容:
Set P1 = New GEO3DLib.Point
P1.Set 1, 2, 3, 0.001
在Python中,我尝试了以下方法:
^{pr2}$但我得到一个错误:
Traceback (most recent call last):
File "<pyshell#3>", line 1, in <module>
pt = cc.CreateObject('Geo3d.Point', None, None, Geo3d.Point)
File "C:\Anaconda3\lib\site-packages\comtypes\client\__init__.py", line 238, in CreateObject
obj = comtypes.CoCreateInstance(clsid, clsctx=clsctx, interface=interface)
File "C:\Anaconda3\lib\site-packages\comtypes\__init__.py", line 1217, in CoCreateInstance
iid = interface._iid_
AttributeError: type object 'Point' has no attribute '_iid_'
将最后一行替换为:
pt = Geo3d.Point
pt.Set(1., 2., 3., 0.001)
我得到这个错误:
Traceback (most recent call last):
File "<pyshell#5>", line 1, in <module>
pt.Set(1., 2., 3., 0.001)
AttributeError: type object 'Point' has no attribute 'Set'
有什么想法吗?在
确保python实现和thinkdesign库是针对同一平台类型编译的:64位或32位。在
我测试如下:
或使用comtypes:
^{pr2}$相关问题 更多 >
编程相关推荐