设置 AutoCAD 系统配置
 
 

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

.NET API 没有包含所有访问选项的类或方法,这些选项是通过 AutoCAD 选项对话框存储的。访问这些选项是通过 ActiveX® Automation 库来完成的。用户使用COM 对象从 Application 对象的 Preferences 属性返回系统配置。

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

只要用户获得 Preferences COM 对象,就可以访问属于选项的九个对象,每个对象分别代表“选项”对话框中的一个选项卡。通过这些对象可以访问“选项”对话框中所有存储在注册表中的选项,可以使用这些对象的属性来自定义许多 AutoCAD 设置。这些对象包括

访问 Preferences 对象

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

下面的示例说明如果通过 COM Interop 访问 Preferences 对象。

VB.NET

Dim acPrefComObj As AcadPreferences = Application.Preferences

C#

AcadPreferences acPrefComObj = (AcadPreferences)Application.Preferences;
VBA/ActiveX 代码参考

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.

引用 Preferences 对象后,就可以使用 Display、Drafting、Files、OpenSave、Output、Profile、Selection、 System 和 User 属性来访问任何特定的 Preferences 对象。

将十字光标设置为全屏

VB.NET

Imports Autodesk.AutoCAD.ApplicationServices
Imports Autodesk.AutoCAD.Runtime
Imports Autodesk.AutoCAD.Interop
 
<CommandMethod("PrefsSetCursor")> _
Public Sub PrefsSetCursor()
  '' 本例将 AutoCAD 图形十字光标设置为全屏  This example sets the crosshairs of the AutoCAD drawing cursor
  '' to full screen.
 
  '' 访问 Preferences 对象     Access the Preferences object
  Dim acPrefComObj As AcadPreferences = Application.Preferences
 
  '' 使用 CursorSize 属性设置十字光标的尺寸   Use the CursorSize property to set the size of the crosshairs
  acPrefComObj.Display.CursorSize = 100
End Sub

C#

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.
 
  // 访问 Preferences 对象     Access the Preferences object
  AcadPreferences acPrefComObj = (AcadPreferences)Application.Preferences;
 
  // 使用 CursorSize 属性设置十字光标的尺寸   Use the CursorSize property to set the size of the crosshairs
  acPrefComObj.Display.CursorSize = 100;
}
VBA/ActiveX 代码参考

显示屏幕菜单和滚动条

VB.NET

Imports Autodesk.AutoCAD.ApplicationServices
Imports Autodesk.AutoCAD.Runtime
Imports Autodesk.AutoCAD.Interop
 
<CommandMethod("PrefsSetDisplay")> _
Public Sub PrefsSetDisplay()
  '' 本例启动屏幕菜单并禁用滚动条    This example enables the screen menu and disables the scrolls
 
  '' 访问 Preferences 对象     Access the Preferences object
  Dim acPrefComObj As AcadPreferences = Application.Preferences
 
  '' 显示屏幕菜单   Display the screen menu
  acPrefComObj.Display.DisplayScreenMenu = True
 
  '' 禁用滚动条  Disable the scroll bars
  acPrefComObj.Display.DisplayScrollBars = False
End Sub

C#

using Autodesk.AutoCAD.ApplicationServices;
using Autodesk.AutoCAD.Runtime;
using Autodesk.AutoCAD.Interop;
 
[CommandMethod("PrefsSetDisplay")]
public static void PrefsSetDisplay()
{
  // 本例启动屏幕菜单并禁用滚动条    This example enables the screen menu and disables the scrolls
 
  // 访问 Preferences 对象     Access the Preferences object
  AcadPreferences acPrefComObj = (AcadPreferences)Application.Preferences;
 
  // 显示屏幕菜单   Display the screen menu
  acPrefComObj.Display.DisplayScreenMenu = true;
 
  // 禁用滚动条  Disable the scroll bars
  acPrefComObj.Display.DisplayScrollBars = false;
}
VBA/ActiveX 代码参考