Jump to content

"Select all that crosses in multiple boxes But omit the box in the selection" lisp


Tripledot

Recommended Posts

Been using this "select in cross box" lisp by Tharwat & is good.

But I have 2 request.

 

1. Please allow to able to select multiple box

2. After selecting everything in the multiple cross box, exclude the box from the selection

 

(defun c:SIB (/ s ss sel)
 ;;    Tharwat 30. May. 2014        ;;
 (if (setq s  (ssadd)
           ss (ssget (list '(0 . "LWPOLYLINE")
                           '(-4 . "&=")
                           '(70 . 1)
                           (cons 410 (getvar 'CTAB))
                     )
              )
     )
   ((lambda (j / sn n d l pts)
      (while (setq sn (ssname ss (setq j (1+ j))))
        (setq l   (vlax-curve-getdistatparam sn (vlax-curve-getendparam sn))
              d   (/ l 250.)
              n   d
              pts nil
        )
        (repeat 250
          (setq pts (cons (vlax-curve-getpointatdist sn n) pts)
                n   (+ n d)
          )
        )
        (if (setq sel (ssget "_CP" pts))
          ((lambda (i / en)
             (while (setq en (ssname sel (setq i (1+ i))))
               (ssadd en s)
             )
           )
            -1
          )
        )
      )
    )
     -1
   )
 )
 (sssetfirst nil s)
 (princ)
)

Edited by Tripledot
Link to comment
Share on other sites

You need to use Code Tags instead of Quote Tags for your Code. [NOPARSE]
Your Code Here

[/NOPARSE]=

Your Code Here

 

My mistake. Updated.

Edited by Tripledot
Link to comment
Share on other sites

Hi,

 

The program asks you to select closed lwpolylines so what do you mean by the following question?

1. Please allow to able to select multiple box

 

For the second question just replace this line (ssadd en s) with the following :

(if (not (eq sn en))
      (ssadd en s)
)

Link to comment
Share on other sites

Hi,

 

The program asks you to select closed lwpolylines so what do you mean by the following question?

 

 

For the second question just replace this line (ssadd en s) with the following :

(if (not (eq sn en))
      (ssadd en s)
)

 

Thanks Tharwat. That change worked. Also i forgotten that it can select multiple boxes so can ignore the 1st question.

 

Thanks

Link to comment
Share on other sites

Tharwat. I encounter an issue. It can only select with I am in WORLD UCS. Can make it possible to select in other UCS?

Link to comment
Share on other sites

Tharwat. I encounter an issue. It can only select with I am in WORLD UCS. Can make it possible to select in other UCS?

 

Replace the following:

(setq pts (cons (trans (vlax-curve-getpointatdist sn n) 1 0) pts)

Link to comment
Share on other sites

Opps. I should not have replied that fast which cause that big mistake to occur. :(

 

no issue Tharwat. Only got the chance to test it just.

 

Too be sure, this would be the code?

(setq pts (cons (trans (vlax-curve-getpointatdist sn n) 0 1) pts)

Edited by Tripledot
Link to comment
Share on other sites

Edit

 

I just realise that Lee posted the correction. Though both post were by Tharwat. Hence I got confused.

 

Thanks Lee & Tharwat for the help. Working now.

Link to comment
Share on other sites

  • 1 month later...

Hi Tharwat.

 

I now face an issue. I need to select those items not crossing or touching the selected polyline but only those that are completely inside.

 

Can you advise on the code to only select entities completely inside the selected closed polyline?

 

Thanks

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...