Message 1 of 3
Ilogic not deleting virtual parts correctly
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
I have a program that cycles through an assembly, finds the parts I need to order, and creates as many virtual parts as I need to order. Each time I run the rule, it is supposed to delete all previous virtual components and add as many virtual components as it needs.
The problem is, if I go through the assembly and delete all instances of these parts, it will still leave one virtual component left over. Not a problem to delete manually, but I'd still like to understand why this is occurring. Can anyone help me understand why it is doing this?
Thank you in advance to everyone for helping out!
Function UpdateVirtParts (sVirtPart, Description, iQty) 'define assembly Dim asmDoc As AssemblyDocument asmDoc = ThisApplication.ActiveDocument 'define assembly Component Definition Dim oAsmCompDef As AssemblyComponentDefinition oAsmCompDef = ThisApplication.ActiveDocument.ComponentDefinition 'Iterate through all of the occurrences in the assembly Dim asmOcc As ComponentOccurrence For Each asmOcc In oAsmCompDef.Occurrences 'get name of occurence only (sees only everything left of the colon) Dim oOcc As Object oOcc = asmOcc.Name.Split(":")(0) 'look at only virtual components If TypeOf asmOcc.Definition Is VirtualComponentDefinition 'compare name selected from list to the 'existing virtual parts If oOcc = sVirtPart Then asmOcc.delete End If Next Dim occs As ComponentOccurrences occs = asmDoc.ComponentDefinition.Occurrences Dim identity As Matrix identity = ThisApplication.TransientGeometry.CreateMatrix 'create first instance of the virtual part Dim virtOcc As ComponentOccurrence virtOcc = occs.AddVirtual(sVirtPart, identity) iProperties.Value(sVirtPart & ":1", "Project", "Description") = Description iProperties.Value(sVirtPart & ":1", "Project", "Part Number") = sVirtPart For index As Integer = 2 To iQTY occs.AddByComponentDefinition(virtOcc.Definition, identity) Next End Function