我想编写一个能够从 AutoDesk Inventor 模型中读取结构的脚本。Inventor 已安装并运行,并通过 win32.com 建立了与它的连接。加载模型并设置一些变量后,我被卡住了。
我有这个列表 oStructuredBOMView.BOMRows
>> print(len(oStructuredBOMView.BOMRows))
2
我可以参考一项
>> print(oStructuredBOMView.BOMRows.Item(1))
<win32com.gen_py.Autodesk Inventor Object Library.BOMRow instance at 0x88831536>
使用目录,我可以显示所有功能/方法
>> print(dir(oStructuredBOMView.BOMRows.Item(1)))
['CLSID', 'GetReferenceKey', '_ApplyTypes_', '__class__', '__delattr__', '__dict__', '__dir__', '__doc__', '__eq__', '__format__', '__ge__', '__getattr__', '__getattribute__', '__gt__', '__hash__', '__init__', '__iter__', '__le__', '__lt__', '__module__', '__ne__', '__new__', '__reduce__', '__reduce_ex__', '__repr__', '__setattr__', '__sizeof__', '__str__', '__subclasshook__', '__weakref__', '_get_good_object_', '_get_good_single_object_', '_oleobj_', '_prop_map_get_', '_prop_map_put_', 'coclass_clsid']
这是我不能超过的一点。如何使用此功能/方法来提取更多信息?例子:
>> oStructuredBOMView.BOMRows.Item(1).sizeof
Traceback (most recent call last):
File "<pyshell#22>", line 1, in <module>
oStructuredBOMView.BOMRows.Item(1).sizeof
File "C:\python\Python35\lib\site-packages\win32com\client\__init__.py", line 473, in __getattr__
raise AttributeError("'%s' object has no attribute '%s'" % (repr(self), attr))
AttributeError: '<win32com.gen_py.Autodesk Inventor Object Library.BOMRow instance at 0x88417896>' object has no attribute 'sizeof'
>> sizeof(oStructuredBOMView.BOMRows.Item(1))
Traceback (most recent call last):
File "<pyshell#23>", line 1, in <module>
sizeof(oStructuredBOMView.BOMRows.Item(1))
NameError: name 'sizeof' is not defined