创建 Point 对象
 
 

Point objects can be useful, for example, as node or reference points that you can snap to and offset objects from. You can set the style of the point and its size relative to the screen or in absolute units.

Point 对象非常有用,例如,可将 Point 对象用作捕捉的节点或者偏移对象的参考点。可以相对于屏幕或采用绝对单位来设置点的样式和大小。

The Pdmode and Pdsize properties of the Database object control the appearance of Point objects. A value of 0, 2, 3, and 4 for Pdmode specify a figure to draw through the point. A value of 1 selects nothing to be displayed.

数据库对象的 PdmodePdsize 属性控制 Point 对象的外观。PDMODE 值 0、2、3 和 4 指定要通过点绘制的图形。值为 1 时表示不显示任何图形。

Adding 32, 64, or 96 to the previous value selects a shape to draw around the point in addition to the figure drawn through it:

在上述值上加上 32、64 或 96 表示除了绘制通过点的图形以外,还在点的周围绘制形状:

Pdsize controls the size of the point figures, except for when Pdmode is 0 and 1. A 0 setting generates the point at 5 percent of the graphics area height. Setting Pdsize to a positive value specifies an absolute size for the point figures. A negative value is interpreted as a percentage of the viewport size. The size of all points is recalculated when the drawing is regenerated.

PDSIZE 控制点图形的尺寸,PDMODE 值为 0 和 1 时除外。如果设置为 0,则点图形的高度是图形区高度的 5%。正的 PDSIZE 值指定点图形的绝对尺寸。负值将解释为视口大小的百分比。重生成图形时将重新计算所有点的大小。

After you change Pdmode and Pdsize, the appearance of existing points changes the next time the drawing is regenerated.

更改 PDMODE 和 PDSIZE 后,现有点的外观将在下次重新生成图形时改变。

创建 Point 对象并更改其外观

The following example creates a Point object in Model space at the coordinate (5, 5, 0). The Pdmode and Pdsize properties are then updated.

下例在模型空间中创建坐标为 (5,5,0) 的 Point 对象,随后将更新 PDMODE 和 PDSIZE 属性。

VB.NET

Imports Autodesk.AutoCAD.Runtime
Imports Autodesk.AutoCAD.ApplicationServices
Imports Autodesk.AutoCAD.DatabaseServices
Imports Autodesk.AutoCAD.Geometry
 
<CommandMethod("AddPointAndSetPointStyle")> _
Public Sub AddPointAndSetPointStyle()
  '' 获得当前文档和数据库   Get the current document and database
  Dim acDoc As Document = Application.DocumentManager.MdiActiveDocument
  Dim acCurDb As Database = acDoc.Database
 
  ''启动一个事务   Start a transaction
  Using acTrans As Transaction = acCurDb.TransactionManager.StartTransaction()
 
      '' 以只读方式打开块表   Open the Block table for read
      Dim acBlkTbl As BlockTable
      acBlkTbl = acTrans.GetObject(acCurDb.BlockTableId, OpenMode.ForRead)
 
      '' 以写方式打开模型空间块表记录   Open the Block table record Model space for write
      Dim acBlkTblRec As BlockTableRecord
      acBlkTblRec = acTrans.GetObject(acBlkTbl(BlockTableRecord.ModelSpace), _
                                      OpenMode.ForWrite)
 
      '' 在模型空间中创建一个坐标为(4,3,0)的点   Create a point at (4, 3, 0) in Model space
      Dim acPoint As DBPoint = New DBPoint(New Point3d(4, 3, 0))
 
      acPoint.SetDatabaseDefaults()
 
      '' 添加新对象到块表记录和事务中   Add the new object to the block table record and the transaction
      acBlkTblRec.AppendEntity(acPoint)
      acTrans.AddNewlyCreatedDBObject(acPoint, True)
 
      '' 在图形中设置所有点对象的样式   Set the style for all point objects in the drawing
      acCurDb.Pdmode = 34
      acCurDb.Pdsize = 1
 
      '' 保存新对象到数据库中   Save the new object to the database
      acTrans.Commit()
  End Using
End Sub

C#

using Autodesk.AutoCAD.Runtime;
using Autodesk.AutoCAD.ApplicationServices;
using Autodesk.AutoCAD.DatabaseServices;
using Autodesk.AutoCAD.Geometry;
 
[CommandMethod("AddPointAndSetPointStyle")]
public static void AddPointAndSetPointStyle()
{
  // 获得当前文档和数据库   Get the current document and database
  Document acDoc = Application.DocumentManager.MdiActiveDocument;
  Database acCurDb = acDoc.Database;
 
  // 启动一个事务  Start a transaction
  using (Transaction acTrans = acCurDb.TransactionManager.StartTransaction())
  {
      // 以只读方式打开块表   Open the Block table for read
      BlockTable acBlkTbl;
      acBlkTbl = acTrans.GetObject(acCurDb.BlockTableId,
                                   OpenMode.ForRead) as BlockTable;
 
      // 以写方式打开模型空间块表记录   Open the Block table record Model space for write
      BlockTableRecord acBlkTblRec;
      acBlkTblRec = acTrans.GetObject(acBlkTbl[BlockTableRecord.ModelSpace],
                                      OpenMode.ForWrite) as BlockTableRecord;
 
      // 在模型空间中创建一个坐标为(4,3,0)的点   Create a point at (4, 3, 0) in Model space
      DBPoint acPoint = new DBPoint(new Point3d(4, 3, 0));
 
      acPoint.SetDatabaseDefaults();
 
      // 添加新对象到块表记录和事务中   Add the new object to the block table record and the transaction
      acBlkTblRec.AppendEntity(acPoint);
      acTrans.AddNewlyCreatedDBObject(acPoint, true);
 
      // 在图形中设置所有点对象的样式   Set the style for all point objects in the drawing
      acCurDb.Pdmode = 34;
      acCurDb.Pdsize = 1;
 
      // 保存新对象到数据库中   Save the new object to the database
      acTrans.Commit();
  }
}
VBA/ActiveX 代码参考