创建对象
 
 

AutoCAD often offers several different ways to create the same graphical object. While the .NET API does not offer the same combinations of creating objects, it does offer a basic object constructor for each object type but also offers overrides for many of the object constructors as well.

在 AutoCAD 中经常有多种不同的方法可以创建相同的图形对象。虽然 .NET API 没有提供同样的创建对象的组合,但是它除为每一个对象类型都提供一个基本的对象构造函数外,也提供了对象构造函数的许多重载版本。

For example, in AutoCAD there are four different ways you can create a circle: (1) by specifying the center and radius, (2) by two points defining the diameter, (3) by three points defining the circumference, or (4) by two tangents and a radius. However, in .NET API there is two creation methods provided to create a circle. One method accepts no parameters, while the second requires a center point, the normal direction for the circle, and a radius.

例如,在 AutoCAD 中创建圆有四种不同方法:(1) 通过指定圆心和半径、(2) 通过定义直径的两点、(3) 通过定义圆周的三点或 (4) 通过两个切点和一个半径。但是,在 .NET API 中只提供了两种创建圆的方法。一个方法不接受任何参数,而第二个需要一个中心点,圆的法线方向和半径。

NoteObjects are created using the New keyword and then appended to the parent object using Add or AppendEntity based on if you are working with a container (symbol table or dictionary) or a BlockTableRecord object.

注意使用 New 关键字创建对象,然后使用 AddAppendEntity 追加到父对象中,使用哪个方法要根据使用的是容器(符号表或字典) 还是块表记录对象。

为新对象指定默认属性值

When a new graphical object is created, the SetDatabaseDefaults method of the new object should be called. The SetDatabaseDefaults method sets the following entity property values based on the current entity values defined in the database of the current document:

当创建一个新图形对象后,应该调用新对象的 SetDatabaseDefaults 方法。 SetDatabaseDefaults 方法根据在当前文档的数据库中定义的当前图元的值设置下列各项图元的属性值。