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.
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.
Solved by chandra.shekar.g. Go to Solution.
Hi,
For the massprop you need to do the following:
# getting mass and parameters (doesn´t work) MassProps = oDoc.ComponentDefinition.MassProperties.mass
Regards,
Arthur Knoors
Autodesk Affiliations:
Autodesk Software:Inventor Professional 2024 | Vault Professional 2022 | Autocad Mechanical 2022
Programming Skills:Vba | Vb.net (Add ins Vault / Inventor, Applications) | I-logic
Programming Examples:Drawing List!|Toggle Drawing Sheet!|Workplane Resize!|Drawing View Locker!|Multi Sheet to Mono Sheet!|Drawing Weld Symbols!|Drawing View Label Align!|Open From Balloon!|Model State Lock!
Posts and Ideas:Dimension Component!|Partlist Export!|Derive I-properties!|Vault Prompts Via API!|Vault Handbook/Manual!|Drawing Toggle Sheets!|Vault Defer Update!
! For administrative reasons, please mark a "Solution as solved" when the issue is solved !
Hi,
For the massprop you need to do the following:
# getting mass and parameters (doesn´t work) MassProps = oDoc.ComponentDefinition.MassProperties.mass
Regards,
Arthur Knoors
Autodesk Affiliations:
Autodesk Software:Inventor Professional 2024 | Vault Professional 2022 | Autocad Mechanical 2022
Programming Skills:Vba | Vb.net (Add ins Vault / Inventor, Applications) | I-logic
Programming Examples:Drawing List!|Toggle Drawing Sheet!|Workplane Resize!|Drawing View Locker!|Multi Sheet to Mono Sheet!|Drawing Weld Symbols!|Drawing View Label Align!|Open From Balloon!|Model State Lock!
Posts and Ideas:Dimension Component!|Partlist Export!|Derive I-properties!|Vault Prompts Via API!|Vault Handbook/Manual!|Drawing Toggle Sheets!|Vault Defer Update!
! For administrative reasons, please mark a "Solution as solved" when the issue is solved !
Hoi need another declaration
Make the declaration to PartComponentDefinition for parts.
Make the declaration to assemblyComponentDefinition for assemblies.
This should do it!
Regards,
Arthur Knoors
Autodesk Affiliations:
Autodesk Software:Inventor Professional 2024 | Vault Professional 2022 | Autocad Mechanical 2022
Programming Skills:Vba | Vb.net (Add ins Vault / Inventor, Applications) | I-logic
Programming Examples:Drawing List!|Toggle Drawing Sheet!|Workplane Resize!|Drawing View Locker!|Multi Sheet to Mono Sheet!|Drawing Weld Symbols!|Drawing View Label Align!|Open From Balloon!|Model State Lock!
Posts and Ideas:Dimension Component!|Partlist Export!|Derive I-properties!|Vault Prompts Via API!|Vault Handbook/Manual!|Drawing Toggle Sheets!|Vault Defer Update!
! For administrative reasons, please mark a "Solution as solved" when the issue is solved !
Hoi need another declaration
Make the declaration to PartComponentDefinition for parts.
Make the declaration to assemblyComponentDefinition for assemblies.
This should do it!
Regards,
Arthur Knoors
Autodesk Affiliations:
Autodesk Software:Inventor Professional 2024 | Vault Professional 2022 | Autocad Mechanical 2022
Programming Skills:Vba | Vb.net (Add ins Vault / Inventor, Applications) | I-logic
Programming Examples:Drawing List!|Toggle Drawing Sheet!|Workplane Resize!|Drawing View Locker!|Multi Sheet to Mono Sheet!|Drawing Weld Symbols!|Drawing View Label Align!|Open From Balloon!|Model State Lock!
Posts and Ideas:Dimension Component!|Partlist Export!|Derive I-properties!|Vault Prompts Via API!|Vault Handbook/Manual!|Drawing Toggle Sheets!|Vault Defer Update!
! For administrative reasons, please mark a "Solution as solved" when the issue is solved !
Hi bradeneurope,
thanks for your support. Unfortunately this does not help, I still get the same error: ...object has no attribute 'ComponentDefinition'
Hi bradeneurope,
thanks for your support. Unfortunately this does not help, I still get the same error: ...object has no attribute 'ComponentDefinition'
how do I do this:
"Make the declaration to PartComponentDefinition for parts.
Make the declaration to assemblyComponentDefinition for assemblies."
Could you please provide the Python code for it?
how do I do this:
"Make the declaration to PartComponentDefinition for parts.
Make the declaration to assemblyComponentDefinition for assemblies."
Could you please provide the Python code for it?
Take a look at this:
You need to declare your component definitions as first as part and assembly.
Dim bA As AssemblyDocument
Set bA = a.ActiveDocument
Dim cA As AssemblyComponentDefinition Set cA = bA.ComponentDefinition Dim dA As MassProperties Set dA = cA.MassProperties
-----------------------------
Dim bP As PartDocument
Set bP = a.ActiveDocument
Dim cP As PartComponentDefinition
Set cP = bP.ComponentDefinition
Dim dP As MassProperties
Set dP = cP.MassProperties
So do not use:
.. oDoc.ComponentDefinitions.Massproperties
Regards,
Arthur Knoors
Autodesk Affiliations:
Autodesk Software:Inventor Professional 2024 | Vault Professional 2022 | Autocad Mechanical 2022
Programming Skills:Vba | Vb.net (Add ins Vault / Inventor, Applications) | I-logic
Programming Examples:Drawing List!|Toggle Drawing Sheet!|Workplane Resize!|Drawing View Locker!|Multi Sheet to Mono Sheet!|Drawing Weld Symbols!|Drawing View Label Align!|Open From Balloon!|Model State Lock!
Posts and Ideas:Dimension Component!|Partlist Export!|Derive I-properties!|Vault Prompts Via API!|Vault Handbook/Manual!|Drawing Toggle Sheets!|Vault Defer Update!
! For administrative reasons, please mark a "Solution as solved" when the issue is solved !
Take a look at this:
You need to declare your component definitions as first as part and assembly.
Dim bA As AssemblyDocument
Set bA = a.ActiveDocument
Dim cA As AssemblyComponentDefinition Set cA = bA.ComponentDefinition Dim dA As MassProperties Set dA = cA.MassProperties
-----------------------------
Dim bP As PartDocument
Set bP = a.ActiveDocument
Dim cP As PartComponentDefinition
Set cP = bP.ComponentDefinition
Dim dP As MassProperties
Set dP = cP.MassProperties
So do not use:
.. oDoc.ComponentDefinitions.Massproperties
Regards,
Arthur Knoors
Autodesk Affiliations:
Autodesk Software:Inventor Professional 2024 | Vault Professional 2022 | Autocad Mechanical 2022
Programming Skills:Vba | Vb.net (Add ins Vault / Inventor, Applications) | I-logic
Programming Examples:Drawing List!|Toggle Drawing Sheet!|Workplane Resize!|Drawing View Locker!|Multi Sheet to Mono Sheet!|Drawing Weld Symbols!|Drawing View Label Align!|Open From Balloon!|Model State Lock!
Posts and Ideas:Dimension Component!|Partlist Export!|Derive I-properties!|Vault Prompts Via API!|Vault Handbook/Manual!|Drawing Toggle Sheets!|Vault Defer Update!
! For administrative reasons, please mark a "Solution as solved" when the issue is solved !
"""declaration"""
oPartDoc = PartDocument()
oPropset = PropertySets()
oPartCompdef = PartComponentDefinition()
MassProp = MassProperties()
MassofPart = Double()
oDescrip = Property()
oDesigner = Property()
oParams = Parameters()
oModelParams = ModelParameters()
oModelParam_1 = ModelParameter()
"""Set the Object"""
oPartDoc = ThisApplication.ActiveDocument
PropertySets = opartdoc.PropertySets.item('Design Tracking Properties')
oDescrip = propertysets.item('Description')
oDesigner = propertysets.item('Designer ')
oPartCompdef = oPartDoc.ComponentDefinition
MassProp = oPartCompdef.MassProperties
MassofPart = MassProps.Mass
oParams = oPartCompDef.Parameters
oModelParams = oParams.ModelParameters
oModelParam_1 = oModelParams.Item(1)
"""Get the Data"""
print(oDescrip.value)
print(oDesigner.value)
print(massofpart)
print(oModelParam_1.Value + ' cm')
"""declaration"""
oPartDoc = PartDocument()
oPropset = PropertySets()
oPartCompdef = PartComponentDefinition()
MassProp = MassProperties()
MassofPart = Double()
oDescrip = Property()
oDesigner = Property()
oParams = Parameters()
oModelParams = ModelParameters()
oModelParam_1 = ModelParameter()
"""Set the Object"""
oPartDoc = ThisApplication.ActiveDocument
PropertySets = opartdoc.PropertySets.item('Design Tracking Properties')
oDescrip = propertysets.item('Description')
oDesigner = propertysets.item('Designer ')
oPartCompdef = oPartDoc.ComponentDefinition
MassProp = oPartCompdef.MassProperties
MassofPart = MassProps.Mass
oParams = oPartCompDef.Parameters
oModelParams = oParams.ModelParameters
oModelParam_1 = oModelParams.Item(1)
"""Get the Data"""
print(oDescrip.value)
print(oDesigner.value)
print(massofpart)
print(oModelParam_1.Value + ' cm')
Hi dgreatice,
thank you for your idea!
Unfortunately it is not working yet. I get the following error: NameError: name 'PartDocument' is not defined.
I think the declaration you did is necessary, but somehow Python is expecting it in a different way?!
Hi dgreatice,
thank you for your idea!
Unfortunately it is not working yet. I get the following error: NameError: name 'PartDocument' is not defined.
I think the declaration you did is necessary, but somehow Python is expecting it in a different way?!
are python can add reference library?
at Visual Studio, I need to add reference library to read class of API Inventor. Like:
C:\Program Files\Autodesk\Inventor 2014\Bin\Public Assemblies\Autodesk.Inventor.Interop.dll
are python can add reference library?
at Visual Studio, I need to add reference library to read class of API Inventor. Like:
C:\Program Files\Autodesk\Inventor 2014\Bin\Public Assemblies\Autodesk.Inventor.Interop.dll
Regards,
Arthur Knoors
Autodesk Affiliations:
Autodesk Software:Inventor Professional 2024 | Vault Professional 2022 | Autocad Mechanical 2022
Programming Skills:Vba | Vb.net (Add ins Vault / Inventor, Applications) | I-logic
Programming Examples:Drawing List!|Toggle Drawing Sheet!|Workplane Resize!|Drawing View Locker!|Multi Sheet to Mono Sheet!|Drawing Weld Symbols!|Drawing View Label Align!|Open From Balloon!|Model State Lock!
Posts and Ideas:Dimension Component!|Partlist Export!|Derive I-properties!|Vault Prompts Via API!|Vault Handbook/Manual!|Drawing Toggle Sheets!|Vault Defer Update!
! For administrative reasons, please mark a "Solution as solved" when the issue is solved !
Regards,
Arthur Knoors
Autodesk Affiliations:
Autodesk Software:Inventor Professional 2024 | Vault Professional 2022 | Autocad Mechanical 2022
Programming Skills:Vba | Vb.net (Add ins Vault / Inventor, Applications) | I-logic
Programming Examples:Drawing List!|Toggle Drawing Sheet!|Workplane Resize!|Drawing View Locker!|Multi Sheet to Mono Sheet!|Drawing Weld Symbols!|Drawing View Label Align!|Open From Balloon!|Model State Lock!
Posts and Ideas:Dimension Component!|Partlist Export!|Derive I-properties!|Vault Prompts Via API!|Vault Handbook/Manual!|Drawing Toggle Sheets!|Vault Defer Update!
! For administrative reasons, please mark a "Solution as solved" when the issue is solved !
Hi dgreatice,
adding the library sounds like the right thing to do. I found out that the module for this is called "ctypes" in Python, however I didn´t manage to install and use it properly so far.
I keep trying ...
Hi dgreatice,
adding the library sounds like the right thing to do. I found out that the module for this is called "ctypes" in Python, however I didn´t manage to install and use it properly so far.
I keep trying ...
hi,
try to find any clue from youtube.
https://www.youtube.com/watch?v=VHxqGJc8hsM&t=62s
hi,
try to find any clue from youtube.
https://www.youtube.com/watch?v=VHxqGJc8hsM&t=62s
Hello,
I find myself in the same situation, I only know Python and I have a few scripts that used ComponentDefinition method. They used to work well, on Inventor 2015, but since the company updated to Inventor 2015 SP2 Update 6, a few days ago, my scripts stopped functioning. Autodesk must have modified something in their COM code... Have you found any solution for your problem yet?
Best regards,
Liviu
Hello,
I find myself in the same situation, I only know Python and I have a few scripts that used ComponentDefinition method. They used to work well, on Inventor 2015, but since the company updated to Inventor 2015 SP2 Update 6, a few days ago, my scripts stopped functioning. Autodesk must have modified something in their COM code... Have you found any solution for your problem yet?
Best regards,
Liviu
Hi @Anonymous,
Try the following python code to retrieve mass properties
import win32com.client from win32com.client import gencache, Dispatch, constants, DispatchEx 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 oDoc = mod.PartDocument(oDoc) 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 dArea = MassProps.Area print(dArea) lNum = partDef.Count print(lNum)
Thanks and regards,
Hi @Anonymous,
Try the following python code to retrieve mass properties
import win32com.client from win32com.client import gencache, Dispatch, constants, DispatchEx 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 oDoc = mod.PartDocument(oDoc) 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 dArea = MassProps.Area print(dArea) lNum = partDef.Count print(lNum)
Thanks and regards,
try this
import win64com.client from win64com.client import gencache, Dispatch, constants, DispatchEx oApp = win64com.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 oDoc = mod.PartDocument(oDoc) 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 dArea = MassProps.Area print(dArea) lNum = partDef.Count print(lNum)
Regards,
Arthur Knoors
Autodesk Affiliations:
Autodesk Software:Inventor Professional 2024 | Vault Professional 2022 | Autocad Mechanical 2022
Programming Skills:Vba | Vb.net (Add ins Vault / Inventor, Applications) | I-logic
Programming Examples:Drawing List!|Toggle Drawing Sheet!|Workplane Resize!|Drawing View Locker!|Multi Sheet to Mono Sheet!|Drawing Weld Symbols!|Drawing View Label Align!|Open From Balloon!|Model State Lock!
Posts and Ideas:Dimension Component!|Partlist Export!|Derive I-properties!|Vault Prompts Via API!|Vault Handbook/Manual!|Drawing Toggle Sheets!|Vault Defer Update!
! For administrative reasons, please mark a "Solution as solved" when the issue is solved !
try this
import win64com.client from win64com.client import gencache, Dispatch, constants, DispatchEx oApp = win64com.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 oDoc = mod.PartDocument(oDoc) 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 dArea = MassProps.Area print(dArea) lNum = partDef.Count print(lNum)
Regards,
Arthur Knoors
Autodesk Affiliations:
Autodesk Software:Inventor Professional 2024 | Vault Professional 2022 | Autocad Mechanical 2022
Programming Skills:Vba | Vb.net (Add ins Vault / Inventor, Applications) | I-logic
Programming Examples:Drawing List!|Toggle Drawing Sheet!|Workplane Resize!|Drawing View Locker!|Multi Sheet to Mono Sheet!|Drawing Weld Symbols!|Drawing View Label Align!|Open From Balloon!|Model State Lock!
Posts and Ideas:Dimension Component!|Partlist Export!|Derive I-properties!|Vault Prompts Via API!|Vault Handbook/Manual!|Drawing Toggle Sheets!|Vault Defer Update!
! For administrative reasons, please mark a "Solution as solved" when the issue is solved !
Regards,
Arthur Knoors
Autodesk Affiliations:
Autodesk Software:Inventor Professional 2024 | Vault Professional 2022 | Autocad Mechanical 2022
Programming Skills:Vba | Vb.net (Add ins Vault / Inventor, Applications) | I-logic
Programming Examples:Drawing List!|Toggle Drawing Sheet!|Workplane Resize!|Drawing View Locker!|Multi Sheet to Mono Sheet!|Drawing Weld Symbols!|Drawing View Label Align!|Open From Balloon!|Model State Lock!
Posts and Ideas:Dimension Component!|Partlist Export!|Derive I-properties!|Vault Prompts Via API!|Vault Handbook/Manual!|Drawing Toggle Sheets!|Vault Defer Update!
! For administrative reasons, please mark a "Solution as solved" when the issue is solved !
Regards,
Arthur Knoors
Autodesk Affiliations:
Autodesk Software:Inventor Professional 2024 | Vault Professional 2022 | Autocad Mechanical 2022
Programming Skills:Vba | Vb.net (Add ins Vault / Inventor, Applications) | I-logic
Programming Examples:Drawing List!|Toggle Drawing Sheet!|Workplane Resize!|Drawing View Locker!|Multi Sheet to Mono Sheet!|Drawing Weld Symbols!|Drawing View Label Align!|Open From Balloon!|Model State Lock!
Posts and Ideas:Dimension Component!|Partlist Export!|Derive I-properties!|Vault Prompts Via API!|Vault Handbook/Manual!|Drawing Toggle Sheets!|Vault Defer Update!
! For administrative reasons, please mark a "Solution as solved" when the issue is solved !
To the best of my knowledge, 'win64com' does not exist (yet?)....
To the best of my knowledge, 'win64com' does not exist (yet?)....
Does this work then:
import win32com.client from win32com.client import gencache, Dispatch, constants, DispatchEx 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 oDoc = mod.PartDocument(oDoc) 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 dArea = MassProps.Area print(dArea) lNum = partDef.Count print(lNum)
I have used "######" instead of '######'
Regards,
Arthur Knoors
Autodesk Affiliations:
Autodesk Software:Inventor Professional 2024 | Vault Professional 2022 | Autocad Mechanical 2022
Programming Skills:Vba | Vb.net (Add ins Vault / Inventor, Applications) | I-logic
Programming Examples:Drawing List!|Toggle Drawing Sheet!|Workplane Resize!|Drawing View Locker!|Multi Sheet to Mono Sheet!|Drawing Weld Symbols!|Drawing View Label Align!|Open From Balloon!|Model State Lock!
Posts and Ideas:Dimension Component!|Partlist Export!|Derive I-properties!|Vault Prompts Via API!|Vault Handbook/Manual!|Drawing Toggle Sheets!|Vault Defer Update!
! For administrative reasons, please mark a "Solution as solved" when the issue is solved !
Does this work then:
import win32com.client from win32com.client import gencache, Dispatch, constants, DispatchEx 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 oDoc = mod.PartDocument(oDoc) 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 dArea = MassProps.Area print(dArea) lNum = partDef.Count print(lNum)
I have used "######" instead of '######'
Regards,
Arthur Knoors
Autodesk Affiliations:
Autodesk Software:Inventor Professional 2024 | Vault Professional 2022 | Autocad Mechanical 2022
Programming Skills:Vba | Vb.net (Add ins Vault / Inventor, Applications) | I-logic
Programming Examples:Drawing List!|Toggle Drawing Sheet!|Workplane Resize!|Drawing View Locker!|Multi Sheet to Mono Sheet!|Drawing Weld Symbols!|Drawing View Label Align!|Open From Balloon!|Model State Lock!
Posts and Ideas:Dimension Component!|Partlist Export!|Derive I-properties!|Vault Prompts Via API!|Vault Handbook/Manual!|Drawing Toggle Sheets!|Vault Defer Update!
! For administrative reasons, please mark a "Solution as solved" when the issue is solved !
Hi,
No, it still does not work. Does it work for you?
*** Python 2.7.3 (default, Apr 10 2012, 23:31:26) [MSC v.1500 32 bit (Intel)] on win32. *** *** Remote Python engine is active *** >>> import win32com.client >>> win32com.client <module 'win32com.client' from 'C:\Users\________\Documents\PORTABLE PROGRAM FILES\Portable Python 2.7.3.1\App\lib\site-packages\win32com\client\__init__.pyc'> >>> from win32com.client import gencache, Dispatch, constants, DispatchEx >>> oApp = win32com.client.Dispatch("Inventor.Application") >>> oApp <win32com.gen_py.Autodesk Inventor Object Library.Application instance at 0x45696624> >>> oApp.Visible = True >>> mod = gencache.EnsureModule("{D98A091D-3A0F-4C3E-B36E-61F62068D488}", 0, 1, 0) >>> mod <module 'win32com.gen_py.D98A091D-3A0F-4C3E-B36E-61F62068D488x0x1x0' from 'C:\Users\______\AppData\Local\Temp\gen_py\2.7\D98A091D-3A0F-4C3E-B36E-61F62068D488x0x1x0\__init__.pyc'> >>> oApp = mod.Application(oApp) Traceback (most recent call last): File "<interactive input>", line 1, in <module> TypeError: 'module' object is not callable
Inventor 2015
64-Bit Edition
Build 223, Release 2015 SP2 Update 6
Windows 7 Entreprise SP1
Hi,
No, it still does not work. Does it work for you?
*** Python 2.7.3 (default, Apr 10 2012, 23:31:26) [MSC v.1500 32 bit (Intel)] on win32. *** *** Remote Python engine is active *** >>> import win32com.client >>> win32com.client <module 'win32com.client' from 'C:\Users\________\Documents\PORTABLE PROGRAM FILES\Portable Python 2.7.3.1\App\lib\site-packages\win32com\client\__init__.pyc'> >>> from win32com.client import gencache, Dispatch, constants, DispatchEx >>> oApp = win32com.client.Dispatch("Inventor.Application") >>> oApp <win32com.gen_py.Autodesk Inventor Object Library.Application instance at 0x45696624> >>> oApp.Visible = True >>> mod = gencache.EnsureModule("{D98A091D-3A0F-4C3E-B36E-61F62068D488}", 0, 1, 0) >>> mod <module 'win32com.gen_py.D98A091D-3A0F-4C3E-B36E-61F62068D488x0x1x0' from 'C:\Users\______\AppData\Local\Temp\gen_py\2.7\D98A091D-3A0F-4C3E-B36E-61F62068D488x0x1x0\__init__.pyc'> >>> oApp = mod.Application(oApp) Traceback (most recent call last): File "<interactive input>", line 1, in <module> TypeError: 'module' object is not callable
Inventor 2015
64-Bit Edition
Build 223, Release 2015 SP2 Update 6
Windows 7 Entreprise SP1
Can't find what you're looking for? Ask the community or share your knowledge.