Announcements
Attention for Customers without Multi-Factor Authentication or Single Sign-On - OTP Verification rolls out April 2025. Read all about it here.

 

Thank you for your help and response! After all the efforts, I was able to get it working exactly as I originally intended—directly from the top-level assembly.

The main key was to store the entire hierarchical path to the occurrence and then use that same path later when modifying its transparency. This ensured precise targeting of individual parts, even within complex subassembly structures.

Below is a sample iLogic code that sets any selected (or previously stored list of parts in my case) to transparent mode.

 
I hope this solution helps others facing a similar challenge! Let me know if further clarification is needed. :smiling_face_with_smiling_eyes:
 
Sub Main()
    ' Get the active document (assumes an assembly is open)
    Dim oDoc As AssemblyDocument = ThisApplication.ActiveDocument

    ' Get the current selection set
    Dim oSelSet As Inventor.SelectSet = oDoc.SelectSet

    ' Check if any component is selected
    If oSelSet.Count = 0 Then
        MessageBox.Show("No component selected. Please select a component.", "Error")
        Return
    End If

    ' Initialize a variable for the selected component occurrence
    Dim oSelectedOccurrence As ComponentOccurrence = Nothing

    ' Loop through the selection set to find a ComponentOccurrence
    For Each oSelObj In oSelSet
        If TypeOf oSelObj Is ComponentOccurrence Then
            oSelectedOccurrence = oSelObj
            Exit For
        End If
    Next

    ' If no valid component is selected, show an error
    If oSelectedOccurrence Is Nothing Then
        MessageBox.Show("The selected item is not a valid component occurrence.", "Error")
        Return
    End If

    ' Prepare to store hierarchy information
    Dim hierarchyInfo As New System.Text.StringBuilder()
    Dim fullHierarchyID As New System.Text.StringBuilder()

    ' Process the selected component and its parent hierarchy
    Dim currentOccurrence As ComponentOccurrence = oSelectedOccurrence
    Dim level As Integer = 0

    Do While Not currentOccurrence Is Nothing
        ' Indent based on the hierarchy level
        Dim indentation As String = New String(" "c, level * 4) ' 4 spaces per level

        ' Get the occurrence ID
        Dim occurrenceID As String = currentOccurrence.Name ' Occurrence ID

        ' Add the occurrence ID to the hierarchy info
        hierarchyInfo.Insert(0, indentation & occurrenceID & vbNewLine)

        ' Build the full hierarchy path (using ~ as a separator for easier processing)
        fullHierarchyID.Insert(0, currentOccurrence.Name & "~")

        ' Move to the parent occurrence
        currentOccurrence = currentOccurrence.ParentOccurrence
        level += 1
    Loop

    ' Remove the trailing ~ from the full hierarchy ID
    If fullHierarchyID.Length > 0 Then
        fullHierarchyID.Length -= 1
    End If

    ' Set the selected part to transparent
    Try
        oSelectedOccurrence.Transparent = True
        MessageBox.Show("Selected part has been set to transparent." & vbNewLine & 
                        "Hierarchy:" & vbNewLine & hierarchyInfo.ToString() & vbNewLine & 
                        "Full Occurrence ID Path: " & fullHierarchyID.ToString(), "Transparency Set")
    Catch ex As Exception
        MessageBox.Show("Failed to set transparency: " & ex.Message, "Error")
    End Try
End Sub