这个就是专门为你写的完整代码:运行时先选择一个矩形,右键即可完成你要的操作 Sub tttt() Dim p As Variant Dim ent As AcadEntity Dim min, max As Variant Dim a(0 To 2) As Double Dim b(0 To 2) As Double ThisDrawing.Utility.GetEntity ent, p, "请选择一个矩形:" ent.GetBoundingBox min, max st3 min, min(0) - 0.001, min(1) - 0.001, 0 st3 max, max(0) + 0.001, max(1) + 0.001, 0 st3 a, min(0) - 0.001, max(1) + 0.001, 0 st3 b, max(0) + 0.001, min(1) - 0.001, 0 ThisDrawing.SendCommand "_trim" & vbCr & "(handent """ & ent.Handle & """)" & vbCr & vbCr & "f" & vbCr & min(0) & "," & min(1) & vbCr & a(0) & "," & a(1) & vbCr & max(0) & "," & max(1) & vbCr & b(0) & "," & b(1) & vbCr & min(0) & "," & min(1) & vbCr & vbCr & vbCr ThisDrawing.SendCommand "_trim" & vbCr & "(handent """ & ent.Handle & """)" & vbCr & vbCr & "f" & vbCr & min(0) & "," & min(1) & vbCr & a(0) & "," & a(1) & vbCr & max(0) & "," & max(1) & vbCr & b(0) & "," & b(1) & vbCr & min(0) & "," & min(1) & vbCr & vbCr & vbCr End Sub |