i'm need some help with selecting 1 part from multi select
im building a dxf generator and i can select an entire assembly and it just fishes out the sheet metal, but when i select the same part a couple of times it wil do it multiple times and thats just a wast of time
so what im basicly looking for is the code that does the opposite of select all occurrences,
so i got a bunch selected and i just want 1 of each parts so part1 1 time , part2 1 time and so on...
tried the ComponentOccurrencesEnumerator, but cant get it to work in a selectset ( so i can count how many times i selected part1)
any ideas someone?
would me very appreciated!!
thanks in advance
Björn
Solved! Go to Solution.
Solved by Burnit87. Go to Solution.
Solved by Burnit87. Go to Solution.
Solved by Burnit87. Go to Solution.
Solved by alyssaweaver. Go to Solution.
I'm not positive this is what you want, but check this out. It allows you to select some occurences rather than all.
http://designandmotion.net/autodesk/replace-some-components-in-inventor-2014/
ok i tell step by step what i want it to do
- first ill set my selection to part priority
- then select complete assembly
- check for double selection
- take sheet metal parts
- run t he dxf genereator for
and the double selection part is where im having troubles, cause if a part is selected 6 times the dxf generator will unfold it 6 times and export it 6 times, wich costs a lot of time, if you got muliple patterns, and i dont want to hand pick every component.
so basicly i want it to check if a part is being selected multiple occurrences and then deselect all but one.
this is how far i've got, it works sort of but it now keeps de-selecting everything that had more then one selection, im looking for a way to update my selectset
'check if the same part is selected multiple times
ForEach prtDocOcc As ComponentOccurrence In SelSet
ForEach prtDocOcc2 As ComponentOccurrence In SelSet
If prtDocOcc.Definition.Document.fullfileName = prtDocOcc2.Definition.Document.fullfileName Then
If prtDocOcc.Name <> prtDocOcc2.Name Then
SelSet.Remove(prtDocOcc2)
'update selectset or it will de-selecting everything that had more then 1 occ selected
EndIf
EndIf
Next
Next
The code on that link I sent you should allow you to select the single occurrence from the get go. Is that not acceptable for what you want to do?
**** missed it,
been searching al day for a solution but i fixed it
thank you a whole lot
redo:
'check if the same part is selected multiple times
ForEach prtDocOcc AsComponentOccurrenceIn SelSet
ForEach prtDocOcc2 AsComponentOccurrenceIn SelSet
If prtDocOcc.Definition.Document.fullfileName = prtDocOcc2.Definition.Document.fullfileName Then
If prtDocOcc.Name <> prtDocOcc2.Name Then
SelSet.Remove(prtDocOcc2)
GoTo redo
EndIf
EndIf
Next
Next
ran into anthoter problem, when you have multiple subassemblies you'll need an extra if
redo:
'check if the same part is selected multiple times
ForEach prtDocOcc AsComponentOccurrenceIn SelSet
ForEach prtDocOcc2 AsComponentOccurrenceIn SelSet
If prtDocOcc.Definition.Document.fullfileName = prtDocOcc2.Definition.Document.fullfileName Then
If prtDocOcc.Name <> prtDocOcc2.Name Then
SelSet.Remove(prtDocOcc2)
GoTo redo
ElseIf prtDocOcc.Name = prtDocOcc2.Name Then
Try
If prtDocOcc.ParentOccurrence.Name <> prtDocOcc2.ParentOccurrence.Name Then
SelSet.Remove(prtDocOcc2)
GoTo redo
EndIf
Catch ex AsException
EndTry
EndIf
EndIf
Next
Next
and worked out another solution for big assemblies, cause the current loop takes 3 to 4 times as long
'check if the same part is selected multiple times
Dim firstLoopCounter AsInteger = 1
Dim secondLoopCounter AsInteger = 1
Dim toRemove AsNewCollection
ForEach prtDocOcc AsComponentOccurrenceIn SelSet
secondLoopCounter = 1
ForEach prtDocOcc2 AsComponentOccurrenceIn SelSet
If secondLoopCounter > firstLoopCounter Then
If prtDocOcc.Definition.Document.fullfileName = prtDocOcc2.Definition.Document.fullfileName Then
If prtDocOcc.Name <> prtDocOcc2.Name Then
toRemove.Add(prtDocOcc2)
ElseIf prtDocOcc.Name = prtDocOcc2.Name Then
Try
If prtDocOcc.ParentOccurrence.Name <> prtDocOcc2.ParentOccurrence.Name Then
toRemove.Add(prtDocOcc2)
EndIf
Catch ex AsException
EndTry
EndIf
EndIf
EndIf
secondLoopCounter = secondLoopCounter + 1
Next
firstLoopCounter = firstLoopCounter + 1
Next
ForEach prtDocToRemove AsComponentOccurrenceIn toRemove
SelSet.Remove(prtDocToRemove)
Next