Occurrence count and color

Occurrence count and color

dhanshri_gavas
Contributor Contributor
233 Views
1 Reply
Message 1 of 2

Occurrence count and color

dhanshri_gavas
Contributor
Contributor

Hi Team,
In Inventor, how do I get the total occurrence count (refer below image) using the API in the part and assembly document? as well as how to get the color of each occurrence using the API?
Thanks in advance!

dhanshri_gavas_0-1721318200852.png

 

0 Likes
234 Views
1 Reply
Reply (1)
Message 2 of 2

WCrihfield
Mentor
Mentor

Hi @dhanshri_gavas.  The lower left number 'Total Occurrences in Active Document' is the total number not only in the top level of the assembly, but also all that are in all of the sub assemblies also.  That number can be obtained using something similar to the following.  This is just a quickie example to show the number in a MsgBox.

Dim oADoc As AssemblyDocument = ThisDoc.Document
Dim oADef As AssemblyComponentDefinition = oADoc.ComponentDefinition
Dim iTotalOccsAllLevels As Integer = oADef.Occurrences.AllReferencedOccurrences(oADef).Count
MsgBox(iTotalOccsAllLevels.ToString, , "Occurrences Count")

As far as I know, that number should always be 1 in a part.  And in a drawing, it will reflect all the data from all the models being referenced within the drawing.  So if you have an assembly with number = 105, then you create a drawing for just that assembly, the drawing will show that same number.

Wesley Crihfield

EESignature

(Not an Autodesk Employee)

0 Likes