CAD开发者社区

 找回密码
 立即注册

QQ登录

只需一步,快速开始

ObjectARX 开发指南

创建角度尺寸 (.NET)

2023-1-1 11:52| 发布者: admin| 查看: 348| 评论: 0|来自: AutoCAD

角度尺寸测量两条线或三点之间的角度。例如,您可以使用它们来测量圆的两个半径之间的角度。尺寸线形成一个弧。角度尺寸是通过创建实例 oforobjects 来创建的。LineAngularDimension2Point3AngularDimension

  • 线角度维度2.表示由两条线定义的角度尺寸。
  • 点3角度维度。表示由三个点定义的角度尺寸。

创建主对象实例时,构造函数可以选择接受设置的参数。创建新对象时,可以提供以下参数:LineAngularDimension2Point3AngularDimensionLineAngularDimension2

  • 延长线 1 起点(属性)XLine1Start
  • 延长线 1 端点(属性)XLine1End
  • 延长线2起点(属性)XLine2Start
  • 延长线 1 端点(属性)XLine2End
  • 弧点(属性)ArcPoint
  • 尺寸文本(属性)DimensionText
  • 标注样式(或属性)DimensionStyleNameDimensionStyle

创建新对象时,可以提供以下参数:Point3AngularDimension

  • 中心点(属性)CenterPoint
  • 延长线 1 点(属性)XLine1Point
  • 延长线2点(属性)XLine2Point
  • 弧点(属性)ArcPoint
  • 尺寸文本(属性)DimensionText
  • 标注样式(或属性)DimensionStyleNameDimensionStyle

创建角度尺寸

本示例在模型空间中创建一个角度尺寸。

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

路过

雷人

握手

鲜花

鸡蛋

最新评论

QQ|Archiver|CAD开发者社区 ( 苏ICP备2022047690号-1 )

GMT+8, 2024-5-19 12:12

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

返回顶部