Parts List Total Qty iLogic

Parts List Total Qty iLogic

Anonymous
Not applicable
1,897 Views
5 Replies
Message 1 of 6

Parts List Total Qty iLogic

Anonymous
Not applicable

Here is what I am trying to accomplish. We will have a single assembly with "x" number of parts. The Parts list will populate the qty for each part required to make a single assembly. The single assembly being constructed may be used 5 times in another assembly making the total parts required 5 times what the Parts List shows. I am having trouble figuring out how to populate the Total Qty column automatically from my user input Message box. Hopefully, the attached example will clarify things. The iLogic is a combination of items found online as I am a complete Noob to all things programming. It seems like I need to iterate through each row of the parts list and multiply the  Qty by the TotalQty variable, I just can't figure that step out and I believe it should be able to happen in the same If statement as the Remarks and MK. Any help or thoughts would be appreciated. Any "how to" or reference resources so I can work this out would also be appreciated.

0 Likes
1,898 Views
5 Replies
Replies (5)
Message 2 of 6

rhasell
Advisor
Advisor

Hi

 

There are no attachments. I can possibly help, as I do this all the time.

 

Reg
2026.1
0 Likes
Message 3 of 6

Anonymous
Not applicable

Sorry, I guess I'm missing a step in the attachment process.

 parts_list.png

Try

Dim oDrawDoc As DrawingDocument = ThisDoc.Document

Dim oSheet As Sheet = oDrawDoc.ActiveSheet

Dim oDrawingView As DrawingView = oSheet.DrawingViews(1)

Dim oBorder As Border = oSheet.Border

Dim oPlacementPoint As Point2d

d0 = InputBox("Prompt", "Title", "2")

If oBorder IsNot Nothing Then  

    oPlacementPoint = oBorder.RangeBox.MaxPoint

Else   

    oPlacementPoint = ThisApplication.TransientGeometry.CreatePoint2d(oSheet.Width, oSheet.Height)

End If

Dim oPartsList As PartsList = oSheet.PartsLists.Add(oDrawingView, oPlacementPoint)

Dim invProperty As Inventor.Property

Dim invCustProperty As PropertySet

Dim dVDoc As Document

Dim oPartList As PartsList = oDrawDoc.ActiveSheet.PartsLists.Item(1)

Dim i As Long = 0

oPartList.PartsListRows.Add(i, False)

For i = 1 To oPartList.PartsListRows.Count

oCell  = oPartList.PartsListRows.Item(i).Item("PC")

oCell4  = oPartList.PartsListRows.Item(i).Item("TOTAL QTY")

If oCell.Value = "" Then

       oCell2 = oPartList.PartsListRows.Item(i).Item("REMARKS")

    oCell3 = oPartList.PartsListRows.Item(i).Item("MK")

    dVDoc = ThisApplication.Documents.ItemByName(oPartList.ReferencedDocumentDescriptor.FullDocumentName)

    invCustProperty = dVDoc.PropertySets.Item("Inventor User Defined Properties")

    invProperty = invCustProperty.Item("Weight")

    oCell2.Value = CStr(Round(invProperty.Value,0)) + " LBS EACH"

    invProperty = invCustProperty.Item("NAME")

    oCell3.Value = (invProperty.Value)

    oCell4.Value = d0

 

End If

Next

 

Catch

    MsgBox("Some error")

End Try

0 Likes
Message 4 of 6

rhasell
Advisor
Advisor

Hi

 

I have been trying to analyse your code, but I struggled to understand what you are trying to achieve.

 

There is a lot going on which could probably be done in your templates.

 

The "Cell4=d0" works just fine, its the rest of the code which is confusing.

 

Perhaps I missed something, but try this.

 

Looking at your code, you would like a field for "Total QTY" which shows the manually inputted value.

 

The Parts list must contain the "Total QTY" column.

 

Here is a snipped of code for you:

 

Dim oDrawDoc As DrawingDocument
oDrawDoc = ThisApplication.ActiveDocument
Dim oPartList As PartsList
oPartList = oDrawDoc.ActiveSheet.PartsLists.Item(1)
oASSQTY = InputBox("Enter Quantity of Assemblies Required", "iLogic", 1)
' Iterate through the contents of the parts list.
Dim i As Long
For i = 1 To oPartList.PartsListRows.Count
oCell = oPartList.PartsListRows.Item(i).Item("TOTAL QTY")
oCell.Value = oASSQTY
Next

BUT if you want to change the 'Item QTY' to reflect the total number required for all the assemblies, then you need to go one step further.

 

In the parts list, create the Total QTY column as per above.

Create another column as a multiplier, eg, "ASSY QTY"

Edit the Parts List

Right click on the "TOTAL QTY" column

  ->Format column

Select "Substitution"

 ->Click on Enable Value,Substitution

 ->Browse Properties, and choose "ASSY QTY"

 ->Change the "First Value" to "Sum of Values"

 ->Click OK.

 

I have modified the same code to reflect the new changes:

Dim oDrawDoc As DrawingDocument
oDrawDoc = ThisApplication.ActiveDocument
Dim oPartList As PartsList
oPartList = oDrawDoc.ActiveSheet.PartsLists.Item(1)
oASSQTY = InputBox("Enter Quantity of Assemblies Required", "iLogic", 1)
' Iterate through the contents of the parts list.
Dim i As Long
For i = 1 To oPartList.PartsListRows.Count
oCell = oPartList.PartsListRows.Item(i).Item("ASSY QTY")
oCell.Value = oASSQTY
Next

Note:

In the Image below, I have changed the "QTY" Column Label to "QTY EA"

 

Parts List.PNG

 

Hope this makes sense and I have managed to help you.

 

Try and get this working for yourself before adding it to the main body of the code.

 

Reg
2026.1
Message 5 of 6

jason_bush
Enthusiast
Enthusiast

Interesting thread. I am currently looking for something somewhat similar, but following is how we currently handle this.

 

-Master Assembly contains all unit assemblies to be released for production

-Unit Assemblies containing all parts per unit. Some being unique to the assembly, and others being reused on all assemblies

 -DWG has Assembly sheets that list BOM for all parts needed to make one full assembly. So one line has Part-A needing qty 2, etc

- DWG has part sheets detailing fabrication for all BOM items. So we have a sheet for Part-A, but the parts list is connected to the Master Assembly which has everything being released to the shop. So it might have 10 unit assemblies. As you know, when you attach that parts list to a sheet you get a massive entire list of parts. We then use iLogic to hide all the items on this sheet except for the stock number being detailed on Part-A sheet. It then cycles thru each sheet doing the same hide process except for the item detailed per sheet.

 

Code I'm looking for...when we open this DWG on first launch, I'd like the option to select my master assembly and then have it place that parts list on all sheets. Next part of the routine would run thru the "hide" process noted above. Then we're done. ;D

 

Co-worker posted this on another thread. I'll find it and link so you can see it in action. Pretty slick.

jbush
0 Likes
Message 6 of 6

jason_bush
Enthusiast
Enthusiast

It was on LinkedIn....

Using iLogic to Hide Parts  

jbush
0 Likes