Announcements
Attention for Customers without Multi-Factor Authentication or Single Sign-On - OTP Verification rolls out April 2025. Read all about it here.
bespel
in reply to: bespel

Hi!

Do you have any idea why this rule work fine with Inventor in English and i get this error if I use another language Inventor release?

 

Sub Main
    Dim oDoc As AssemblyDocument
    oDoc = ThisApplication.ActiveDocument
    
    Dim oBOM As BOM
    oBOM = oDoc.ComponentDefinition.BOM
    
    Dim oBOMView As BOMView
    oBOMView = oBOM.BOMViews.Item("Parts Only")
    
    Dim Materials As Object
    Materials = CreateObject("Scripting.Dictionary")
    
    Call BOMweightIteration(oBOMView.BOMRows, Materials)

    For Each item In Materials
		If msg = "" Then 
			'msg = "Materials & Mass:" & item & " " & Materials(item) & "kg" & ", "
			msg = item & " " & Materials(item) & "kg" & ", "
		Else
        	msg = msg & item & " " & Materials(item) & "kg" & ","
		End If
    Next
	msg = Left(msg, Len(msg) - 1) 'rimuove l'ultima virgola
	
	Materials = Nothing
	
	'iProperties.Value(System.IO.Path.GetFileName(oDoc.FullFilename), "Custom", "MatlWeights") = msg
	iProperties.Value("Custom", "MatlWeights") = msg
	MsgBox(msg)
End Sub


Private Sub BOMweightIteration(oBOMRows As BOMRowsEnumerator, ByRef Materials As Object)

    Dim i As Long
	Dim oItemWeight As Double
	Dim weight As Double
	
    For i = 1 To oBOMRows.count
        Dim oRow As BOMRow
        oRow = oBOMRows.Item(i)
  
        Dim oCompDef As ComponentDefinition
        oCompDef = oRow.ComponentDefinitions.Item(1)
		
		oRowDoc = oCompDef.Document
		
		Matl = oRowDoc.PropertySets("Design Tracking Properties")("Material").Value
		
		Weight = oCompDef.MassProperties.Mass 'massa in kg come l'unità del database
		oItemWeight = Round(Weight*oRow.TotalQuantity, 2)
		
		'MsgBox(oRowDoc.FullFileName & vbLf & Matl & vbLf & oItemWeight)
		
        If Materials.Exists(Matl) Then
			Materials(Matl) = Materials(Matl) + oItemWeight 'dove  1 = 1 posizione decimale
		Else
			Materials.Add(Matl, oItemWeight)
		End If  
    Next
End Sub 

 cfcf.jpg