here one exampel @manu.marjanen ->
Start with all component visibility , Default design view
Best Regards Johan G
Class ThisRule
Sub Main()
Dim refs As New List(Of String)
refs.Add("Part1:1")
refs.Add("Part2:2")
refs.Add("Part:3")
CreateDesignViewWithComponents(refs, "Test", False)
refs.Clear()
refs.Add("Part:1")
CreateDesignViewWithComponents(refs, "Test2", False)
End Sub
Public Sub CreateDesignViewWithComponents(RefChainList As List(Of String), nameOfDesignView As String, Optional createLoD As Boolean = False)
Dim odoc As AssemblyDocument = ThisDoc.Document
Dim oAssDef As AssemblyComponentDefinition = odoc.ComponentDefinition
Dim dvrs As DesignViewRepresentations = oAssDef.RepresentationsManager.DesignViewRepresentations
Dim currentDvrName As String = oAssDef.RepresentationsManager.ActiveDesignViewRepresentation.Name
Dim dvr As DesignViewRepresentation
Try
dvrs.Item(nameOfDesignView).Delete
dvr = dvrs.Add(nameOfDesignView)
Catch
dvr = dvrs.Add(nameOfDesignView)
End Try
Dim ReturnedOcc As Inventor.ComponentOccurrence
Dim occColl As ObjectCollection
If ThisApplication Is Nothing Then
occColl = ThisServer.TransientObjects.CreateObjectCollection
Else
occColl = ThisApplication.TransientObjects.CreateObjectCollection
End If
Dim item As String
Dim oCompDef As Inventor.ComponentDefinition = odoc.ComponentDefinition
'define the first level components collection
Dim oCompOcc As Inventor.ComponentOccurrence
'Turn off the visibility of parts in the top level assembly that don't contain the specified text string (StrInput1)
For Each oCompOcc In oCompDef.Occurrences
For Each item In RefChainList
If oCompOcc.Name = item Then
oCompOcc.Visible = True
Try
oCompOcc.SetDesignViewRepresentation("Drawing")
Catch
End Try
Exit For
Else
oCompOcc.Visible = False
End If
Next
Next
dvr.Locked = True
Dim LoDrs As LevelOfDetailRepresentations = oAssDef.RepresentationsManager.LevelOfDetailRepresentations
Dim LoDr As LevelOfDetailRepresentation
If createLoD = True Then
Try
LoDrs.Item(nameOfDesignView).Delete
LoDr = dvr.CopyToLevelOfDetail
Catch
LoDr = dvr.CopyToLevelOfDetail
End Try
End If
dvrs.Item(currentDvrName).Activate
End Sub
End Class