Hi @dr.avon0. I do not fully understand your request, but the image does help some. Even the image contains lots of text that I can not select, and can not translate, so I will have to make a few assumptions here. It looks like you want to copy the 'total quantity' of a specific assembly component and write that as the value of that component's Project iProperty value. Unfortunately, I do not even know how to create many of the language specific characters involved in their names while using an English keyboard. So, I created an example iLogic code that you can review and test with. This example is using 3 code routine blocks of code. The 'Main' one is getting the current document, and if it is not an assembly, shows a message, then exits the code. Then it gets the assembly's BOM (Bill of Material), and its 'structured' view of the BOM. Then the second code routine block of code is called to run, and supplies it with the BOMRows collection, so it can 'recursively' iterate through them. As it iterates through them, it calls the third code routine block of code to run on each BOMRow object. When it gets to that last code routine, it first gets the 'total quantity' of that BOMRow. Then it tries to get the Inventor.Document object which that BOMRow references. Then it tries to write that total quantity as the value of that Document's 'Project' iProperty. So, this will do that for every BOMRow, instead of just one specific BOMRow. In order to change its functionality to only effect one specific BOMRow, you can include some code in that last block of code that checks the name of the component of that BOMRow, to see if it is the one you want to work with, then only allow it to proceed if it is a match. I did not include many comments within the code, because I am not fluent in your language, so it would be of no use to you.
Sub Main
Dim oADoc As AssemblyDocument = TryCast(ThisDoc.Document, Inventor.AssemblyDocument)
If oADoc Is Nothing Then
MsgBox("An Assembly Document must be active for this rule to work. Exiting.", vbCritical, "")
Exit Sub
End If
Dim oBOM As Inventor.BOM = oADoc.ComponentDefinition.BOM
oBOM.StructuredViewEnabled = True
oBOM.StructuredViewFirstLevelOnly = True
Dim oBOMView, oStrBOMView As BOMView
For Each oBOMView In oBOM.BOMViews
If oBOMView.ViewType = BOMViewTypeEnum.kStructuredBOMViewType Then
oStrBOMView = oBOMView
Exit For
End If
Next 'oBOMView
If oStrBOMView Is Nothing Then
MsgBox("Structured BOMView not found!", vbCritical, "iLogic")
Exit Sub
End If
RecurseBOMRows(oStrBOMView.BOMRows, AddressOf ProcessBOMRow)
MsgBox("Total Quantity found = " & oTotalQty, , "")
End Sub
Sub RecurseBOMRows(oBOMRows As Inventor.BOMRowsEnumerator, rowProcess As Action(Of Inventor.BOMRow))
If (oBOMRows Is Nothing) OrElse (oBOMRows.Count = 0) Then Exit Sub
For Each oRow As Inventor.BOMRow In oBOMRows
'call other Sub routine to run on this BOMRow
rowProcess(oRow)
'recurse child BOMRows, if any
If (Not oRow.ChildRows Is Nothing) Then
RecurseBOMRows(oRow.ChildRows, rowProcess)
End If
Next
End Sub
Sub ProcessBOMRow(bomRow As Inventor.BOMRow)
Dim sTotalQty As String = bomRow.TotalQuantity
Dim oRowDoc As Inventor.Document = Nothing
Try
oRowDoc = bomRow.ComponentDefinitions.Item(1).Document
Catch
End Try
If (oRowDoc Is Nothing) Then Exit Sub
If (Not oRowDoc.IsModifiable) Then Exit Sub
Try
oRowDoc.PropertySets.Item(3).Item(3).Value = sTotalQty
Catch
End Try
End Sub
If this solved your problem, or answered your question, please click ACCEPT SOLUTION .
Or, if this helped you, please click (LIKE or KUDOS) 👍.
Wesley Crihfield

(Not an Autodesk Employee)