After set a material to the component definition of a document using API, the Physical properties under iProperty window is not updated, unless the user click on Update button. Also, the API call to PartDocument.Update do not update the value either.
The simplest way is access one of the physical properties, which will force the whole API MassProperties to update. The following sample code demonstrate it.
‘ access the document and
‘ component definition
Dim partDoc As PartDocument
partDoc = m_inventorApplication.ActiveDocument
‘ the material name
Dim materialName As String = "Material Name"
‘ define and access the material
partDoc.Materials.Add(materialName, 6.45)
Dim materialDef As Material = _
partDoc.Materials(materialName)
partDoc.ComponentDefinition.Material = materialDef
‘ access the property will force an update
Dim mass As Double = partDoc. _
ComponentDefinition.MassProperties.Mass

Leave a Reply