13
70
57
初露锋芒
使用道具 举报
1
1069
1050
Option ExplicitConst pi As Double = 3.14159265358979Public Sub TouchNearestText()Dim oEnt As AcadEntityDim oLine As AcadLineDim pickPtOn Error GoTo Err_ReportCall ThisDrawing.Utility.GetEntity(oEnt, pickPt, vbLf & "Select a Line: ") If Not TypeOf oEnt Is AcadLine Then MsgBox "Not a Line!" Exit Sub End IfSet oLine = oEnt Dim minExt As Variant Dim maxExt As Variant ' Return the bounding box for the line and return the minimum ' and maximum extents of the box in the minExt and maxExt variables.oLine.GetBoundingBox minExt, maxExt Dim pts(0 To 11) As Double pts(0) = minExt(0): pts(1) = minExt(1): pts(2) = 0# pts(3) = maxExt(0): pts(4) = minExt(1): pts(5) = 0# pts(6) = maxExt(0): pts(7) = maxExt(1): pts( = 0# pts(9) = minExt(0): pts(10) = maxExt(1): pts(11) = 0# Dim setObj As AcadSelectionSet Dim setColl As AcadSelectionSets Dim oText As AcadText Dim pickPnt As Variant Dim setName As String Dim selMod As Long Dim vertPts As Variant Dim dblElv As Double Dim gpCode(1) As Integer Dim dataValue(1) As Variant Dim dxfcode, dxfdata '' build your filter here: gpCode(0) = 0: gpCode(1) = 8 dataValue(0) = "TEXT": dataValue(1) = "0" dxfcode = gpCode: dxfdata = dataValue setName = "$CrossSelect$" With ThisDrawing Set setColl = .SelectionSets For Each setObj In setCollIf setObj.Name = setName Then.SelectionSets.item(setName).DeleteExit ForEnd IfNext Set setObj = .SelectionSets.Add(setName) End With selMod = AcSelect.acSelectionSetCrossingPolygon ' <-- can use also acSelectionSetWindowPolygon ' setObj.SelectByPolygon selMod, pts, dxfcode, dxfdata setObj.Highlight True