Multiply number of parts by number of assemblies

Multiply number of parts by number of assemblies

cristianofa8
Explorer Explorer
333 Views
5 Replies
Message 1 of 6

Multiply number of parts by number of assemblies

cristianofa8
Explorer
Explorer

I have a drawing of a set to manufacture, I already have a parts list with the quantity of how many pieces to manufacture a set. Is it possible to multiply the number of sets by the number of pieces per set? To then present this value on the drawing sheet for the production of each piece?

Inventor.png

 

I think an easier way is to insert the calculation value into the iProperties of each solid in the table. Then, in the production design sheet, I can search for this field where the total value is entered. I've tried several ways, but it always gives errors or doesn't work correctly.

Thanks

0 Likes
334 Views
5 Replies
Replies (5)
Message 2 of 6

Andrii_Humeniuk
Advisor
Advisor

Hi @cristianofa8 . This iLogic code needs to be run in the main assembly. It counts the number of occurrences of all parts and creates 2 new custom properties in each part.
The first property TotalQty is the number of occurrences in the main assembly of each part.
The second property MainAseembly is the name of the assembly in which the rule was run.

Dim oInvApp As Inventor.Application = ThisApplication
Dim oADoc As AssemblyDocument = TryCast(oInvApp.ActiveDocument, AssemblyDocument)
If oADoc Is Nothing Then Exit Sub
Dim sName As String = IO.Path.GetFileNameWithoutExtension(oADoc.FullFileName)
Dim oOccs As ComponentOccurrences = oADoc.ComponentDefinition.Occurrences
Dim oTM As Transaction = oInvApp.TransactionManager.StartTransaction(oADoc, "Set Props Qty...")
For Each oRefDoc As PartDocument In oADoc.AllReferencedDocuments.OfType(Of PartDocument)
	If Not oRefDoc.IsModifiable Then Continue For	
	Dim oRefDef As PartComponentDefinition = oRefDoc.ComponentDefinition
	Dim iQty As Integer = oOccs.AllLeafOccurrences(oRefDef).Count
	If iQty = 0 Then Continue For
	Dim oCustom As PropertySet = oRefDoc.PropertySets("Inventor User Defined Properties")
	Try : oCustom("TotalQty").Value = iQty
	Catch : oCustom.Add(iQty, "TotalQty") : End Try
	Try : oCustom("MainAseembly").Value = sName
	Catch : oCustom.Add(sName, "MainAseembly") : End Try
Next
oTM.End()

 

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
Message 3 of 6

cristianofa8
Explorer
Explorer

Hello
Thanks for the help and sorry for the late feedback. I tested your rule, and it does create the fields, but it doesn't count the correct amount. For example, as you can see from the parts list, part 1 is associated with solid79, and we see that there are two from the parts list (we confirm that it is solid79 and 85, from this image). My intention, in the case of this piece, is to insert the correct quantity, which is four, on the individual drawing sheet. In other words, I wanted the quantity to appear in the field you created (Number of pieces X Number of sets). I think that after having this field filled in correctly, I can make it appear on the individual drawing sheets when I insert the Base View.Inventor1.png

0 Likes
Message 4 of 6

Stakin
Collaborator
Collaborator

1.make a assembly contains 2 sets of your model

2.open bom table

3.enable  part only view

4.add a user property "Qty" in parts only view,and copy the bom qty to it.

 

0 Likes
Message 5 of 6

cristianofa8
Explorer
Explorer

Hello
From what I understand, I would have to copy the assembly as many times as I need. It could be a solution for small sets and small quantities, which I'm not interested in, as I have many projects in which I have to create hundreds of sets and which are heavy designs.

0 Likes
Message 6 of 6

Stakin
Collaborator
Collaborator
Spoiler
1、copy a collumn,only once
2、use another  coding way of parts only bom view .
but it the premise is that your model is a normal model, without substitutes, no ipart, no iassembly, and no component replacements, etc. Considering the above issues, it would be very complicated.
Dim oInvApp As Inventor.Application = ThisApplication
Dim oADoc As AssemblyDocument = TryCast(oInvApp.ActiveDocument, AssemblyDocument)
If oADoc Is Nothing Then Exit Sub
Dim sName As String = IO.Path.GetFileNameWithoutExtension(oADoc.FullFileName)
Dim oOccs As ComponentOccurrences = oADoc.ComponentDefinition.Occurrences
Dim oTM As Transaction = oInvApp.TransactionManager.StartTransaction(oADoc, "Set Props Qty...")
Dim oBOM As BOM = oADoc.ComponentDefinition.BOM
oBOM.PartsOnlyViewEnabled = True
oBOM.GetPartNumberMergeSettings(False, {"" })
Dim oPartsOnlyBOMView As BOMView
oPartsOnlyBOMView = oBOM.BOMViews.Item("Parts Only")
For Each oBomRow As BOMRow In oPartsOnlyBOMView.BOMRows
	Dim iQty As Integer = oBomRow.TotalQuantity
		Dim oDef As ComponentDefinition = oBomRow.ComponentDefinitions.Item(1)
		Dim oDoc As PartDocument = oDef.Document
			If Not oDoc.IsModifiable Then Continue For
		Dim oCustom As PropertySet = oDoc.PropertySets("Inventor User Defined Properties")
		Try : oCustom("BomTotalQty").Value = iQty * 2
		Catch : oCustom.Add(iQty * 2, "BomTotalQty") : End Try
	Try : oCustom("BomMainAseembly").Value = sName
	Catch : oCustom.Add(sName, "BomMainAseembly") : End Try
Next​

 

0 Likes