Announcements
Attention for Customers without Multi-Factor Authentication or Single Sign-On - OTP Verification rolls out April 2025. Read all about it here.
pts_user
726 Views, 8 Replies

Retrieving Material ID for Applied Materials in Assemblies (.iam) or Parts (.ipt)

I am currently attempting to retrieve the material ID for materials applied to assemblies (.iam) or parts (.ipt). While I have successfully obtained the material name and other details, I am encountering difficulty in obtaining the material ID.

If anyone has insights or suggestions on how to retrieve the material ID for the applied material, I would greatly appreciate your input.

For your reference, please find the code snippet below.

  • For assemblies:

 

Inventor.Document doc = m_InventorApplication.ActiveDocument;
AssemblyDocument asmdoc = doc as AssemblyDocument;
AssemblyComponentDefinition asmDef = (doc as AssemblyDocument).ComponentDefinition;
string matName = asmDef.DefaultMaterial.Name;

 

  • For parts:

 

PartDocument prtdoc = Componentocc.Definition.Document as PartDocument;
PartComponentDefinition partDef = (prtdoc as PartDocument).ComponentDefinition;
string matName = partDef.Material.Name;