
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hi all,
I am trying to get the list of parameters and mass properties from a .ipt, but it´s not working. Retrieving description and designer from the iproperties is in contrast no problem.
I´m a mechanical engineer and I´m using Python because it´s the only programming language I know.
This is my code:
import win32com.client
from win32com.client import gencache
oApp = win32com.client.Dispatch('Inventor.Application')
oApp.Visible = True
mod = gencache.EnsureModule('{D98A091D-3A0F-4C3E-B36E-61F62068D488}', 0, 1, 0)
oApp = mod.Application(oApp)
oApp.SilentOperation = True
oDoc = oApp.ActiveDocument
prop = oApp.ActiveDocument.PropertySets.Item("Design Tracking Properties")
# getting description and designer from iproperties (works)
Descrip = prop('Description').Value
Designer = prop('Designer').Value
print(Descrip)
print(Designer)
# getting mass and parameters (doesn´t work)
MassProps = oDoc.ComponentDefinition.MassProperties
partDef = oDoc.ComponentDefinition.Parameters
and this is the error message I get:
File "M:/Python/Idas_Arbeit/inventor_7.py", line 21, in <module>
oMassProps = oDoc.ComponentDefinitions.MassProperties
File "M:\zzz_Anaconda\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.Document instance at 0x2937542647032>' object has no attribute 'ComponentDefinitions'
I use Inventor 2018 and Python 3.6.2. on Windows 10.
Any ideas? Your help would be very much appreciated!
Solved! Go to Solution.