07-21-2021
06:58 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
07-21-2021
06:58 PM
Hi all,
I am struggling to figure out how I can remove invisible (visible = false) items from component occurances count.
best regards,
Flo
Solved! Go to Solution.
07-22-2021
12:25 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
07-22-2021
12:25 AM
Hi @floccipier
If you dont want to use a for each loop and just loop through the occurrences, checking each one of them if it's visible or not and add +1 to an integer if so, you can do it like this
(oDoc = the document your'e checking all referenced occurrences of)
Dim oAsm As AssemblyDocument = ThisDoc.Document MsgBox(oAsm.ComponentDefinition.Occurrences.AllReferencedOccurrences(oDoc).OfType(Of ComponentOccurrence).Where(Function(x) x.Visible = True).Count)
Otherwise something like this is probably the most simple way to do it:
Dim oAsm As AssemblyDocument = ThisDoc.Document Dim count As Integer = 0 For Each oOcc As ComponentOccurrence In oAsm.ComponentDefinition.Occurrences.AllReferencedOccurrences(oDoc) If oOcc.Visible Then count += 1 Next MsgBox(count)
Jhoel Forshav
Download my free Inventor Addin - Hole Projector
LinkedIn | Ideas | Contributions | Blog posts | Website
07-22-2021
12:55 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
07-22-2021
12:55 AM
Try this!
Dim oAsmCompDef As AssemblyComponentDefinition oAsmCompDef = ThisApplication.ActiveDocument.ComponentDefinition 'Iterate through all of the occurrences Dim oOccurrence As ComponentOccurrence Dim oList As New List(Of Integer) For Each oOccurrence In oAsmCompDef.Occurrences If oOccurrence.Visible = True Then oList.Add(oAsmCompDef.Occurrences.Count) End If x1 = oList.Count Next MessageBox.Show(x1, "Number of VisibleComponents")
Bhavik Suthar