Set AutoCAD Preferences (.NET)

The AutoCAD .NET API does not contain any classes or methods to access the options in which are accessed through the AutoCAD Options dialog box. Access to these options is done through the ActiveX® Automation library. You use the COM object returned from the Preferences property of the Application object.

Once you have the Preferences COM object, you can then access the nine objects pertaining to the options, each representing a tab in the Options dialog box. These objects provide access to all of the registry-stored options in the Options dialog box. You can customize many of the AutoCAD settings by using properties found on these objects. These objects are

Access the Preferences object

The following example shows how to access the Preferences object through COM interop.

C# Example

AcadPreferences acPrefComObj = (AcadPreferences)Application.Preferences;

After you reference the Preferences object, you can then access any of the specific Preferences objects using the Display, Drafting, Files, OpenSave, Output, Profile, Selection, System, and User properties.

Set the crosshairs to full screen

C# Example

using Autodesk.AutoCAD.ApplicationServices;
using Autodesk.AutoCAD.Runtime;
using Autodesk.AutoCAD.Interop;
 
[CommandMethod("PrefsSetCursor")]
public static void PrefsSetCursor()
{
    // This example sets the crosshairs for the drawing window
    // to full screen.
 
    // Access the Preferences object
    AcadPreferences acPrefComObj = (AcadPreferences)Application.Preferences;
 
    // Use the CursorSize property to set the size of the crosshairs
    acPrefComObj.Display.CursorSize = 100;
}

Hide the scroll bars

C# Example

using Autodesk.AutoCAD.ApplicationServices;
using Autodesk.AutoCAD.Runtime;
using Autodesk.AutoCAD.Interop;
 
[CommandMethod("PrefsSetDisplay")]
public static void PrefsSetDisplay()
{
    // This example disables the scroll bars
 
    // Access the Preferences object
    AcadPreferences acPrefComObj = (AcadPreferences)Application.Preferences;
 
    // Disable the scroll bars
    acPrefComObj.Display.DisplayScrollBars = false;
}