To use the AutoCAD® .NET API effectively you should be familiar with the AutoCAD entities, objects, and features related to the tasks you want to automate. The greater your knowledge of an object's graphical and nongraphical properties, the easier it is for you to manipulate them through the AutoCAD .NET API. For information specific to the members (methods, functions or properties) of an object in the AutoCAD .NET API, see the AutoCAD .NET Reference Guide. 要想有效利用AutoCAD® .NET API编程接口,必须熟悉AutoCAD自动化任务相关的AutoCAD实体、对象和特性等。你对对象的图形属性和非图形属性知道的越多,使用AutoCAD® .NET API对他们进行操作就越容易。AutoCAD .NET API对象各成员(方法、函数、属性等)的详细信息,请参见AutoCAD .NET参考指南。 Topics in this section: 本节内容:
Understand the AutoCAD Object HierarchyAn object is the main building block of the AutoCAD .NET API. Each exposed object represents a precise part of AutoCAD. There are many different types of objects in the AutoCAD .NET API. Some of the objects represented in the AutoCAD .NET API are: 对象是AutoCAD .NET API的主要构成块。每个公开的对象都精确代表AutoCAD的一个部件。AutoCAD .NET API拥有许多不同类型的对象,例如: ·
Graphical objects such as lines, arcs, text, and dimensions直线、圆弧、文字和标注等图形对象; ·
Style settings such as layers, linetypes, and dimension styles 图层、线型、标注样式等样式设置对象; ·
Organizational structures such as layers, groups, and blocks图层、组、块等图形组织结构对象;
·
The drawing display such as view and viewport 视图、视口等图形显示对象; ·
Even the drawing and the AutoCAD application 乃至图形和AutoCAD应用程序本身也是对象; The objects are structured in a hierarchical fashion, with the AutoCAD Application object at the root. This hierarchical structure is often referred to as the Object Model. The following illustration shows the basic relationships between the Application object and an entity that is in a BlockTableRecord, such as Model space. There are many more objects in the AutoCAD .NET API that are not represented here. 所有对象以AutoCAD的Application对象为根对象,按层次结构方式组织,通常称层次结构为对象模型。下图所示表示了Application对象与BlockTableRecord模型空间内实体的基本关系。这里只列出了AutoCAD .NET API中的部分对象。
1、The Application Object
Application对象 The Application object is the root object of the AutoCAD .NET API. From the Application object, you can access the main window as well as any open drawing. Once you have a drawing, you can then access the objects in the drawing. For information on working with open drawing files (documents) see
The Document Object. Application对象是AutoCAD .NET API的根对象,从Application对象,可以访问AutoCAD主窗口,以及任何打开的图形,并进而访问图形里的各个对象。有关处理打开图形文档的信息,参见Document对象。 For example, the Application object has a DocumentManager property that returns the DocumentCollection object. This object provides access to the the drawings that are currently open in AutoCAD and allows you to create, save and open drawing files. Other properties of the Application object provide access to the application-specific data such as InfoCenter, the main window, and the status bar.The MainWindow property allows access to the application name, size, location, and visibility. 例如,Application对象有一个DocumentManager属性,用来返回DocumentCollection对象,该对象提供了访问当前打开的AutoCAD图形的功能,并允许你创建、保存、打开图形文件。Application对象的其他属性提供了访问应用程序特有数据的功能,像信息中心InfoCenter、主窗口、状态栏等。MainWindow属性允许访问应用程序的名称、主窗口大小、位置及可见性等。 While most of the properties of the Application object allow access to objects in the AutoCAD .NET API, there are some that reference objects in the AutoCAD ActiveX® Automation. These properties include a COM version of the application object (AcadApplication), the menubar (MenuBar), loaded menugroups (MenuGroups), and preferences (Preferences). Application对象的大多数属性允许对AutoCAD .NET API里的对象进行访问,同时也有一些属性是对AutoCAD ActiveX® Automation里的对象(COM对象)的引用,这些属性包括应用程序对象的COM版本(AcadApplication)、菜单栏(MenuBar)、加载的菜单组(MenuGroups)、以及选项设置(Preferences)等。
DocumentManager
Container for all the document objects (there is a document object for each drawing that is open). 所有文档对象的容器(每个打开的图形对应一个文档对象) DocumentWindowCollection
Container for all the document window objects (there is a document window object for each document object in the DocumentManager). 所有文档窗口对象的容器(DocumentManager里每个文档对象有一个文档窗口对象) InfoCenter
Contains a reference to the InfoCenter toolbar. 包含对信息中心工具栏的引用
MainWindow
Contains a reference to the application window object of AutoCAD. 包含对AutoCAD应用程序窗口对象的引用 MenuBar
Contains a reference to the MenuBar COM object for the menubar in AutoCAD. 包含对AutoCAD菜单栏对应的MenuBar COM对象的引用
MenuGroups
Contains a reference to the MenuGroups COM object which contains the customization group name for each loaded CUIx file. 包含对MenuGroups COM对象的引用,菜单组对象包含每个已加载CUIx文件的自定义组名 Preferences
Contains a reference to the Preferences COM object which allows you to modify many of the settings in the Options dialog box. 包含对Preferences COM对象的引用,该对象允许你在选项(Options)对话框里修改许多设置
Publisher
Contains a reference to the Publisher object which is used for publishing drawings. 包含对Publisher对象的引用,该对象用于发布图形 StatusBar
Contains a reference to the StatusBar object for the application window. 包含对应用程序窗口状态栏对象(StatusBar对象)的引用 UserConfiguration
Contains a reference to the UserConfiguration object which allows you to work with user saved profiles. 包含对UserConfiguration对象的引用,该对象允许你处理用户保存的配置信息
|