Hi @mikejones. I am not sure about the true scope of your task, or how you need to specify which view to process, so I wasn't sure how deep you wanted this to go. For instance, do you only want the rule to process the view if it directly references an assembly? Do you only want the part numbers of 'top level' assembly components in that assembly, or do you want it to go down into sub levels, and sub sub levels, etc? Do you only want one part number listed for each 'unique' component (even if multiple components reference same model file), or one for every component, even if there are 10 components referencing the same model file? Below is an example that lets you 'Pick' a view, then just processes the top level components that are not suppressed.
Sub Main
Dim oView As DrawingView = PickDrawingView
Dim oModel As Document = oView.ReferencedDocumentDescriptor.ReferencedDocument
Dim oPNList As New List(Of String)
If oModel.DocumentType <> DocumentTypeEnum.kAssemblyDocumentObject Then Exit Sub
Dim oAModel As AssemblyDocument = oModel
Dim oOccs As ComponentOccurrences = oAModel.ComponentDefinition.Occurrences
If oOccs.Count = 0 Then Exit Sub 'no components to process
For Each oOcc As ComponentOccurrence In oOccs
If oOcc.Suppressed Then Continue For
Dim oPN As String = iProperties.Value(oOcc.Name, "Project", "Part Number")
oPNList.Add(oPN)
Next
oMyPN = InputListBox("", oPNList, "", "Part Numbers")
End Sub
Function PickDrawingView(Optional oPrompt As String = vbNullString) As DrawingView
If oPrompt = "" Then oPrompt = "Select a Drawing View."
oObj = ThisApplication.CommandManager.Pick(SelectionFilterEnum.kDrawingViewFilter, oPrompt)
If IsNothing(oObj) OrElse (TypeOf oObj Is DrawingView = False) Then Return Nothing
Dim oView As DrawingView = oObj
Return oView
End Function
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)