Top Level Assembly - BOM Qty

Top Level Assembly - BOM Qty

WP_Australind
Enthusiast Enthusiast
203 Views
1 Reply
Message 1 of 2

Top Level Assembly - BOM Qty

WP_Australind
Enthusiast
Enthusiast

I have a Top Level Assembly where using the Bill Of Materials (BOM) the total number of parts used is listed, as per normal.

When I Create an IDW drawing of the part that is used in the top most assembly,  I want to show the total number of items required.

 

I know I could do this with View Reps from the assembly, but this is messy.

 

In the BOM list of the Assembly, I'm trying to make Custom Property (BOMREQ) that captures the BOM Qty, normally I would have expected to enter =<QTY> in the cell to do this, and the QTY value (4) would be shown in the cell, but it isn't working. 

I have a Sketch Block on my IDW with a custom property, that would report this value.

 

Is there another way of doing this, or am I missing something?

 

 

Inventor 2024

0 Likes
204 Views
1 Reply
Reply (1)
Message 2 of 2

Andrii_Humeniuk
Advisor
Advisor

Hi @WP_Australind . This iLogic code creates or writes to the NUMREQ parameter the number of components in the main assembly. You need to run the code in the main assembly.

 

Sub main
	Dim oAsmDoc As AssemblyDocument = ThisApplication.ActiveDocument
	Dim oOccs As ComponentOccurrences = oAsmDoc.ComponentDefinition.Occurrences
	For Each oRefDoc As PartDocument In oAsmDoc.AllReferencedDocuments.OfType(Of PartDocument)
		If Not oRefDoc.IsModifiable Then Continue For
		Dim iQTy As Integer = oOccs.AllReferencedOccurrences(oRefDoc).Count
		If iQTy = 0 Then Continue For
		Dim oCustom As PropertySet = oRefDoc.PropertySets("Inventor User Defined Properties")
		Dim MSGS As New ModelStatesGlobalScope(oRefDoc)
		Try : oCustom("NUMREQ").Value = iQTy
		Catch : oCustom.Add(iQTy, "NUMREQ") : End Try
		MSGS.Dispose
	Next
End Sub

 

 

Andrii Humeniuk - CAD Coordinator, Autodesk Certified Instructor

LinkedIn | My free Inventor Addin | My Repositories

Did you find this reply helpful ? If so please use the Accept as Solution/Like.

EESignature

0 Likes