@JBerns
Actually, all we can see from 00:10 in your video is that the variable iProps is declared as an object of type IiParameters. That's why intellisense is giving you suggestions. It still doesn't have a value, you've only declared what type of object it is. The value is actually set from the iLogic rule before the form is shown. This specific object of type IiParameters has to be retrieved from iLogic in Inventor (I hope this makes sense), thats why we have to assign the value from the iLogic rule, because in that environment it already exists as iProperties.
Did you change the row of code in the iLogic rule from:
myForm.iProps = iProps 'IiProperties
To:
myForm.iProps = iProperties
If you did, then I'm very confused as to why it doesnt work 🤔
In other words, this iLogic rule, in combination with the DLL from my rar-archive should work?
AddReference "C:\Users\jberns\source\repos\EditFourBlocks\EditFourBlocks\bin\Debug\EditFourBlocks.dll"
Private Sub Main()
' Dim oAsmLibMat_Array, oLib_Array1, oLib_Array2, oLib_Array3, oLib_Array4 As New ArrayList
Dim oAsmLibMat_List As New Generic.List(Of String)
Dim oAssetLib As AssetLibrary
Dim oAsset As Asset
For Each oAssetLib In ThisApplication.AssetLibraries
' For Each oAsset In oAssetLib.AppearanceAssets
If oAssetLib.DisplayName = "NMC Materials" Then
Dim material As MaterialAsset
For Each material In oAssetLib.MaterialAssets
' oAsmLibMat_Array.Add(material.DisplayName)
oAsmLibMat_List.Add(material.DisplayName)
Next
End If
Next
Dim oLib_List1 = Clone(oAsmLibMat_List)
Dim oLib_List2 = Clone(oAsmLibMat_List)
Dim oLib_List3 = Clone(oAsmLibMat_List)
Dim oLib_List4 = Clone(oAsmLibMat_List)
Using myForm As New EditFourBlocks.iLogic
myForm.Parameter = Parameter
myForm.iLogicVB = iLogicVb
myForm.iProps = iProperties 'IiProperties
'myForm.oPartDoc = oPartDoc
myForm.oBox1Length = Parameter("Box_2020-03-12_01:1", "Length")
myForm.oBox1Width = Parameter("Box_2020-03-12_01:1", "Width")
myForm.oBox1Height = Parameter("Box_2020-03-12_01:1", "Height")
myForm.oBox2Length = Parameter("Box_2020-03-12_02:1", "Length")
myForm.oBox2Width = Parameter("Box_2020-03-12_02:1", "Width")
myForm.oBox2Height = Parameter("Box_2020-03-12_02:1", "Height")
myForm.oBox3Length = Parameter("Box_2020-03-12_03:1", "Length")
myForm.oBox3Width = Parameter("Box_2020-03-12_03:1", "Width")
myForm.oBox3Height = Parameter("Box_2020-03-12_03:1", "Height")
myForm.oBox4Length = Parameter("Box_2020-03-12_04:1", "Length")
myForm.oBox4Width = Parameter("Box_2020-03-12_04:1", "Width")
myForm.oBox4Height = Parameter("Box_2020-03-12_04:1", "Height")
' Define the material lists
Dim Mats01 As New Generic.List(Of String)
Dim Mats02 As New Generic.List(Of String)
Dim Mats03 As New Generic.List(Of String)
Dim Mats04 As New Generic.List(Of String)
Mats01 = oLib_List1
Mats02 = oLib_List2
Mats03 = oLib_List3
Mats04 = oLib_List4
' Define part names
Dim sPartNm1 As String = "Box_2020-03-12_01.ipt"
Dim sPartNm2 As String = "Box_2020-03-12_02.ipt"
Dim sPartNm3 As String = "Box_2020-03-12_03.ipt"
Dim sPartNm4 As String = "Box_2020-03-12_04.ipt"
' ' Define materials
' Dim strMaterialNm1 As String = "HR"
' Dim strMaterialNm2 As String = "304 SS"
' Dim strMaterialNm3 As String = "ALUM-6061"
' Dim strMaterialNm4 As String = "UHMW, GREEN"
' Get the active assembly.
Dim oAsmDoc As AssemblyDocument
oAsmDoc = ThisApplication.ActiveDocument
' Change material
Dim oDoc As Document
For Each oDoc In oAsmDoc.AllReferencedDocuments
' Check to see if this is a part
If oDoc.DocumentType = kPartDocumentObject Then
Dim oPartDoc2 As PartDocument
oPartDoc2 = oDoc
Select Case oPartDoc2.DisplayName
Case sPartNm1
'myForm.oBox1Matl = strMaterialNm1
myForm.oBox1Matl = iProperties.MaterialOfComponent("Box_2020-03-12_01:1")
oLib_List1 = AddPartDocMatls2(oPartDoc2, oLib_List1)
oLib_List1.Sort
myForm.oBox1Doc = oDoc
Case sPartNm2
'myForm.oBox2Matl = strMaterialNm2
myForm.oBox2Matl = iProperties.MaterialOfComponent("Box_2020-03-12_02:1")
oLib_List2 = AddPartDocMatls2(oPartDoc2, oLib_List2)
oLib_List2.Sort
myForm.oBox2Doc = oDoc
Case sPartNm3
'myForm.oBox3Matl = strMaterialNm3
myForm.oBox3Matl = iProperties.MaterialOfComponent("Box_2020-03-12_03:1")
oLib_List3 = AddPartDocMatls2(oPartDoc2, oLib_List3)
oLib_List3.Sort
myForm.oBox3Doc = oDoc
Case sPartNm4
'myForm.oBox4Matl = strMaterialNm4
myForm.oBox4Matl = iProperties.MaterialOfComponent("Box_2020-03-12_04:1")
oLib_List4 = AddPartDocMatls2(oPartDoc2, oLib_List4)
oLib_List4.Sort
myForm.oBox4Doc = oDoc
End Select
End If
Next
Break
myForm.oBox1MatList = oLib_List1
myForm.oBox2MatList = oLib_List2
myForm.oBox3MatList = oLib_List3
myForm.oBox4MatList = oLib_List4
' Show the dialog
myForm.ShowDialog
' if user cancelled, do nothing
If myForm.didCancel Then Return
' pass the form values back to Inventor
RuleParametersOutput()
Parameter("Box_2020-03-12_01:1", "Length") = myForm.oBox1Length
Parameter("Box_2020-03-12_01:1", "Width") = myForm.oBox1Width
Parameter("Box_2020-03-12_01:1", "Height") = myForm.oBox1Height
Parameter("Box_2020-03-12_02:1", "Length") = myForm.oBox2Length
Parameter("Box_2020-03-12_02:1", "Width") = myForm.oBox2Width
Parameter("Box_2020-03-12_02:1", "Height") = myForm.oBox2Height
Parameter("Box_2020-03-12_03:1", "Length") = myForm.oBox3Length
Parameter("Box_2020-03-12_03:1", "Width") = myForm.oBox3Width
Parameter("Box_2020-03-12_03:1", "Height") = myForm.oBox3Height
Parameter("Box_2020-03-12_04:1", "Length") = myForm.oBox4Length
Parameter("Box_2020-03-12_04:1", "Width") = myForm.oBox4Width
Parameter("Box_2020-03-12_04:1", "Height") = myForm.oBox4Height
' Parameter("Box1Length") = myForm.oBox1Length
' Parameter("Box1Width") = myForm.oBox1Width
' Parameter("Box1Height") = myForm.oBox1Height
' Parameter("Box2Length") = myForm.oBox2Length
' Parameter("Box2Width") = myForm.oBox2Width
' Parameter("Box2Height") = myForm.oBox2Height
' Parameter("Box3Length") = myForm.oBox3Length
' Parameter("Box3Width") = myForm.oBox3Width
' Parameter("Box3Height") = myForm.oBox3Height
' Parameter("Box4Length") = myForm.oBox4Length
' Parameter("Box4Width") = myForm.oBox4Width
' Parameter("Box4Height") = myForm.oBox4Height
' MsgBox("Box1 material: " & myForm.cboBox1Matl.selectedtext)
InventorVb.DocumentUpdate()
End Using
End Sub
Private Function AddPartDocMatls2(LocPartDoc As PartDocument, MatList As Generic.List(Of String))
' Dim TempMatList As Generic.List(Of String) = MatList
Dim oPartAsset As Asset
For Each oPartAsset In LocPartDoc.MaterialAssets
'Add material to list if it is not already in the list
' If Not TempMatList.Contains(oPartAsset.DisplayName) Then
' TempMatList.Add(oPartAsset.DisplayName)
' End If
If Not MatList.Contains(oPartAsset.DisplayName) Then
MatList.Add(oPartAsset.DisplayName)
End If
Next
Return MatList
End Function
Public Function Clone(listToClone As List(Of String)) As List(Of String)
Return listToClone.Select(Function(s)(s.Clone())).Cast(Of String).ToList()
End Function