AutoCAD OSMODE System Variable

Cover.jpg

Introduction

 

Object Snap, commonly known as Osnap, is one of AutoCAD's most frequently used features. It enables users to precisely align geometry by snapping to key points like endpoints, midpoints, centers, and intersections, significantly aiding in accurate drawing and design.

 

While many users are familiar with turning object snaps on and off via the user interface, did you know that AutoCAD uses a system variable called OSMODE to control which object snaps are active?

 

What Is OSMODE?

 

The OSMODE system variable in AutoCAD controls which Object Snap (OSNAP) modes are currently active. Each OSNAP option is assigned a unique number, and when you turn on multiple snaps, AutoCAD adds their values together to store them as a single bitcode.

 

Here's a table that shows the object snaps and their corresponding values:

 

Value

Description

0

None

1

Endpoint

2

Midpoint

4

Center

8

Node

16

Quadrant

32

Intersection

64

Insertion

128

Perpendicular

256

Tangent

512

Nearest

1024

Geometric center

2048

Apparent Intersection

4096

Extension

8192

Parallel

16384

Suppresses the current running object snaps

 

How to Use OSMODE

 

To control object snaps using the command line: Type OSMODE in the AutoCAD command line and press Enter.

Enter a numeric value that represents your desired combination of object snaps.

 

For example, if you enter 1, only the Endpoint snap will be active.

 

If you want to enable multiple snaps, say Endpoint, Midpoint, Center, Perpendicular, and Geometric Center, add their corresponding values: 1 + 2 + 4 + 128 + 1024 = 1159

Entering 1159 for OSMODE will turn all five snaps ON at once.

 

Reference Image 1 - OSMODE.png

 

Reference Image 2 - OSnap.png

 

Why Use OSMODE?

 

Using OSMODE is especially useful when automating tasks with scripts, LISP routines, or simply when you want to quickly switch between custom snap configurations without clicking through the UI every time.

 

One of the best ways to streamline your workflow is by converting your frequently used OSNAP settings into a custom command using the Customize User Interface (CUI).

 

Create a Custom OSNAP Command

 

1. Open the Customize User Interface by typing CUI on the command line.

2. Create a new command.

3. Assign the command a custom name, such as MyOsnap

4. Enter the following code under Macro: ^C^C_OSMODE;1159;

5. This macro sets OSMODE to a specific value (e.g., 1159), which corresponds to your desired OSNAP combination.

 

Reference Image 3 - CUI.png

 

6. Drag and drop your new command to the Tool Palette for quick access. Now, with a single click, you can instantly apply your custom snap settings.

 

 

Bonus: Add It to the Ribbon

 

Want even easier access? Add your custom OSNAP command to the ribbon!

Check out my blog: [A Guide to Ribbon Customization in AutoCAD] for a step-by-step walkthrough on how to enhance your AutoCAD interface with personalized commands.