CAD开发者社区

 找回密码
 立即注册

QQ登录

只需一步,快速开始

ObjectARX 开发指南

设置 AutoCAD 首选项 (.NET)

2023-1-1 15:48| 发布者: admin| 查看: 424| 评论: 0|来自: AutoCAD

AutoCAD .NET API 不包含任何用于访问通过“AutoCAD 选项”对话框访问的选项的类或方法。对这些选项的访问是通过 ActiveX®自动化库完成的。使用从应用程序对象的属性返回的 COM 对象。Preferences

拥有首选项 COM 对象后,可以访问与选项相关的九个对象,每个对象代表“选项”对话框中的一个选项卡。这些对象提供对“选项”对话框中所有注册表存储选项的访问。您可以使用在这些对象上找到的特性来自定义许多 AutoCAD 设置。这些对象是

  • 首选项显示
  • 首选项起草
  • 首选项文件
  • 首选项打开保存
  • 首选项输出
  • 首选项配置文件
  • 首选项选择
  • 首选项系统
  • 首选项用户

访问首选项对象

下面的示例演示如何通过 COM 互操作访问首选项对象。

VB.NET

Dim acPrefComObj As AcadPreferences = Application.Preferences

C#

AcadPreferences acPrefComObj = (AcadPreferences)Application.Preferences;

VBA/ActiveX 代码参考

Dim acadPref as AcadPreferences
Set acadPref = ThisDrawing.Application.Preferences

引用“首选项”对象后,可以使用“显示”、“绘图”、“文件”、“打开保存”、“输出”、“配置文件”、“选择”、“系统”和“用户”属性访问任何特定的“首选项”对象。

将十字准线设置为全屏

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 代码参考

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 代码参考

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

路过

雷人

握手

鲜花

鸡蛋

最新评论

QQ|Archiver|CAD开发者社区 ( 苏ICP备2022047690号-1 )

GMT+8, 2024-5-19 16:17

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

返回顶部