- Sub Measure()
- Dim Ent As AcadEntity
- Dim Pnt As Variant
- ThisDrawing.Utility.GetEntity Ent, Pnt, vbCr & "请选择要按距离取点的曲线:"
- Ent.Highlight True
- Dim Dis As Double
- Dis = ThisDrawing.Utility.GetDistance(, vbCr & "选择长度:")
- Dim Cnt As Long
- Cnt = ThisDrawing.ModelSpace.Count
- ThisDrawing.SendCommand "measure" & vbCr & _
- GetDoubleEntTable(Ent, Pnt) & vbCr & Dis & vbCr
- Dim i As Long
- Dim Point As AcadPoint
- Dim PntPos As Variant
- For i = ThisDrawing.ModelSpace.Count - 1 To Cnt Step -1
- If ThisDrawing.ModelSpace(i).ObjectName = "AcDbPoint" Then
- Debug.Print ThisDrawing.ModelSpace(i).ObjectName
- Set Point = ThisDrawing.ModelSpace(i)
- PntPos = Point.Coordinates
- Debug.Print PntPos(0) & " " & PntPos(1)
- Point.Delete
- End If
- Next
- End Sub
- '转换双元表的函数
- Public Function GetDoubleEntTable(entObj As AcadEntity, Pnt As Variant) As String
- Dim entHandle As String
- entHandle = entObj.Handle
- GetDoubleEntTable = "(list(handent " & Chr(34) & entHandle & Chr(34) & _
- ")(list " & Str(Pnt(0)) & Str(Pnt(1)) & Str(Pnt(2)) & "))"
- End Function
|