大家好,
不久前,我编写了一些VBA代码,将图层列表插入绘图区域。它在每个层中绘制一条线,旁边放置一个文本,数据字段链接到该线的层。可以给我一个Lisp版本的吗?我试着用我有限的Lisp知识和投降。。。
这是VBA代码。。。
Public Sub LAYERLIST()On Error Resume NextDim TextStr As StringDim Lay As AcadLayerDim MTxt As AcadMTextDim SP(0 To 2), EP(0 To 2), Width As DoubleDim n As DoubleDim LayName As StringDim lineObj As AcadLineDim startPoint(0 To 2) As DoubleDim endPoint(0 To 2) As DoubleDim TxtInsertPoint(0 To 2) As DoubleDim IPoint(0 To 2) As DoubleDim VarPoint As VariantDim LayID As StringDim m As IntegerDim Counter As IntegerDim TotalLayCount As IntegerDim RowCount As IntegerDim ColumnIndex As IntegerDim TextId As StringThisDrawing.ActiveLayer = ThisDrawing.Layers.Item("0")TotalLayCount = ThisDrawing.Layers.CountWidth = 0VarPoint = ThisDrawing.Utility.GetPoint(IPoint, "Select a Point:")If Err Then Endm = 0Counter = 0RowCount = InputBox("There are " & TotalLayCount & " layers in this drawing." & vbCrLf & "Enter Number of Rows in the layer list:", "Enter Number of Rows")For Each Lay In ThisDrawing.LayersCounter = Counter + 1If Counter > RowCount Then ColumnIndex = ColumnIndex + 1 Counter = 0 n = 0End Ifn = n + 8 startPoint(0) = VarPoint(0) + (ColumnIndex * 70) startPoint(1) = VarPoint(1) - n startPoint(2) = VarPoint(2) endPoint(0) = VarPoint(0) + 25 + (ColumnIndex * 70) endPoint(1) = VarPoint(1) - n endPoint(2) = VarPoint(2) ThisDrawing.ActiveLayer = Lay LayID = Lay.ObjectID Set lineObj = ThisDrawing.ActiveLayout.Block.AddLine(startPoint, endPoint) TextId = lineObj.ObjectID TextStr = "%<\AcObjProp Object(" & TextId & ").Layer>%" TxtInsertPoint(0) = VarPoint(0) + (ColumnIndex * 70) + 30 TxtInsertPoint(1) = 2 + (VarPoint(1) - n) TxtInsertPoint(2) = VarPoint(2) Set MTxt = ThisDrawing.ModelSpace.AddMText(TxtInsertPoint, Width, TextStr) MTxt.Height = 2 MTxt.AttachmentPoint = acAttachmentPointMiddleLeft ZoomExtentsNextUpdateZoomExtentsMsgBox "Done..."End SubPublic Sub TXTLIST()Dim MTxt As AcadMTextDim TxtStyle As AcadTextStyleDim startPoint(0 To 2) As DoubleDim VarPoint As VariantDim n As IntegerDim Str As StringDim Width As DoubleVarPoint = ThisDrawing.Utility.GetPoint(, "Select a Point:")n = 0For Each TxtStyle In ThisDrawing.TextStyles If Not TxtStyle.Name = "" Then ThisDrawing.ActiveTextStyle = TxtStyle n = n + 1 startPoint(0) = VarPoint(0) startPoint(1) = VarPoint(1) + (n + 1) startPoint(2) = VarPoint(2) Str = TxtStyle.Name Width = 0 Set MTxt = ThisDrawing.ModelSpace.AddMText(startPoint, Width, Str) MTxt.AttachmentPoint = acAttachmentPointMiddleLeft MTxt.Height = 1 End IfNextUpdateMsgBox "Done..."End SubPublic Sub DIMLIST()Dim DimObj As AcadDimAlignedDim DimStyle As AcadDimStyleDim startPoint(0 To 2) As DoubleDim endPoint(0 To 2) As Double