AutoCAD .NET API には、AutoCAD の[オプション]ダイアログ ボックスからアクセスできるオプションにアクセスするためのクラスやメソッドが含まれていません。これらのオプションには、ActiveX® オートメーション ライブラリを使用してアクセスします。Application オブジェクトの Preferences プロパティから返される COM オブジェクトを使用します。
Preferences COM オブジェクトを取得したら、オプションに関連する 9 個のオブジェクトにアクセスできます。これらのオブジェクトは、それぞれが[オプション]ダイアログ ボックスのタブを表しています。これらのオブジェクトで、レジストリに保存されている[オプション]ダイアログ ボックス内のすべてのオプションにアクセスすることができます。これらのオブジェクトにあるプロパティを使用して、AutoCAD のさまざまな設定をカスタマイズできます。オブジェクトは、次のとおりです。
次の例では、COM 相互運用機能を使用して Preferences オブジェクトにアクセスする方法を示します。
Dim acPrefComObj As AcadPreferences = Application.Preferences
AcadPreferences acPrefComObj = (AcadPreferences)Application.Preferences;
Dim acadPref as AcadPreferences Set acadPref = ThisDrawing.Application.Preferences
Preferences オブジェクトの参照後、Display、Drafting、Files、OpenSave、Output、Profile、Selection、System、User プロパティを使って、それぞれの Preferences オブジェクトにアクセスできます。
Imports Autodesk.AutoCAD.ApplicationServices
Imports Autodesk.AutoCAD.Runtime
Imports Autodesk.AutoCAD.Interop
<CommandMethod("PrefsSetCursor")> _
Public Sub PrefsSetCursor()
'' This example sets the crosshairs of the AutoCAD drawing cursor
'' to full screen.
'' Access the Preferences object
Dim acPrefComObj As AcadPreferences = Application.Preferences
'' Use the CursorSize property to set the size of the crosshairs
acPrefComObj.Display.CursorSize = 100
End Sub
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;
}
Sub PrefsSetCursor()
' This example sets the crosshairs of the AutoCAD drawing cursor
' to full screen
' Access the Preferences object
Dim acadPref As AcadPreferences
Set acadPref = ThisDrawing.Application.Preferences
' Use the CursorSize property to set the size of the crosshairs
acadPref.Display.CursorSize = 100
End Sub
Imports Autodesk.AutoCAD.ApplicationServices
Imports Autodesk.AutoCAD.Runtime
Imports Autodesk.AutoCAD.Interop
<CommandMethod("PrefsSetDisplay")> _
Public Sub PrefsSetDisplay()
'' This example disables the scroll bars
'' Access the Preferences object
Dim acPrefComObj As AcadPreferences = Application.Preferences
'' Disable the scroll bars
acPrefComObj.Display.DisplayScrollBars = False
End Sub
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;
}
Sub PrefsSetDisplay()
' This example disables the scroll bars
' Access the Preferences object
Dim acadPref As AcadPreferences
Set acadPref = ThisDrawing.Application.Preferences
' Disable the scroll bars
acadPref.Display.DisplayScrollBars = False
End Sub