AutoCAD .NET API には、AutoCAD の[オプション]ダイアログ ボックスからアクセスできるオプションにアクセスするためのクラスやメソッドが含まれていません。これらのオプションには、ActiveX® オートメーション ライブラリを使用してアクセスします。Application オブジェクトの Preferences プロパティから返される COM オブジェクトを使用します。
Preferences COM オブジェクトを取得したら、オプションに関連する 9 個のオブジェクトにアクセスできます。これらのオブジェクトは、それぞれが[オプション]ダイアログ ボックスのタブを表しています。これらのオブジェクトで、レジストリに保存されている[オプション]ダイアログ ボックス内のすべてのオプションにアクセスすることができます。これらのオブジェクトにあるプロパティを使用して、AutoCAD のさまざまな設定をカスタマイズできます。オブジェクトは、次のとおりです。
次の例では、COM 相互運用機能を使用して Preferences オブジェクトにアクセスする方法を示します。
AcadPreferences acPrefComObj = (AcadPreferences)Application.Preferences;
Preferences オブジェクトの参照後、Display、Drafting、Files、OpenSave、Output、Profile、Selection、System、User プロパティを使って、それぞれの Preferences オブジェクトにアクセスできます。
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;
}
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;
}