need help converting lisp ssget code to vba

need help converting lisp ssget code to vba

aridzv
Enthusiast Enthusiast
237 Views
1 Reply
Message 1 of 2

need help converting lisp ssget code to vba

aridzv
Enthusiast
Enthusiast

Hi.

I need help converting this lisp code to VBA:

 

  (setq ss (ssget '((0 . "INSERT"))))
  
  (repeat (setq i (sslength ss))
    (setq e (ssname ss (setq i (1- i))))
    (alert (cdr (assoc 2 (entget e))))
  )

 

thanks,

aridzv

0 Likes
Accepted solutions (1)
238 Views
1 Reply
Reply (1)
Message 2 of 2

tim11_manhhieu
Advocate
Advocate
Accepted solution
Sub GetBlockNames()
    Dim ent As Object
    Dim ss As Object
    Dim i As Integer
    
    Set ss = ThisDrawing.SelectionSets.Add("SS")
    ss.SelectOnScreen
    
    For i = 0 To ss.Count - 1
        Set ent = ss.Item(i)
        
        If ent.ObjectName = "AcDbBlockReference" Then
            MsgBox ent.Name
        End If
    Next i
    
    ThisDrawing.SelectionSets.Item("SS").Delete
End Sub