鲍勃:我以前说过,现在我再说一遍;
你是最棒的!
我认为您在sendcommand中漏掉了几个输入,但我得到了它代码4]
以下是结果:
- Sub BlockonlayersLoop() 'This Sub will keep prompting for the next block until user escapes.
- Dim B As AcadBlock
- Dim ent As AcadEntity
- Dim P
- Dim LayerCol As New Collection
- Dim slayer As String
- Dim Picked As Boolean
- Dim i As Integer
- Dim PauseTime, Start 'Bob's Code
-
- PauseTime = 1 'Bob's Code
- Start = Timer 'Bob's Code
-
- Do While Timer < Start + PauseTime 'This pause gives time for the macro to finish before trying to unload 'Bob's Code
- Do
- On Error Resume Next
- ThisDrawing.Utility.GetEntity ent, P, "Pick a blockref"
- If Not TypeOf ent Is AcadBlockReference Then
- Picked = False
- GoTo ExitOut
- Else
- Picked = True
- End If
- If ent Is Nothing Then
- Picked = False
- GoTo ExitOut
- Else
- Picked = True
- End If
-
- Set B = ThisDrawing.Blocks(ent.Name)
- Debug.Print "The block " & B.Name & " uses the following layers:"
-
- For Each ent In B
- slayer = ent.Layer
- For i = 1 To LayerCol.Count
- If LayerCol(i) = slayer Then GoTo Skip
- Next
- LayerCol.Add slayer
- Skip:
- Next
- For i = 1 To LayerCol.Count
- Debug.Print LayerCol(i)
- Next
- ExitOut:
- Dim Num As Integer
- For Num = 1 To LayerCol.Count
- LayerCol.Remove 1
- Next
- Loop Until Picked = False
- Loop
- ThisDrawing.SendCommand "vbaunload" & vbCr & "Tools.dvb" & vbCr 'Bob's Code
- End Sub
它看起来非常有效
谢谢您,先生!
|