创建角度标注
 
 

Angular dimensions measure the angle between two lines or three points. For example, you can use them to measure the angle between two radii of a circle. The dimension line forms an arc. Angular dimensioms are created by creating instances of LineAngularDimension2 or Point3AngularDimension objects.

角度标注用于测量两条线或三个点之间的角度。例如,用户可以使用它们来测量圆的两个半径之间的角度。角度标注是通过创建 LineAngularDimension2 或 Point3AngularDimension 对象的实例来创建的。

When you create an instance of a LineAngularDimension2 or Point3AngularDimension object, the constructors can optionally accept a set parameters. The following parameters can be supplied when you create a new LineAngularDimension2 object:

当用户创建 LineAngularDimension2 或 Point3AngularDimension 对象的实例后, 构造函数可以随意的接受一组参数。当创建一个新的LineAngularDimension2 对象时,可以提供下面的参数:

The following parameters can be supplied when you create a new Point3AngularDimension object:

当创建一个新的 Point3AngularDimension 对象时,可以提供下面的参数:

For additional information about creating angular dimensions, see “Create Angular Dimensions” in the AutoCAD User's Guide.

有关创建角度标注的详细信息,请参见《AutoCAD 用户手册》中的“创建角度标注”。

创建角度标注

This example creates an angular dimension in model space.

本例在模型空间中创建一个角度标注。

VB.NET

Imports Autodesk.AutoCAD.Runtime
Imports Autodesk.AutoCAD.ApplicationServices
Imports Autodesk.AutoCAD.DatabaseServices
Imports Autodesk.AutoCAD.Geometry
 
<CommandMethod("CreateAngularDimension")> _
Public Sub CreateAngularDimension()
  '' 获得当前数据库  Get the current 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)
 
      '' 创建一个角度标注  Create an angular dimension
      Dim acLinAngDim As LineAngularDimension2 = New LineAngularDimension2()
      acLinAngDim.SetDatabaseDefaults()
      acLinAngDim.XLine1Start = New Point3d(0, 5, 0)
      acLinAngDim.XLine1End = New Point3d(1, 7, 0)
      acLinAngDim.XLine2Start = New Point3d(0, 5, 0)
      acLinAngDim.XLine2End = New Point3d(1, 3, 0)
      acLinAngDim.ArcPoint = New Point3d(3, 5, 0)
      acLinAngDim.DimensionStyle = acCurDb.Dimstyle
 
      '' 添加新对象到模型空间和事务中   Add the new object to Model space and the transaction
      acBlkTblRec.AppendEntity(acLinAngDim)
      acTrans.AddNewlyCreatedDBObject(acLinAngDim, True)
 
      '' 提交修改并销毁事务  Commit the changes and dispose of the transaction
      acTrans.Commit()
  End Using
End Sub

C#

using Autodesk.AutoCAD.Runtime;
using Autodesk.AutoCAD.ApplicationServices;
using Autodesk.AutoCAD.DatabaseServices;
using Autodesk.AutoCAD.Geometry;
 
[CommandMethod("CreateAngularDimension")]
public static void CreateAngularDimension()
{
  // 获得当前数据库  Get the current 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;
 
      // Create an angular dimension
      LineAngularDimension2 acLinAngDim = new LineAngularDimension2();
      acLinAngDim.SetDatabaseDefaults();
      acLinAngDim.XLine1Start = new Point3d(0, 5, 0);
      acLinAngDim.XLine1End = new Point3d(1, 7, 0);
      acLinAngDim.XLine2Start = new Point3d(0, 5, 0);
      acLinAngDim.XLine2End = new Point3d(1, 3, 0);
      acLinAngDim.ArcPoint = new Point3d(3, 5, 0);
      acLinAngDim.DimensionStyle = acCurDb.Dimstyle;
 
      // 添加新对象到模型空间和事务中   Add the new object to Model space and the transaction
      acBlkTblRec.AppendEntity(acLinAngDim);
      acTrans.AddNewlyCreatedDBObject(acLinAngDim, true);
 
      // 提交修改并销毁事务  Commit the changes and dispose of the transaction
      acTrans.Commit();
  }
}
VBA/ActiveX 代码参考