Function GetSel(Optional Name = "TLSSEL") As AcadSelectionSet On Error Resume Next ThisDrawing.SelectionSets(Name).Delete Set GetSel = ThisDrawing.SelectionSets.Add(Name) End Function Sub jh() Dim p1(0 To 2) As Double Dim ss As AcadSelectionSet Set ss = GetSel() 'ss.SelectOnScreen 'For j = 0 To ss.Count - 1 ' ms = ss.Item(j).ObjectID & Chr(10) + ms 'Next 'MsgBox ms
Dim ft(0) As Integer, fd(0) LayerName = "c1" ft(0) = 8: fd(0) = LayerName ss.Select acSelectionSetAll, , , ft, fd For i = 0 To ss.Count - 1 If i > ss.Count - 1 Then GoTo pp: gs = 0 MsgBox ss.Item(i).ObjectName & Chr(10) & ss.Item(i).ObjectID & Chr(10) & i ss.Item(i).GetBoundingBox mind, maxd a = maxd(0) - mind(0) b = maxd(1) - mind(1) For k = 1 To ss.Count - 1 If k > ss.Count - 1 Then GoTo kk: ss.Item(k).GetBoundingBox mindt, maxdt at = maxdt(0) - mindt(0) bt = maxdt(1) - mindt(1) If at = a And bt = b And ss.Item(k).ObjectID <> ss.Item(i).ObjectID Then 'MsgBox ss.Item(k).ObjectID & Chr(10) & k ss.Item(k).Delete gs = gs + 1 Set ss = GetSel() LayerName = "c1" ft(0) = 8: fd(0) = LayerName ss.Select acSelectionSetAll, , , ft, fd k = k - 1 End If Next kk: Dim sm As AcadMText pb = ThisDrawing.Utility.GetPoint(, "选择基点:" & Chr(10)) ss.Item(i).Move mind, pb ss.Item(i).GetBoundingBox minda, maxda p1(0) = minda(O): p1(1) = minda(1) - 5: p1(2) = minda(2) w = a / 5 Set sm = ThisDrawing.ModelSpace.AddMText(p1, w, gs + 1) sm.Layer = "t1" Next pp:
End Sub
不行呀!救救呀! |