土木在线论坛 \ 建筑设计 \ CAD下载及教程 \ cad里如何量测大批点之间两两距离?
在做雨量站点分布图的时候,需要量测大量雨量站点之间的距离,请问各位大侠有没有什么办法可以自动生成列表,是不是需要另外编程,但是我自己对cad编程一点都不懂,恳请大家的帮助.感激不尽^_^

全部回答(3 )

  • tongmingniao
    先选择点对象,结果输出到dat文件。
    vba程序如下:
    Option Explicit
    Sub 批量求点距()
    Dim YSet As AcadSelectionSet
    Set YSet = ThisDrawing.PickfirstSelectionSet
    If YSet.count = 0 Then
    MsgBox "选择点对象": Exit Sub
    Else
    If MsgBox("如果选择好了点对象,请继续", vbOKCancel, "是否继续?") = vbCancel Then Exit Sub
    End If
    ' MsgBox YSet.count

    Dim I As Long
    Dim J As Long
    Dim PointI As Variant
    Dim PointJ As Variant
    Dim X1 As Double
    Dim Y1 As Double
    Dim X2 As Double
    Dim Y2 As Double
    Dim SaveFile As String
    SaveFile = Left(ThisDrawing.Path & "\" & ThisDrawing.Name, Len(ThisDrawing.Path & "\" & ThisDrawing.Name) - 3) & "dat"
    Open SaveFile For Output As #1
    For I = 0 To YSet.count - 2
    PointI = YSet(I).Coordinates
    X1 = PointI(0)
    Y1 = PointI(1)
    For J = I + 1 To YSet.count - 1
    PointJ = YSet(J).Coordinates
    X2 = PointJ(0)
    Y2 = PointJ(1)
    Debug.Print Sqr((X2 - X1) ^ 2 + (Y2 - Y1) ^ 2)
    Print #1, Sqr((X2 - X1) ^ 2 + (Y2 - Y1) ^ 2)
    Next
    Next
    Close #1
    End Sub
    2009-03-21 16:31:21 来自 PC 评论 举报
  • rdihe_009
    这个恐怕只能编程了,用autolisp或vba做个循环都很容易实现
    2005-03-24 21:56:24 来自 PC 评论 举报
加载更多
这个家伙什么也没有留下。。。

CAD下载及教程

返回版块

52.09 万条内容 · 667 人订阅

猜你喜欢

回帖成功

经验值 +10