@gcross
Working with the drawing:
This iLogic code might suit your needs. It switches the visibility off for the virtual part via part number when a drawing view rep is changed. You might be able to set this up in a drawing template if the view reps and virtual part number are the same.
Correction on previous post I mentioned it might be possible to control the virtual part by changing it from a default to reference Bom Structure per view rep in the assembly. This is not possible.
To Use the below code run from a drawing file as an external or internal rule. Change the Text in red to the Part Number and View Rep Name required. This will only do two variations but if you need more try and follow the pattern and add in more variations.
It is only looking at the view on the current sheet where the parts list is so this may not work if your set up is different, if it doesn't work we can modify to the workflow you are using.
'https://forums.autodesk.com/t5/inventor-forum/ilogic-rule-scanning-partslist-rows/td-p/5184691
'Unable to capture current view rep of drawing, set view rep then check name
'https://forums.autodesk.com/t5/inventor-customization/api-get-the-quot-design-view-representation-quot-name-from-a/td-p/6335821
'Get File Doc
Dim doc As Document
doc = ThisApplication.ActiveDocument
'Check This is a drawing file
If doc.DocumentType <> kDrawingDocumentObject Then
MessageBox.Show("This is Not a drawing file, Exiting.", "iLogic")
Return
End If
'We have the Drawing Doc
Dim oDrawDoc As DrawingDocument
oDrawDoc = doc
'[Change Virtual part and View Rep Here
Dim VirtPart1 As String = "Component1" 'Place virtual part (partnumber)Here
Dim VirtPart2 As String = "Component2" 'Place virtual part (partnumber)Here
Dim ViewRepName1 As String = "1" 'Place view rep Name Here
Dim ViewRepName2 As String = "2" 'Place view rep Name Here
']
' Set a reference to the drawing document.
' This assumes a drawing document is active.
' Set a reference to the active sheet
Dim oActiveSheet As Sheet
oActiveSheet = oDrawDoc.ActiveSheet
Dim oDrawingView As DrawingView
'[Look through each view in the sheet in order to detect active view rep
For Each oDrawingView In oActiveSheet.DrawingViews
''Set Drawing View Rep by providing a string value
' oDrawingView.SetDesignViewRepresentation("2", True) 'Relating to Assembly View rep'True =Associative,False = Not Associative
Try
ActViewRepDraw = ActiveSheet.View(oDrawingView.Name).View.ActiveDesignViewRepresentation
'MessageBox.Show(ActViewRepDraw, "iLogic-Active View Rep")
Catch
MessageBox.Show("Associativity of view is switched off!Cannot read Active View rep!", "iLogic")
End Try
Next
']
'[Control the Partslist Item Visibilty
' Set a reference to the first parts list on the active sheet.
' This assumes that a parts list is on the active sheet.
Dim oPartList As PartsList
oPartList = oDrawDoc.ActiveSheet.PartsLists.Item(1)
' Iterate through the contents of the parts list.
Dim i As Long
For i = 1 To oPartList.PartsListRows.Count
'look at only the part number column
oCell = oPartList.PartsListRows.Item(i).Item("PART NUMBER")
If ActViewRepDraw = ViewRepName1
'find a specific value
If oCell.Value = VirtPart2 Then
'hide the row
oPartList.PartsListRows.Item(i).Visible = False
Else
oPartList.PartsListRows.Item(i).Visible = True
End If
ElseIf ActViewRepDraw = ViewRepName2
'find a specific value
If oCell.Value = VirtPart1 Then
'hide the row
oPartList.PartsListRows.Item(i).Visible = False
Else
oPartList.PartsListRows.Item(i).Visible = True
End If
Else
MessageBox.Show("Drawing view rep not changing PartList", "iLogic")
End If
Next
']
'Homework It was raining
'[[Get Model View Reps
'Dim oAssyDoc As AssemblyDocument
'oAssyDoc = ThisDrawing.ModelDocument
'Dim oAsmCompDef As AssemblyComponentDefinition
'oAsmCompDef = oAssyDoc.ComponentDefinition
''define view rep collection
'Dim oViewReps As DesignViewRepresentations
'oViewReps = oAsmCompDef.RepresentationsManager.DesignViewRepresentations
''define view rep
'Dim oViewRep As DesignViewRepresentation
''define an arraylist to hold the list of view rep names
'Dim NameList As New ArrayList()
''create a list of view reps
'For Each oViewRep In oViewReps
' NameList.Add(oViewRep.Name)
'Next
''ViewRepName = InputListBox("Prompt", NameList, d0, Title := "Title", ListName := "List")
''MultiValue.SetValueOptions(True, DefaultIndex := 0)
''Put them In a Parameter If needed To control By form
''MultiValue.List("ViewRep") = NameList
''Active view rep Of the model
'ActViewRepModel = oAsmCompDef.RepresentationsManager.ActiveDesignViewRepresentation
'MessageBox.Show(ActViewRep.Name, "iLogic")
']
If this solved a problem, please click (accept) as solution.
Or if this helped you, please, click (like)
Regards
Alan