Add Custom Quantity iProperties (Assembly and Part)

Add Custom Quantity iProperties (Assembly and Part)

hw.sheldon
Contributor Contributor
2,254 Views
9 Replies
Message 1 of 10

Add Custom Quantity iProperties (Assembly and Part)

hw.sheldon
Contributor
Contributor

Hello all. Again I am in the midst of editing a code, which I got of a forum (big THANKS to whoever wrote this). The purpose of this code is to add a custom iproperty for quantities on an assembly and assembly components. The main reason I want this is because I can add the quantities to the table on my dwg files with iproperties. I did get the assembly to work except I had to custom add the iproperty name myself (which I can do in the assembly template), so its no big deal.

 

So if I have an assembly and and I need to produce a quantity of 2. As the screenshots show, the Unit_QTY is the number of components in an assembly. Let just say there's 4 in an assembly, so the Total_QTY should equal 8. My issue on this is how to get the Total_QTY on assembly components to the correct name and number. Thanks in advance

0 Likes
Accepted solutions (1)
2,255 Views
9 Replies
Replies (9)
Message 2 of 10

dalton98
Collaborator
Collaborator

You shouldn't need to create a custom iproperty for each part in the assembly if you just want to change a parts list value. Try something like this first:

Dim oDrawingDoc As DrawingDocument = ThisApplication.ActiveDocument

Dim oPartsList As PartsList
oPartsList = oDrawingDoc.ActiveSheet.PartsLists.Item(1)

Dim oRow As PartsListRow
For Each oRow In oPartsList.PartsListRows
	Try
	oRow.Expanded = True
	Catch
	End Try
Next

oPartsList.PartsListColumns.Add(PropertyTypeEnum.kCustomProperty, , "TOTAL QTY")

For Each oRow In oPartsList.PartsListRows
	oRow.Item(6).Value = oRow.Item(2).Value * 2
Next
0 Likes
Message 3 of 10

hw.sheldon
Contributor
Contributor

Thanks for the reply, but I see that this...

For Each oRow In oPartsList.PartsListRows
	oRow.Item(6).Value = oRow.Item(2).Value * 2

has a value of x 2, sometimes I will have assemblies that I have to make 4 of, or sometimes only 1. If you've run the code I edited then you probably saw " Enter the Quantity" pop up. There is where I would enter the quantity I need, now that number has to be multiplied by the number of components in an assembly and thus be my Total_QTY in iproperties.

 

I will not need to add a custom iproperty to every part (expect to my older assembly drawings). I will add the custom iproperty to the ipt template. Thanks!

0 Likes
Message 4 of 10

Pav3L
Advocate
Advocate
Accepted solution

Hi,

I am not a expert in iLogic or in english language... but as I understand your description the code I am using should do exactly that and should help you to modify your code.

It also looks very similar to yours, I think we used the same starting code found in this forum https://forums.autodesk.com/t5/inventor-ilogic-and-vb-net-forum/item-number-to-iproperty/m-p/8849986 

Enter number of pcs to produce, parameter "Product_quantity"

PART_QTY shows number of pcs of the part/assembly/subassembly, basically the same number that is in BOM

ORDER_QTY shows total number of pcs to produce for each part/assembly/subassembly. The formula is ORDER_QTY = Product_quantity * PART_QTY

 

Message 5 of 10

dalton98
Collaborator
Collaborator

@hw.sheldon mb I didn't really read your code. The try/catch trick works for creating new custom iproperties.

Dim oAss As AssemblyDocument = ThisApplication.ActiveDocument

Dim oCustomProp As PropertySet
oCustomProp = oAss.PropertySets.Item(4)

Dim oTotalQty As Integer
oTotalQty = oAss.ComponentDefinition.Occurrences.Count

Dim ItemQuantity As Integer
ItemQuantity = InputBox("Enter the quantity.", "Quantity", ItemQuantity)

'create custom iproperty ^
Try
oCustomProp.Item("Unit_QTY").Value = ItemQuantity
Catch
oCustomProp.Add(ItemQuantity, "Unit_QTY")
End Try

'create total quantity property
Try
oCustomProp.Item("Total_QTY").Value = oTotalQty * ItemQuantity
Catch
oCustomProp.Add(oTotalQty * ItemQuantity, "Total_QTY")
End Try
0 Likes
Message 6 of 10

hw.sheldon
Contributor
Contributor

@Pav3L, this is exactly what I was looking for. Thanks much!!

0 Likes
Message 7 of 10

hw.sheldon
Contributor
Contributor

@dalton98, your code does come very close but it shouldn't multiply the Total_QTY by that much. Also, the code only adds the iproperty to assembly and not the assembly components. Thanks for trying!

0 Likes
Message 8 of 10

dalton98
Collaborator
Collaborator

@hw.sheldon Glad you found a solution. However, I would be cautious when assigning assembly values (i.e. item quantity) to those specific part documents in case they are used on different assemblies.

0 Likes
Message 9 of 10

rhasell
Advisor
Advisor

Hi

The code is cut version of mine, I got the base code from the forum. I use the Project number to differentiate the parts/assemblies from one another, as I don't want re-used parts and assemblies to change the Total QTY upsetting all the drawings.

 

Your issue, however is easier solved in the drawing environment, where you can make use of the parts list multiplier.

 

Have a look here and let me know if you need any help.

https://forums.autodesk.com/t5/inventor-ilogic-and-vb-net-forum/drawing-parts-quantity-ilogic/m-p/79...

 

Reg
2026.3
0 Likes
Message 10 of 10

hw.sheldon
Contributor
Contributor

@rhasell Thanks, I'll take a look at it.

0 Likes