Create Angular Dimensions
 
 
 

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.

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:

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

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

Create an angular dimension

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.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.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 Code Reference