Hi @tjvz85
The batch file in this thread is a part file, but assuming you've copied the rules and form from that file to an assembly file and have all of that working, you could use this example or something similar for the selection rule.
I hope this helps.
Best of luck to you in all of your Inventor pursuits,
Curtis
http://inventortrenches.blogspot.com
Sub Main
Create_Params()
Select_Files()
End Sub
Sub Create_Params()
' Get the active document. Assumes a part document is active.
Dim oDoc As AssemblyDocument
oDoc = ThisApplication.ActiveDocument
' Get the UserParameters collection
Dim userParams As UserParameters
userParams = oDoc.ComponentDefinition.Parameters.UserParameters
'check for parameter and create if not found
Try
oTest = Parameter("Part_Files_List")
Catch
'multi-value text parameter
userParams.AddByValue("Part_Files_List", "< No Files >", UnitsTypeEnum.kTextUnits)
End Try
Parameter.Param("Part_Files_List").IsKey = True
Try
oTest = Parameter("ActionList")
Catch
'multi-value text parameter
userParams.AddByValue("ActionList", "Copy All Custom Parameters", UnitsTypeEnum.kTextUnits)
MultiValue.SetList("ActionList", "Copy All Custom Parameters", "Delete All Custom Parameters")
End Try
Parameter.Param("ActionList").IsKey = True
End Sub
Sub Select_Files()
Dim oAsmCompDef As AssemblyComponentDefinition
oAsmCompDef = ThisApplication.ActiveEditDocument.ComponentDefinition
Dim oPart As ComponentOccurrence
Dim oHighLight As Inventor.HighlightSet
oHighLight = ThisDoc.Document.CreateHighlightSet
Dim oSelect As ComponentOccurrence
Dim oNamesList As New ArrayList
Dim oPrompt1 As String
oPrompt1 = "Select components, then press Escape to continue..."
While True
oSelect = ThisApplication.CommandManager.Pick _
(SelectionFilterEnum.kAssemblyLeafOccurrenceFilter, oPrompt1)
'if nothing then exit
If IsNothing(oSelect) Then Exit While
oNamesList.Add(oSelect.Definition.document.fullfilename)
Call oHighLight.AddItem(oSelect)
End While
'define ArrayList to hold each file name
Dim MyArrayList As New ArrayList
'add existing parameter list items to the array
For Each Item In MultiValue.List("Part_Files_List")
If Item <> "< No Files >" Then
MyArrayList.Add(Item)
Else
End If
Next
'Loop through result strings with For Each.
Dim sFile As String
i = 0
For Each sFile In oNamesList
'check for duplicates then
'add selected files to the array
If Not (MyArrayList.Contains(sFile)) Then
MyArrayList.Add(sFile)
Else
'add to counter for each duplicate file
i = i +1
End If
Next
'add the array to the parameter list
MultiValue.List("Part_Files_List") = MyArrayList
Parameter("Part_Files_List") = myArrayList(0)
If i >0 Then
MessageBox.Show("Note: Duplicate file(s) not added to the list.","iLogic", _
MessageBoxButtons.OK,MessageBoxIcon.Information)
End If
End Sub
