2
3
1
初来乍到
Public Function axEnt2lspEnt(entObj As AcadEntity) As String Dim entHandle As String entHandle = entObj.Handle axEnt2lspEnt = "(handent" & Chr(34) & entHandle & Chr(34) & ")" End Function Public Function offent(obj As AcadEntity, off As Double, pt() As Double, de As Boolean) As AcadEntity Const pi = 3.1415926 'obj??????????off???????????????pt()???????????????????,de ??????????????? '???obj???????????????????????????????????? Dim obj1 As AcadPolyline Dim pl As AcadPolyline Dim cr As AcadCircle Select Case UCase(obj.ObjectName) Case "ACDB3DPOLYLINE", "ACDB2DPOLYLINE" ReDim pt(UBound(obj.Coordinates)) As Double For I = 0 To UBound(pt) Step 3 pt(I) = obj.Coordinate(I / 3)(0) pt(I + 1) = obj.Coordinate(I / 3)(1) Next I teml = obj.Layer temc = obj.Closed Case "ACDBPOLYLINE" ReDim pt(((UBound(obj.Coordinates) + 1) / 2) * 3 - 1) As Double For I = 0 To UBound(pt) Step 3 pt(I) = obj.Coordinate((I) / 3)(0) pt(I + 1) = obj.Coordinate((I) / 3)(1) Next I teml = obj.Layer temc = obj.Closed Case "ACDBCIRCLE" Set cr = obj Dim pp As Double pp = cr.radius ReDim pt(359 * 3 + 2) As Double For I = 0 To 359 pt(I * 3) = cr.center(0) + Cos(I * pi / 180) * cr.radius pt(I * 3 + 1) = cr.center(1) + Sin(I * pi / 180) * cr.radius pt(I * 3 + 2) = 0 Next I teml = obj.Layer temc = True End Select Set obj1 = ThisDrawing.ModelSpace.AddPolyline(pt) obj1.Layer = teml obj1.Closed = temc '--------------------------------- Dim offobj As AcadEntity Select Case off Case Is > 0 off1 = obj1.Offset(off) If off1(0).Area obj1.Area Then off1(0).Delete off1 = obj1.Offset(-1 * off) End If Set offobj = off1(0) End Select '-------------------------------- Set offent = offobj ReDim pt(UBound(offobj.Coordinates)) As Double For I = 0 To UBound(pt) Step 3 pt(I) = offobj.Coordinate(I / 3)(0) pt(I + 1) = offobj.Coordinate(I / 3)(1) Next I obj1.Delete Set obj1 = Nothing If de Then offobj.Delete End If End Function Public Function chkclose(SSet As AcadSelectionSet) As Boolean chkclose = True Dim pl As AcadObject For I = 0 To SSet.Count - 1 Set pl = SSet.Item(I) Select Case UCase(pl.ObjectName) Case "ACDB3DPOLYLINE", "ACDB2DPOLYLINE" last = (UBound(pl.Coordinates) + 1) / 3 - 1 Case "ACDBPOLYLINE" last = (UBound(pl.Coordinates) + 1) / 2 - 1 Case "ACDBCIRCLE" last = -1 End Select If last > 0 Then If Not (pl.Closed Or (pl.Coordinate(0)(0) = pl.Coordinate(last)(0) And pl.Coordinate(0)(1) = pl.Coordinate(last)(1))) Then chkclose = False pl.color = acRed pl.Highlight True End If End If Next I End Function Sub trim() Dim ptt(0 To 7) As Double pt1 = ThisDrawing.Utility.GetPoint(, " ?????????????:") pt2 = ThisDrawing.Utility.GetCorner(pt1, " ?????????????:") ptt(0) = pt1(0) ptt(1) = pt1(1) ptt(2) = pt1(0) ptt(3) = pt2(1) ptt(4) = pt2(0) ptt(5) = pt2(1) ptt(6) = pt2(0) ptt(7) = pt1(1) Set plineObj = ThisDrawing.ModelSpace.AddLightWeightPolyline(ptt) plineObj.Closed = True Dim SSet1 As AcadSelectionSet For Each SSet1 In ThisDrawing.SelectionSets If SSet1.Name = "SS2" Then ThisDrawing.SelectionSets.Item("SS2").Delete Exit For End If Next Set SSet1 = ThisDrawing.SelectionSets.Add("SS2") Dim keyWord As String