Keyboard shortcuts for transparent component

Hi all

A little practical question, on Solidworks there is the keyboard shortcut " tab " to " hide a component ". Is there, or is it possible to set a keyboard shortcut to " make a component transparent "

Thank you

Hello

No ability to assign a key to this function (checked on SW2023 and 2024).

1 Like

Hello

Following this post (https://forum.mycad.visiativ.com/t/affecter-un-raccourci-clavier-a-un-cmdbutton-dans-un-uf/112019/3) the simple idea came to me to use this method to maybe solve your problem, and finally serve us all:

Here are the 2 macros, one to make transparent, the other to make opaque:
Macros_CompTransparent-Opaque.zip (15.2 KB)


CompTransparent.swp

' *****************
' 01/07/25 by Sylk
' *****************
'*** prérequis: assemblage ouvert et au moins un composant sélectionné.

Dim swApp, Part As Object
Dim boolstatus As Boolean
Dim longstatus, longwarnings As Long
Sub main()
    Set swApp = Application.SldWorks
    Set Part = swApp.ActiveDoc
    If Part Is Nothing Or Part.GetType <> swDocASM Then
        If MsgBox("Le document doit être un assemblage. S'il n'est simplement pas encore enregistré, vous pouvez choisir d'ignorer cet avertissement.", vbYesNo + vbInformation) = vbNo Then Exit Sub
    End If
    boolstatus = Part.SetComponentTransparent(True)
End Sub


CompOpaque.swp

' *****************
' 01/07/25 by Sylk
' *****************
'*** prérequis: assemblage ouvert et au moins un composant sélectionné.

Dim swApp, Part As Object
Dim boolstatus As Boolean
Dim longstatus, longwarnings As Long
Sub main()
    Set swApp = Application.SldWorks
    Set Part = swApp.ActiveDoc
    If Part Is Nothing Or Part.GetType <> swDocASM Then
        If MsgBox("Le document doit être un assemblage. S'il n'est simplement pas encore enregistré, vous pouvez choisir d'ignorer cet avertissement.", vbYesNo + vbInformation) = vbNo Then Exit Sub
    End If
    boolstatus = Part.SetComponentTransparent(False)
End Sub

Continuation of the tutorial to follow...