Jump to content

Need lisp which can select all the polylines inside a polygon even if a polyline’s segment fall inside that boundary.


Recommended Posts

Posted

Can you post an actual drawing? 

 

And explain what you want in more detail.

Posted

@Akanezuko If I'm interpreting you correctly - try this:

(defun c:SelinPoly (/ es ob pts r ss)
   (if 
      (and
          (setq es (entsel "\nSelect a polygon: "))
          (= (cdr (assoc 0 (entget (car es)))) "LWPOLYLINE")
      )
      (progn
         (setq ob  (vlax-ename->vla-object (car es))
               pts (vla-get-coordinates ob)
               pts (vlax-safearray->list (vlax-variant-value pts))
         )
         (while pts
            (setq r   (cons (list (car pts) (cadr pts)) r)
               	pts (cddr pts)
            )
         )
         (if (> (length r) 2)
            (progn
               (entdel (car es))
               (setq ss (ssget "CP" r '((0 . "*POLYLINE"))))
               (entdel (car es))
               (sssetfirst nil ss)
            )
            (princ "\nSelected Polygon must be more than 2 points.")
         )
      )
      (princ "\nYou must select a Polygon.")
   )
   (princ)
)

 

  • Like 1
Posted

Using VLAX  can save a couple of lines when getting pline points.

(setq r (vlax-get ob 'coordinates))

I tend to use this, I think it was a suggestion by Lee-Mac.

(setq plent (entsel "\nPick rectang"))
(if plent (setq co-ord (mapcar 'cdr (vl-remove-if-not '(lambda (x) (= (car x) 10)) (entget (car plent))))))

 

  • Like 2
Posted
11 hours ago, BIGAL said:

Using VLAX  can save a couple of lines when getting pline points.

(setq r (vlax-get ob 'coordinates))

I tend to use this, I think it was a suggestion by Lee-Mac.

(setq plent (entsel "\nPick rectang"))
(if plent (setq co-ord (mapcar 'cdr (vl-remove-if-not '(lambda (x) (= (car x) 10)) (entget (car plent))))))

 

 

18 hours ago, pkenewell said:

@Akanezuko If I'm interpreting you correctly - try this:

(defun c:SelinPoly (/ es ob pts r ss)
   (if 
      (and
          (setq es (entsel "\nSelect a polygon: "))
          (= (cdr (assoc 0 (entget (car es)))) "LWPOLYLINE")
      )
      (progn
         (setq ob  (vlax-ename->vla-object (car es))
               pts (vla-get-coordinates ob)
               pts (vlax-safearray->list (vlax-variant-value pts))
         )
         (while pts
            (setq r   (cons (list (car pts) (cadr pts)) r)
               	pts (cddr pts)
            )
         )
         (if (> (length r) 2)
            (progn
               (entdel (car es))
               (setq ss (ssget "CP" r '((0 . "*POLYLINE"))))
               (entdel (car es))
               (sssetfirst nil ss)
            )
            (princ "\nSelected Polygon must be more than 2 points.")
         )
      )
      (princ "\nYou must select a Polygon.")
   )
   (princ)
)

 

Thank you!!!

  • Like 1

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