- '单选标注对象获取对齐及转角标注中的各点坐标
- Sub FixSingleDim()
- Dim Ent As AcadEntity
- Dim Pnt As Variant
- Dim DimPoints As Variant
- '选择对象
- ThisDrawing.Utility.GetEntity Ent, Pnt, vbCr & "选择要要获取坐标的标注对象:"
- If Ent.ObjectName Like "AcDb*Dimension" Then
- DimPoints = GetDimLinePoint(Ent)
- Dim i As Integer
- For i = 0 To UBound(DimPoints)
- Debug.Print DimPoints(i)
- Next
- End If
- End Sub'获取对齐标注及转角标注的尺寸界线原点及标注点的函数
- '返回格式:三组三维坐标,分别与DXF组码的13,14,10组码对应。
- '前两个坐标对应于对象模型中的ExtLine1Point,ExtLine2Point,第三个坐标在对象模型中没有。
- '作者:明经通道 mccad
- Function GetDimLinePoint(Dimension As AcadDimension) As Variant
- '在复制标注对象前先保存当前图形中的块数量
- Dim BlockCount As Long
- BlockCount = ThisDrawing.Blocks.Count
- '复制需要锁定文字内容的标注对象
- Dim CopyDimension As AcadDimension
- Set CopyDimension = Dimension.Copy
- '检查块数量是否增加,而且新增加的块名前缀是否为"*D"
- Dim NewBlockCount As Long
- NewBlockCount = ThisDrawing.Blocks.Count
- If NewBlockCount = BlockCount + 1 And Left(ThisDrawing.Blocks(BlockCount).Name, 2) = "*D" Then
- '遍历块中的对象,取得定义的点
- Dim EntityInBlock As AcadEntity
- Dim DimPnt As Variant
- Dim DimPoints() As Double
- Dim i As Integer
- For Each EntityInBlock In ThisDrawing.Blocks(BlockCount)
- If EntityInBlock.ObjectName = "AcDbPoint" Then
- i = i + 1
- DimPnt = EntityInBlock.Coordinates
- ReDim Preserve DimPoints(i * 3 - 1)
- DimPoints(i * 3 - 3) = DimPnt(0)
- DimPoints(i * 3 - 2) = DimPnt(1)
- DimPoints(i * 3 - 1) = DimPnt(2)
- End If
- Next
- End If
- '删除复制的标注对象
- CopyDimension.Delete
- GetDimLinePoint = DimPoints
- End Function
|