Get partnumbers of purchased parts, excluding pp in purchased assy's

Get partnumbers of purchased parts, excluding pp in purchased assy's

hldr
Contributor Contributor
349 Views
2 Replies
Message 1 of 3

Get partnumbers of purchased parts, excluding pp in purchased assy's

hldr
Contributor
Contributor

Hi all, 

 

I'm working on an iLogic rule which will export certain part numbers to a txt-file. I want to export all part numbers of parts and sub assemblies that are set as purchased. Sometimes a purchased subassy contains some purchased parts, but i don't need the part numbers of those parts. 

So basically i need an export of all the partnumbers  that would show op as purchased in the parts-only BOM.

 

The rule is mostly working, but the part that should skip purchased parts in purchased assy's seems to be causing problems. So I was wondering if there is a better/alternative way to write this:

If oRefDoc.SubType = "{9C464203-9BAE-11D3-8BAD-0060B0CE6BB4}" Or oRefDoc.SubType = "{4D29B490-49B2-11D0-93C3-7E0706000000}" Or oRefDoc.SubType = "{E60F81E1-49B3-11D0-93C3-7E0706000000}" Or oRefDoc.SubType = "{28EC8354-9024-440F-A8A2-0E0E55D635B0}" Then
			
				Dim oPartDoc As Document
				oPartDoc = oRefDoc
				
				'Check if part is purchased part
				If oPartDoc.ComponentDefinition.BOMStructure = 51973 Then 'Purchase
										
					Dim oRefAssys As DocumentsEnumerator = oRefDoc.ReferencingDocuments
					Dim PurchaseCheck As Document
					Dim ReffPurchasePart As Boolean 
					
					ReffPurchasePart = True
				'Check if there are purchased parts in purchased assy's, if so then ignore these parts	
					For Each PurchaseCheck In oRefAssys						'purchase						'assembly														
						If PurchaseCheck.ComponentDefinition.BOMStructure = 51973 And PurchaseCheck.SubType = "{E60F81E1-49B3-11D0-93C3-7E0706000000}" Then 
							ReffPurchasePart = False
						End If																								'weldment
						If PurchaseCheck.ComponentDefinition.BOMStructure = 51973 And PurchaseCheck.SubType = "{28EC8354-9024-440F-A8A2-0E0E55D635B0}" Then 																								
						
							ReffPurchasePart = False
						End If
					Next
					
					If ReffPurchasePart = False Then
					Else 

 

0 Likes
350 Views
2 Replies
Replies (2)
Message 2 of 3

A.Acheson
Mentor
Mentor

Perhaps an easier way is to work directly with the BOM and select the parts only tab then loop through the BOM checking and adding the purchased parts/assemblies to a list. API sample here

Dim PurchasedList As New ArrayList

Dim AssyDoc As AssemblyDocument
AssyDoc = ThisApplication.ActiveDocument

Dim oAsmCompDef As AssemblyComponentDefinition
oAsmCompDef = AssyDoc.ComponentDefinition

Dim oBOMView As BOMView 
oBOMView = oAsmCompDef.BOM.BOMViews("Parts Only")

For Each oBOMRow As BOMRow In oBOMView.BOMRows
	Dim oDoc As Document = oBOMRow.ComponentDefinitions.Item(1).Document
	If oDoc.SubType = "{9C464203-9BAE-11D3-8BAD-0060B0CE6BB4}" Or oDoc.SubType = "{4D29B490-49B2-11D0-93C3-7E0706000000}" Or oDoc.SubType = "{E60F81E1-49B3-11D0-93C3-7E0706000000}" Or oDoc.SubType = "{28EC8354-9024-440F-A8A2-0E0E55D635B0}" Then
		'Check if part is purchased part
		If oDoc.ComponentDefinition.BOMStructure = 51973 Then 'Purchase
			'Logger.Info(oDoc.DisplayName)
			Dim oDTP As PropertySet = oDoc.PropertySets.Item("Design Tracking Properties")
			Dim oPN As String = oDTP.Item("Part Number").Value.ToString
			PurchasedList.Add(oPN)
		End If
	End If
Next

d0 = InputListBox("Prompt", PurchasedList, d0, Title := "Purchased List", ListName := "List")

 

If this solved a problem, please click (accept) as solution.‌‌‌‌
Or if this helped you, please, click (like)‌‌
Regards
Alan
Message 3 of 3

hldr
Contributor
Contributor

Thank you for your reply. I just bumped on some other practical purchased parts problems, and decided to use a completely different approach. Thank you anyway!

0 Likes