Message 1 of 5

Not applicable
10-10-2020
11:08 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hello Everyone,
So I am trying to build a custom 3rd party application for Inventor using the API. I have a utility class that does a lot of heavy lifting for me. I am trying to create a method that suppresses all other parts except the part with a specified iProperty value in the description.
In my code, I have been able to find the part with the particular iProperty value, but when I check the occurrences of that part in the assembly, the count is zero. Here is a snippet of the code I am using, is there anything I am doing wrong?
public static void SuppressAllOccurancesExecpted(String iPropertyId, DocumentsEnumerator documents)
{
foreach (Document document in documents)
{
PropertySet propertySet = document.PropertySets["Design Tracking Properties"];
Property description = null;
PartDocument part = null;
PartComponentDefinition partComp = null;
ComponentOccurrences occurances = null;
foreach (Property property in propertySet)
{
if(property.Name == "Description")
{
description = property;
if(description.Value == iPropertyId)
{
part = (PartDocument)document;
partComp = part.ComponentDefinition;
MessageBox.Show(part.DisplayName);
occurances = partComp.Occurrences;
MessageBox.Show(occurances.Count.ToString());
}
break;
}
}
}
}
Thank you very much for you assistance!
Solved! Go to Solution.