Message 1 of 9
Retrieving Material ID for Applied Materials in Assemblies (.iam) or Parts (.ipt)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
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;