EaBIM一直以来积极响应国家“十二五”推进建筑业信息化的号召,对建筑领域的信息技术开展深入技术交流和探讨!致力于打造“BIM-建筑师-生态技术”三位一体综合资源交流共享平台,希望为BIM与可持续设计理念及技术的普及做出微小的贡献!!!

萧闫子 发表于 2014-1-8 16:05:48

[资料] 控制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·         PreferencesUserAccess the Preferences object 访问Perferences对象
The following example shows how to access the Preferences object through COM interop.下面示例演示怎样通过COM交互操作访问Perferences对象。VB.NETDim acPrefComObj As AcadPreferences = Application.PreferencesC#AcadPreferences acPrefComObj = (AcadPreferences)Application.Preferences;VBA/ActiveX Code ReferenceDim acadPref as AcadPreferencesSet acadPref = ThisDrawing.Application.PreferencesAfter 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.NETImports Autodesk.AutoCAD.ApplicationServicesImports Autodesk.AutoCAD.RuntimeImports Autodesk.AutoCAD.Interop<CommandMethod("PrefsSetCursor")> _Public Sub PrefsSetCursor()'' This example sets the crosshairs of the AutoCAD drawing cursor'' to full screen.'' Access the Preferences objectDim acPrefComObj As AcadPreferences = Application.Preferences   '' Use the CursorSize property to set the size of the crosshairsacPrefComObj.Display.CursorSize = 100End SubC#using Autodesk.AutoCAD.ApplicationServices;using Autodesk.AutoCAD.Runtime;using Autodesk.AutoCAD.Interop;public static void PrefsSetCursor(){// This example sets the crosshairs for the drawing window// to full screen.   // Access the Preferences objectAcadPreferences acPrefComObj = (AcadPreferences)Application.Preferences;   // Use the CursorSize property to set the size of the crosshairsacPrefComObj.Display.CursorSize = 100;}VBA/ActiveX Code ReferenceSub 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 = 100End Sub
Hide the scroll bars 隐藏滚动条
VB.NETImports Autodesk.AutoCAD.ApplicationServicesImports Autodesk.AutoCAD.RuntimeImports Autodesk.AutoCAD.Interop<CommandMethod("PrefsSetDisplay")> _Public Sub PrefsSetDisplay()'' This example disables the scroll bars   '' Access the Preferences objectDim acPrefComObj As AcadPreferences = Application.Preferences   '' Disable the scroll barsacPrefComObj.Display.DisplayScrollBars = FalseEnd SubC#using Autodesk.AutoCAD.ApplicationServices;using Autodesk.AutoCAD.Runtime;using Autodesk.AutoCAD.Interop;public static void PrefsSetDisplay(){// This example disables the scroll bars   // Access the Preferences objectAcadPreferences acPrefComObj = (AcadPreferences)Application.Preferences;   // Disable the scroll barsacPrefComObj.Display.DisplayScrollBars = false;}VBA/ActiveX Code ReferenceSub 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 = FalseEnd 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 ReferenceVBA/ActiveX交叉参考
VBA/ActiveX Class.NET API Class
DatabasePreferencesDatabase and drawing based system variables

页: [1]
查看完整版本: [资料] 控制AutoCAD环境(五) 设置AutoCAD选项