Hello to everyone,
I used some code I found in previous topics to calculate the bounding box of an assembly. At first sight, it seems to be working but after some more investigation I ran into something strange. The code collects all the necessary bodies of the assembly but when they are added to a bodydumbrule, all the bodies of duplicate components are excluded and only the last instance of the component body is added to the selection.
How can I change the code to select also all duplicate bodies?
Here's part of the code :
Dim bodies1(n) As NXOpen.Body
bodies1 = AllBodies.ToArray()
Dim selectionIntentRuleOptions1 As NXOpen.SelectionIntentRuleOptions = Nothing
selectionIntentRuleOptions1 = workPart.ScRuleFactory.CreateRuleOptions()
selectionIntentRuleOptions1.SetSelectedFromInactive(False)
Dim bodyDumbRule1 As NXOpen.BodyDumbRule = Nothing
'At this point all bodies are still in 'bodies1'
bodyDumbRule1 = tempWorkPart.ScRuleFactory.CreateRuleBodyDumb(bodies1, True, selectionIntentRuleOptions1)
selectionIntentRuleOptions1.Dispose()
Dim scCollector1 As NXOpen.ScCollector = Nothing
scCollector1 = toolingBoxBuilder1.BoundedObject
Dim rules1(0) As NXOpen.SelectionIntentRule
rules1(0) = bodyDumbRule1
scCollector1.ReplaceRules(rules1, False)
'After the 'ReplaceRules' command, the duplicate bodies are filtered out.
I am only a beginner in programming so maybe someone more experienced can help me out.
Thank you in advance.