macro to toggle "allow selection in HLR and shaded modes"

Discussion in 'SolidWorks' started by hq105862, Aug 1, 2005.

  1. hq105862

    hq105862 Guest

    I find I am switching between this fellow all the time.

    Does anyone have a macro or a better way to quick toggle this without
    going to tools/options/selection the whole time?

    thanks
     
    hq105862, Aug 1, 2005
    #1
  2. hq105862

    matt Guest

    One curious bit of info is that it toggles itself when you start the
    fillet command, at least in 2005.

    Matt
     
    matt, Aug 1, 2005
    #2
  3. hq105862

    TOP Guest

    I recorded a macro with which to do this, but the API call appears to
    be broke.

    ViewDisplayShadedWithEdges

    This method seems to be orphaned, it isn't in the docs and even though
    I can record it, it doesn't work.
     
    TOP, Aug 2, 2005
    #3
  4. hq105862

    Tin Man Guest

    See code below. It only works for assemly and part files, not drawing
    files.
    Enjoy,
    Ken

    '*********************************************************************************
    'DisplayModeToggle.swp
    '*********************************************************************************

    Option Explicit
    Dim swApp As SldWorks.SldWorks
    Dim swModel As SldWorks.ModelDoc2
    Dim swDraw As SldWorks.DrawingDoc
    Dim swDrawModel As SldWorks.ModelDoc2
    Dim swView As SldWorks.View
    Dim swSelMgr As SldWorks.SelectionMgr
    Dim ModelView As Object
    Dim DisplayModeState As Long
    Dim DrawDisplayMode As Long
    Dim LargeAssemblyModeOn As Boolean
    Dim Response As String

    Sub main()
    Set swApp = Application.SldWorks
    Set swModel = swApp.ActiveDoc

    'ModelView::DisplayMode
    Set ModelView = swModel.ActiveView

    'Get current Display Mode Setting
    DisplayModeState = ModelView.DisplayMode

    'Get current Large Assembly Mode Setting
    LargeAssemblyModeOn = swModel.LargeAssemblyMode

    If swModel.GetType = swDocPART Then
    If DisplayModeState = swViewDisplayMode_Shaded Or DisplayModeState
    = swViewDisplayMode_ShadedWithEdges Then
    ModelView.DisplayMode = swViewDisplayMode_HiddenLinesGrayed
    Else
    ModelView.DisplayMode = swViewDisplayMode_ShadedWithEdges
    End If
    ElseIf swModel.GetType = swDocASSEMBLY Then
    If DisplayModeState = swViewDisplayMode_Shaded Or DisplayModeState
    = swViewDisplayMode_ShadedWithEdges Then
    ModelView.DisplayMode = swViewDisplayMode_HiddenLinesGrayed
    ElseIf LargeAssemblyModeOn Then
    ModelView.DisplayMode = swViewDisplayMode_Shaded
    Else
    ModelView.DisplayMode = swViewDisplayMode_ShadedWithEdges
    End If
    ElseIf swModel.GetType = swDocDRAWING Then
    '***THE BELOW DOESN'T WORK (DRAWINGS)***
    ' Set swSelMgr = swModel.SelectionManager
    ' If swSelMgr.GetSelectedObjectType2(1) <> swSelDRAWINGVIEWS Then
    ' Response = MsgBox("Must pre-select 1 view before running
    routine.", vbExclamation, "Routine Ending")
    ' End
    ' End If
    ' Set swDraw = swModel
    ' swDraw.ViewDisplayHiddengreyed
    ' Response = MsgBox("Toggle to Shaded?", vbYesNo + vbQuestion +
    vbDefaultButton1, "Drawing File")
    ' If Response = vbYes Then
    ' swDraw.ViewDisplayShaded
    ' If Not LargeAssemblyModeOn Then
    ' swDraw.ViewModelEdges
    ' End If
    ' End If
    End If

    swModel.ClearSelection2 True
    End Sub
     
    Tin Man, Aug 2, 2005
    #4
  5. hq105862

    hq105862 Guest

    Thanks Tin Man.

    I have just got these two macro's from my Support people.

    to turn it on:

    Sub main()
    Dim swApp As Object
    Set swApp = Application.SldWorks
    swApp.SetUserPreferenceToggle swEdgesHiddenEdgeSelectionInHLR, Not
    swApp.GetUserPreferenceToggle(swEdgesHiddenEdgeSelectionInHLR)
    End Sub

    to turn it off:

    Dim swApp As Object
    Dim Part As Object
    Dim boolstatus As Boolean
    Dim longstatus As Long, longwarnings As Long
    Dim FeatureData As Object
    Dim Feature As Object
    Dim Component As Object
    Sub main()

    Set swApp = Application.SldWorks

    Set Part = swApp.ActiveDoc
    swApp.SetUserPreferenceToggle swEdgesHiddenEdgeSelectionInHLR, False
    End Sub


    not sure why the setting up info only shows on the one, I just copied
    and pasted for others...
     
    hq105862, Aug 3, 2005
    #5
Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.