Python - 使用方法和函数

我想编写一个能够从 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


幕布斯7119047
浏览 191回答 2
2回答
打开App,查看更多内容
随时随地看视频慕课网APP

相关分类

Python