Select All Parts With Prefix Username

Select All Parts With Prefix Username

Anonymous
Not applicable
373 Views
3 Replies
Message 1 of 4

Select All Parts With Prefix Username

Anonymous
Not applicable
I have a procedure that saves (SaveAs) and Replaces parts as I design. I'm free to modify parts after one button click. Each new part is assigned a temporary number that begins with the user name, an underscore, and a sequence of numbers (001, 002, etc.).

Here's my problem. When the design is finished I will select all parts in my assembly that begin with username and assign them real numbers based on and furnished by our ERP software. What is the best way to select them? Should I use a selection filter and string manipulation, or should I pull a list from the BOM and loop through it?

Thanks,

Jon
0 Likes
374 Views
3 Replies
Replies (3)
Message 2 of 4

Anonymous
Not applicable
I'm thinking this might work, but how do you simply list the quantities rather than print out each occurrence?

{code}For Each oCompOcc In oCompDef.Occurrences
If oCompOcc.SubOccurrences.Count = 0 Then
Debug.Print(oCompOcc.Name)
Else
Debug.Print(oCompOcc.Name)
Call processAllSubOcc{code}
0 Likes
Message 3 of 4

Anonymous
Not applicable
I don't know VB.NET very well but VB6 & VBA can use a Dictionary object to keep track of both the component name (Key) and count (Value). The Dictionary object is in the File System Object which is referenced in the Microsoft Scripting Runtime (scrrun.dll).
0 Likes
Message 4 of 4

Anonymous
Not applicable
The way I've gotten around the occurance issue is to use referenced files:
Starting from a drawing, it gets the first view and then gets the part numbers of all the files referenced by the assembly. The actual code has more checks and validations but you can add that...

On Error Resume Next
Set oDocRef = oDoc.ActiveSheet.DrawingViews(1).ReferencedFile. _
DocumentDescriptor.ReferencedDocument
For Each oRefDoc In oDocRef.ReferencedDocuments
Set oPropsets = oRefDoc.PropertySets
Set oPropSet = oPropsets.Item("Design Tracking Properties")
Set oProp = oPropSet.Item("Part Number")
Next
Hope this helps Edited by: gohlin on May 18, 2009 10:10 AM
0 Likes