|
|
|
|
|
|
AutoCAD
|
Temporarily change the running object snap mode
|
|
Ease of Use
|
Intermediate
|
Version tested with
|
2004, 2005
|
Submitted by:
|
malik641
|
Description:
|
Stores the Object Snaps you have running at Run-Time and resets the Object Snap mode to specific settings. Once the code is run again, the original settings are restored.
|
Discussion:
|
At my job, I design pools. And when I dimension the pool I like to use the Center object snap and everything else off. I usually have a lot more snaps running than just Center, so it becomes tedious to keep checking on/off the same check boxes everytime I dimension a pool. So I made this code as sort of a "switch" for when I dimension pools, specifically. But you can set it to whatever you prefer, just follow the code.
|
Code:
|
instructions for use
|
Option Explicit
Public intSnapSetting As Integer
Public SettingChanged As Boolean
Sub Change_Snaps()
If SettingChanged = False Then
intSnapSetting = ThisDrawing.GetVariable("OSMODE")
SettingChanged = True
End If
If ThisDrawing.GetVariable("OSMODE") = 4 Then
ThisDrawing.SetVariable "OSMODE", intSnapSetting
SettingChanged = False
AutoCAD.Application.ActiveDocument.Utility.Prompt vbCrLf & "Snaps Restored"
Else
ThisDrawing.SetVariable "OSMODE", 4
AutoCAD.Application.ActiveDocument.Utility.Prompt vbCrLf & "Snap set to Center"
End If
End Sub
|
How to use:
|
- Open the VBE (Alt+F11)
- Insert a new module (or use an existing if you prefer) Insert --> Module
- Copy and Paste code into the new module (be sure no duplicates of "Option Explicit" exist)
- Change the Snap Settings in the code to your needs
- Save the project
- Close the VBE
-
- OR
-
- If you are going to download the attachment, then do the following:
- Download file
- Extract the file to any destination (Desktop, My Documents, etc)
- In AutoCAD, type VBALOAD
- Select the file you extracted, press enter
|
Test the code:
|
- In AutoCAD, choose Tools --> Macro --> Macros... (or Alt+F8) and choose "Change_Snaps" to change the Object Snap setting to the desired settings
- Repeat step 1 to restore the previous snap settings
-
- If you like, create a user defined button and in the Button Properties under "Macro Associated with this Button" paste the following (without quotes): "-vbarun Change_Snaps"
|
Sample File:
|
ChangeSnaps.zip 4.28KB
|
Approved by mdmackillop
|
This entry has been viewed 54 times.
|
|