Jump to content

sharing lisp to select blocks by its name from a selection set


aridzv

Recommended Posts

Hi.

This time for a change I am not whining about problems,

but sharing a lisp created by knowledge shared here on the forum and I hope this lisp will be useful to other members here as it was effective for me.

the lisp prompt the user to select the block to use for the selection set and then promt the user to select the items in the desiered area and select only the blocks of the of the desiered block that was selected in the first step.

the lisp also select parametric blocks (I'm a bricscad user...) with *U name,probebly a dynamic blocks in autocad.

 

regards,

aridzv.

Sel_Bl_ByName.lsp

Edited by aridzv
  • Like 1
Link to comment
Share on other sites

@mhupp

I couldn't quite get it to work...

I picked the object use in select similar,

then slected the items to look in,

but no items where selectet...🤷‍♂️

Link to comment
Share on other sites

it only selects similar things you can 👀 when you run the command. if the original entity isn't on screen it wont be part of the selection after the command is run.

 

Edited by mhupp
Link to comment
Share on other sites

I was using something like this. I don't know who it is from, but I modified it a little bit.

 

;********************************************************;
; Block Name Filter 
; ss [selection-set] from ssget
; blknamelist [list] - list of [str] of effective block names to filter (e.g. "SUSPENSION2", "IBEAM PLAN")
; ss_new [selection-set] - Filtered selection set of ssnames of blocks
(defun MA:block_filter (ss blknamelist / count i ent obj ss_new) 
  (if ss 
    (progn 
      (setq ss_new (ssadd))
      (setq count (sslength ss))
      (setq i -1)
      (repeat count 
        (setq ent (ssname ss (setq i (1+ i))))
        (setq obj (vlax-ename->vla-object ent))
        (foreach blkname blknamelist 
          (if 
            (or 
              (wcmatch (strcase (LM:al-effectivename ent) T) 
                       (strcat "*" blkname "*")
              )
              (= blkname (LM:al-effectivename ent))
            )
            (ssadd ent ss_new)
          )
        )
      )
      ss_new
      ;(sssetfirst nil ss_new) ; Can be used to see which entities are highlighted
    )
  )
)

 

It needs Lee-Mac's LM:al-effectivename sub-function.

 

I use it by typing:

(MA:block_filter (ssget "_X") (list "BLOCK1" "BLOCK2"))

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...