AnsweredAssumed Answered

combine ''view'' items with a macro button (on/off)

Question asked by Menno Geefshuysen on May 18, 2017
Latest reply on May 18, 2017 by Menno Geefshuysen

I have a macro that was a solution on a problem I had yesterday, the problem for me was to add a if command in a macro.

If Command Macro



'This macro will toggle the user setting for selection of hidden edges in HLV &
'wireframe modes.
'Precondition: A currently running session of Solidworks.
'Postcondition: The user setting for hidden edge selection in HLV/wirframe _
                has been toggled and the updated setting can be seen in _
                the status bar.

Dim swApp As SldWorks.SldWorks
Dim swStatus As SldWorks.Frame

Sub main()

Set swApp = Application.SldWorks
Set swStatus = swApp.Frame

' Case Selection of hidden edges - Allow selection in wireframe and HLV modes
If swApp.GetUserPreferenceToggle(swUserPreferenceToggle_e.swEdgesHiddenEdgeSelectionInWireframe) = 1 Then
    swApp.SetUserPreferenceToggle swUserPreferenceToggle_e.swEdgesHiddenEdgeSelectionInWireframe, False
    swStatus.SetStatusBarText "Hidden Edge Selection = OFF"
    swApp.SetUserPreferenceToggle swUserPreferenceToggle_e.swEdgesHiddenEdgeSelectionInWireframe, True
    swStatus.SetStatusBarText "Hidden Edge Selection = ON"
End If

End Sub


Now I want to combine the view options show/hide Origin and Coordinate system the same way, with the same macro structure.


what I captured when recording a macro was:

Dim swApp As Object

Dim Part As Object
Dim boolstatus As Boolean
Dim longstatus As Long, longwarnings As Long

Sub main()

Set swApp = Application.SldWorks

Set Part = swApp.ActiveDoc
boolstatus = Part.SetUserPreferenceToggle(swUserPreferenceToggle_e.swDisplayCoordSystems, True)
End Sub


with this information I think I can go proceed to investigate the difference between those and get to know more about the coding.

Please help me out Solidworks Masters of the World!