02-05 控制AutoCAD环境(五) 设置AutoCAD选项

前端之家收集整理的这篇文章主要介绍了02-05 控制AutoCAD环境(五) 设置AutoCAD选项前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。

Set AutoCAD Preferences设置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.

AutoCAD .NET API没有提供那些通过AutoCAD选项对话框访问选项的类和方法。要访问这些选项,必须使用ActiveX® Automation库。我们使用从Application对象的Preferences属性返回的COM对象(来访问这些选项)。

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:

一旦拥有COM对象Preferences,我们就可以访问附属于选项的九个对象,每个对象代表选项对话框的一个选项页。这些对象提供来了访问选项对话框中全部注册表存储选项的功能。通过使用这些对象的属性,我们可以自定义AutoCAD的许多设置。这些对象是:

(这九个对象统称为Perferences对象译者注)

· PreferencesDisplay

· PreferencesDrafting

· PreferencesFiles

· PreferencesOpenSave

· PreferencesOutput

· PreferencesProfiles

· PreferencesSelection

· PreferencesSystem

· PreferencesUser

Access the Preferences object 访问Perferences对象

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

下面示例演示怎样通过COM交互操作访问Perferences对象。

VB.NET

Dim acPrefComObj As AcadPreferences = Application.Preferences

C#

AcadPreferences acPrefComObj = (AcadPreferences)Application.Preferences;

VBA/ActiveX Code Reference

Dim acadPref as AcadPreferences

Set acadPref = ThisDrawing.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.

完成对Perferences对象的引用,我们就可以使用Display属性、 Drafting属性、 Files属性、 OpenSave属性、 Output属性、 Profile属性、 Selection属性、 System属性及User属性来访问指定的Perferences对象。

Set the crosshairs to full screen 设置十字光标为全屏幕

VB.NET

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

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.

// Access the Preferences object

AcadPreferences acPrefComObj = (AcadPreferences)Application.Preferences;

// Use the CursorSize property to set the size of the crosshairs

acPrefComObj.Display.CursorSize = 100;

}

VBA/ActiveX Code Reference

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

Hide the scroll bars 隐藏滚动条

VB.NET

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

C#

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;

}

VBA/ActiveX Code Reference

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

Topics in this section本节主题

· Database Preferences 数据库选项

1、Database Preferences数据库选项

Along with application level preferences,there are drawing based preferences that are accessed with the Options dialog Box that are stored in a drawing file. To access these stored settings,use the appropriate property on the Database object or use the GetSystemVariable and SetSystemVariable methods of the Application object.

除了应用程序级的选项设置外,还有基于图形的选项设置,这些选项设置使用选项对话框访问并存储在图形文件里。要访问这些存储设置,使用Database对象的相应属性,或使用Application对象的GetSystemVariable方法和SetSystemVariable方法

VBA/ActiveX Cross Reference

VBA/ActiveX交叉参考

VBA/ActiveX Class

.NET API Class

DatabasePreferences

Database and drawing based system variables

猜你在找的VB相关文章