Issue:
We have one ipart with the custom parameters and place this ipart in an assembly. We need to get existing custom values for a particular occurrence (ipartmember).
Solution
If you check iPartTableColumn.FormattedHeading, you will find there is such format "<free></free>" for custom column. Following is a simple sample.It assumes an assembly is opened. And the first occurrence is an iPart member.
void test()
{
// assume we have had Inventor application
// get current assemly
AssemblyDocument invAD =
(AssemblyDocument)_InvApplication.ActiveDocument;
// assume the first Occurrence is from iPart
ComponentOccurrence invCO =
invAD.ComponentDefinition.Occurrences[1];
// get PartComponentDefinition
PartComponentDefinition invPCD =
(PartComponentDefinition)invCO.Definition;
if(invPCD.IsiPartMember)
{
// get iPartFactory
iPartFactory iPartfac =
{
// assume we have had Inventor application
// get current assemly
AssemblyDocument invAD =
(AssemblyDocument)_InvApplication.ActiveDocument;
// assume the first Occurrence is from iPart
ComponentOccurrence invCO =
invAD.ComponentDefinition.Occurrences[1];
// get PartComponentDefinition
PartComponentDefinition invPCD =
(PartComponentDefinition)invCO.Definition;
if(invPCD.IsiPartMember)
{
// get iPartFactory
iPartFactory iPartfac =
invPCD.iPartMember.ParentFactory;
// dump the custom values
foreach (iPartTableCell inviPTC in
invPCD.iPartMember.Row)
{
String oFormatHeading =
// dump the custom values
foreach (iPartTableCell inviPTC in
invPCD.iPartMember.Row)
{
String oFormatHeading =
iPartfac.TableColumns[inviPTC.Column].
FormattedHeading;
if (oFormatHeading.IndexOf("<free>") != -1)
{
//get value: iPartTableCell.Value
System.Diagnostics.Debug.Write(
if (oFormatHeading.IndexOf("<free>") != -1)
{
//get value: iPartTableCell.Value
System.Diagnostics.Debug.Write(
inviPTC.Value.ToString());
}
}
}
}
}
}
}
}