14
42
28
初露锋芒
Dim varObjArr As VariantDim aEnt As AcadEntityDim aLine2 As AcadPolylineDim Coords2 As Variant[... part that works with acadlwpolylines...]ElseIf TypeOf aEnt Is AcadPolyline Then Set aLine2 = aEnt varObjArr = aLine2.Offset(-0.001) Set aLine2 = varObjArr(0) Coords2 = aLine2.Coordinates aLine2.DeleteEnd If
使用道具 举报
29
519
477
Select Case objEnt.ObjectName Case "AcDbPolyline" ... (LWPolyline) Case "AcDb2dPolyline" ... (2D-Polyline) Case "AcDb3dPolyline" ... (3D-Polyline) Case "AcDbLine" ... (Line) . . . Case Else ... (Catches non handled objects)End Select
Option Compare TextOption ExplicitSub Overlap()Dim aEnt As AcadEntityDim varObjArr As VariantDim aEnt2 As AcadEntityDim sSet As AcadSelectionSetDim sSet2 As AcadSelectionSetDim aLine As AcadLWPolylineDim aCopy As AcadLWPolylineDim aCheck As AcadLWPolylineDim aLine2 As AcadPolylineDim aCopy2 As AcadPolylineDim aCheck2 As AcadPolylineDim Coords As VariantDim Coords2 As VariantDim Coords3 As VariantDim FT(0) As IntegerDim FD(0) As VariantDim FT2(1) As IntegerDim FD2(1) As VariantDim oLay As AcadLayerDim j As IntegerDim i As IntegerDim Overlap_Count As IntegerFT(0) = 0FD(0) = "*polyline"FT2(0) = 0FD2(0) = "*polyline"FT2(1) = 8FD2(1) = "N_GRA*"Set oLay = ThisDrawing.Layers.Add("_CHECK_OVERLAP")oLay.Lineweight = acLnWt030oLay.Color = acCyanOverlap_Count = 0On Error GoTo DeleteSet sSet = ThisDrawing.SelectionSets.Add("sset")sSet.Select acSelectionSetAll, , , FT, FDOn Error GoTo ErrorControle For Each aEnt In sSet If aEnt.Layer Like "N_GRA1A" Or aEnt.Layer Like "N_GRA1GBA" Then GoTo FollowingEntity ElseIf aEnt.Layer Like "*gano*" Or aEnt.Layer Like "N_GRA*" Or aEnt.Layer Like "ANO_GVCO*" Then If TypeOf aEnt Is AcadLWPolyline Then Set aCheck = aEnt varObjArr = aCheck.Offset(0.001) Set aLine = varObjArr(0) If aLine.Area > aCheck.Area Then Erase varObjArr aLine.Delete varObjArr = aCheck.Offset(-0.001) Set aLine = varObjArr(0) End If ReDim Coords(0 To UBound(aLine.Coordinates)) Coords = aLine.Coordinates aLine.Delete ReDim Coords2(0 To ((UBound(Coords) + 1) / 2 * 3) - 1) As Double j = 0 For i = 0 To UBound(Coords) Step 2 Coords2(j) = Coords(i) Coords2(j + 1) = Coords(i + 1) Coords2(j + 2) = 0 j = j + 3 Next i ElseIf TypeOf aEnt Is AcadPolyline Then Set aCheck2 = aEnt varObjArr = aCheck2.Offset(0.001) Set aLine2 = varObjArr(0) If aLine2.Area > aCheck2.Area Then Erase varObjArr aLine2.Delete varObjArr = aCheck2.Offset(-0.001) Set aLine2 = varObjArr(0) End If ReDim Coords2(0 To UBound(aLine2.Coordinates)) As Double Coords2 = aLine2.Coordinates aLine2.Delete End If Erase varObjArr On Error GoTo Delete2 Set sSet2 = ThisDrawing.SelectionSets.Add("sset2") sSet2.SelectByPolygon acSelectionSetCrossingPolygon, Coords2, FT2, FD2 On Error GoTo ErrorControle For Each aEnt2 In sSet2 If TypeOf aEnt2 Is AcadLWPolyline Then Set aCopy = aEnt2.Copy aCopy.Layer = "_CHECK_OVERLAP" Overlap_Count = Overlap_Count + 1 'following code is the make the offsetlines visible for control 'ThisDrawing.ModelSpace.AddPolyline (Coords2) ElseIf TypeOf aEnt2 Is AcadPolyline Then Set aCopy2 = aEnt2.Copy aCopy2.Layer = "_CHECK_OVERLAP" Overlap_Count = Overlap_Count + 1 'following code is the make the offsetlines visible for control 'ThisDrawing.ModelSpace.AddPolyline (Coords2) End If Next aEnt2 ThisDrawing.SelectionSets.Item("sset2").Delete End If