I'm trying to write an iLogic app for processing bodies of the active Assembly.
My minimal goal is just to count unique bodies.
My current best bet is:
Dim oAsmDoc As AssemblyDocument oAsmDoc = ThisApplication.ActiveDocument Dim MsgBody As String="" Dim OccIndex As Integer=0 Dim BdQTY As Integer=0 For Each oOcc As ComponentOccurrence In oAsmDoc.ComponentDefinition.Occurrences BdQTY=BdQTY+oOcc.SurfaceBodies.Count OccIndex=OccIndex+1 MsgBody=MsgBody & "#" & OccIndex & ":" & vbCrLf & "Name : " & oOcc.Name & vbCrLf & "Type : " & oOcc.Type & vbCrLf & "BodyQTY = " & oOcc.SurfaceBodies.Count & vbCrLf & vbCrLf Next MsgBox(MsgBody,, BdQTY & " bodies found in " & oAsmDoc.ComponentDefinition.Occurrences.Count & " components:")
For standard sample weldment-assembly Carriage.iam it gives me wrong result (6 bodies) while expected is 10 bodies (reported by BSCT after pressing Ctrl+F7) :
I guess I have done at least two mistakes:
1. I am not skipping the body for duplicated occurences
2. I'm not counting bodies of sub-assemblies
and may be I should more carefully process weld-beads
As for 2 if I don't missed some easier way (some ready for use property) i probably need to add some recursion procedure (never did this before yet) , right?
Could please somebody point me in the right direction..
PS: My further goal - get body-complexity rating i.e.. report N (let say five) most complex bodies sorted for decreasing FaceCount
Solved! Go to Solution.
Solved by chandra.shekar.g. Go to Solution.
Hoping that below iLogic code may help to get count of bodies in an assembly.
Dim oAsmDoc As AssemblyDocument oAsmDoc = ThisApplication.ActiveDocument Dim MsgBody As String="" Dim OccIndex As Integer=0 Dim BdQTY As Integer=0 Dim oDoc As Document For Each oDoc In oAsmDoc.AllReferencedDocuments BdQTY=BdQTY+ oDoc.ComponentDefinition.SurfaceBodies.Count OccIndex=OccIndex+1 MsgBody=MsgBody & "#" & OccIndex & ":" & vbCrLf & "Name : " & oDoc.DisplayName & vbCrLf & "Type : " & oDoc.DocumentType & vbCrLf & "BodyQTY = " & oDoc.ComponentDefinition.SurfaceBodies.Count & vbCrLf & vbCrLf Next MsgBox(MsgBody,, BdQTY & " bodies found in " & oAsmDoc.ComponentDefinition.Occurrences.Count & " components:")
Thanks and regards,
Can't find what you're looking for? Ask the community or share your knowledge.