角度寸法を記入する(.NET)

角度寸法は、2 本の線分がなす角度、または 3 つの点によって生成される角度を表します。たとえば、角度寸法を使用して、1 つの円の 2 つの半径間の角度を示すことができます。この場合、寸法線は円弧を形成します。角度寸法を記入するには、LineAngularDimension2 オブジェクトまたは Point3AngularDimension オブジェクトのインスタンスを作成します。

LineAngularDimension2 オブジェクトまたは Point3AngularDimension オブジェクトのインスタンスを作成すると、コンストラクタはオプションで一連のパラメータを受け入れることができます。新しい LineAngularDimension2 オブジェクトを作成するときは、次のパラメータを指定できます。

新しい Point3AngularDimension オブジェクトを作成するときは、次のパラメータを指定できます。

角度寸法を記入する

次の例は、モデル空間に角度寸法を記入します。

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
        Using 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)
        End Using

        '' 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
        using (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 コード リファレンス

Sub CreateAngularDimension()
    Dim dimObj As AcadDimAngular
    Dim angVert(0 To 2) As Double
    Dim FirstPoint(0 To 2) As Double
    Dim SecondPoint(0 To 2) As Double
    Dim TextPoint(0 To 2) As Double
 
    ' Define the dimension
    angVert(0) = 0
    angVert(1) = 5
    angVert(2) = 0
    FirstPoint(0) = 1
    FirstPoint(1) = 7
    FirstPoint(2) = 0
    SecondPoint(0) = 1
    SecondPoint(1) = 3
    SecondPoint(2) = 0
    TextPoint(0) = 3
    TextPoint(1) = 5
    TextPoint(2) = 0
 
    ' Create the angular dimension in model space
    Set dimObj = ThisDrawing.ModelSpace. _
                    AddDimAngular(angVert, FirstPoint, SecondPoint, TextPoint)
    ZoomAll
End Sub