Jump to content

Selects everything that touches pre-selected objects


macros55

Recommended Posts

Mr Tusky, I appreciate you, realy it is a good job. Thanks

 

So how do choose those who touch the blocks?

 

image.png.b5816cab45cd025c97888c562ff375fd.png

Link to comment
Share on other sites

For blocks you are forced to use the code I edited which only processes the selected entity: the reason is that I use (nentsel) to retrieve the nested entity, which I cannot do with a (ssget) as in the code I put in the attached file.

Link to comment
Share on other sites

If touch means only requires accuracy at the level of a rectangle circumscribing the selected object.

It can be implemented simply like this.

; TOUCHSEL - exceed 2024.06.25
; Selects all objects that touch the selected object's bounding boxes.


(defun c:TOUCHSEL ( / ss ssl i ss_all ent obj bbox llp urp ss2 ss2l j ent2 )
  (vl-load-com)
  (if (setq ss (ssget))
    (progn
      (setq ssl (sslength ss))
      (setq i 0)
      (setq ss_all (ssadd))
      (repeat ssl
        (setq ent (ssname ss i))
        (setq obj (vlax-ename->vla-object ent))
        (setq bbox (vla-getboundingbox obj 'll 'ur))
        (setq llp (vlax-safearray->list ll))
        (setq urp (vlax-safearray->list ur))
        (if (setq ss2 (ssget "C" llp urp))
          (progn
            (setq ss2l (sslength ss2))
            (setq j 0)
            (repeat ss2l
              (setq ent2 (ssname ss2 j))
              (setq ss_all (ssadd ent2 ss_all))
              (setq j (+ j 1))
            )
          )
        )
        (setq i (+ i 1))
      )
      (sssetfirst nil ss_all)
    )
  )
  (princ)
)

 

 

  • Like 1
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...