How to quick select all entity have same property

How to quick select all entity have same property

tim11_manhhieu
Advocate Advocate
537 Views
6 Replies
Message 1 of 7

How to quick select all entity have same property

tim11_manhhieu
Advocate
Advocate

The execution sequence will be like this
1) select the object
2) run the macro
3) all objects in drawing with the same properties as the object in step 1) will be selected.
Does anyone have the vba or lisp code that can share with me?

0 Likes
Accepted solutions (2)
538 Views
6 Replies
Replies (6)
Message 2 of 7

Brock_Olly
Collaborator
Collaborator
Accepted solution

You want a LISP i'm guessing?
This also depends on which properties you want to be the same.
This chatgpt-lisp selects based on Layer, Colour and Object type
Doesn't seem to work for dynamic blocks though.

You could also just use Selectsimilar command and tweak it with SELECTSIMILARMODE

(defun c:SSAME ( / ent entData objType objLayer objColor blockName filter ss)
  ;; Step 1: Select an object
  (setq ent (car (entsel "\nSelect object with desired properties: ")))
  (if ent
    (progn
      (setq entData  (entget ent))
      (setq objType  (cdr (assoc 0 entData))) ; Object type
      (setq objLayer (cdr (assoc 8 entData))) ; Layer name
      (setq objColor (cdr (assoc 62 entData))) ; ACI color

      ;; If it's a block reference, get the block name
      (if (equal objType "INSERT")
        (setq blockName (cdr (assoc 2 entData)))
      )

      ;; Step 2: Build filter list
      (setq filter (list (cons 0 objType)
                         (cons 8 objLayer)))
      (if objColor
        (setq filter (append filter (list (cons 62 objColor))))
      )
      (if blockName
        (setq filter (append filter (list (cons 2 blockName))))
      )

      ;; Step 3: Select matching objects
      (setq ss (ssget "X" filter))

      ;; Step 4: Feedback
      (if ss
        (progn
          (prompt (strcat "\nFound " (itoa (sslength ss)) " matching object(s)."))
          (sssetfirst nil ss)
        )
        (prompt "\nNo matching objects found.")
      )
    )
    (prompt "\nNothing selected.")
  )
  (princ)
)

 

0 Likes
Message 3 of 7

Ed__Jobe
Mentor
Mentor

Have you tried the QSELECT command? You can type it in or access it from the Properties palette.

2025-04-04_14-45-52.PNG

Ed


Did you find this post helpful? Feel free to Like this post.
Did your question get successfully answered? Then click on the ACCEPT SOLUTION button.
How to post your code.

EESignature

Message 4 of 7

tim11_manhhieu
Advocate
Advocate

That is amazing, I didn't know there was a SELECTSIMILAR command. Appreciate.

 

0 Likes
Message 5 of 7

tim11_manhhieu
Advocate
Advocate

If using Qselect, it quite time consuming because I have to select object, property, value.

0 Likes
Message 6 of 7

Brock_Olly
Collaborator
Collaborator
Accepted solution

Just for your information, selectsimilar can be called form the right-click-menu.

Brock_Olly_0-1744100398822.png

 

Message 7 of 7

tim11_manhhieu
Advocate
Advocate

Sorry for my poor AutoCad, thank you again.

0 Likes