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

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

Reply to
hq105862
Loading thread data ...

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

Matt

Reply to
matt

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.

Reply to
TOP

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

Reply to
Tin Man

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...

Reply to
hq105862

PolyTech Forum website is not affiliated with any of the manufacturers or service providers discussed here. All logos and trade names are the property of their respective owners.