Jump to content

Recommended Posts

Posted

Hi, Is there a Lisp routine which can move all objects within a selected polyline to a layer called "exist" and all objects outside that same polyline to a layer called "site" ?? ignoring all frozen or OFF layers ?? Regards.

Posted

If you want to have a go, look at Selection Sets to select everything within the polyline (see Lee Mac Selection sets page - it is rather good - ssget), window polygon or crossing polygon

Do 2 selection sets - one for everything "_X" and one for Crossing Polygon, I think Lee Mac has a routine there to remove one selection set from another.

This gives you 2 sets of entities to work with

Loads of LISPs out there to change layers.

 

Have a go, it is easier than you might think 

Posted (edited)

Try this:

(defun c:chglyobjpl (/ acdoc p_list p_coord sset ent obj newLayerName i)

  (vl-load-com)
  (setq acdoc (vla-get-ActiveDocument (vlax-get-acad-object)))

;;;;;;;;;;;https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/selection-set-using-existing-polygon/td-p/11307274
;;;;;;;;;;;calderg1000 msg-7

  (setq p_list (entget (car (entsel "\nSelect the LwPolyline: "))))

  (if (setq
        p_coord (mapcar 'cdr
                        (vl-remove-if-not '(lambda (x) (= (car x) 10)) p_list)
                );;end setq p_coord
      );;end if condition
    (sssetfirst nil (setq sset (ssget "_wp" p_coord)))
  )

;;;;;;;;;;;;;;;;;;;;;;;;;;;;Select Objects In polygon;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

;;;;;;;;;;;;;;;;;;;;;;;;;;;;Change Objects Layer;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  (if sset
    (progn
      (setq newLayerName "exist") ;;(getstring T "\nEnter new layer name: "))
      (repeat (setq i (sslength sset))
        (setq i (1- i))
        (setq ent (ssname sset i))
        (setq obj (vlax-ename->vla-object ent))
        (vla-put-Layer obj newLayerName)
      );;repeat
      (vla-Regen acdoc acAllViewports)
      (sssetfirst nil nil)
    );;progn
    (princ "\nNo objects found in the drawing.")
  );;if
;;;;;;;;;;;;;;;;;;;;;;;;;;;;Change Objects Layer;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

  (princ)
);;end defun

 

Edited by aridzv
Posted

Thanks ...

but.....

on running the program, its saying that "no objects found in the drawing" and the program closes

 

Posted (edited)

see new code.

make sure the layers names are correct.

(defun c:chglyobjpl (/ acdoc p_list p_coord sset ent obj newLayerName newLayerName1 i)

  (vl-load-com)
  (setq acdoc (vla-get-ActiveDocument (vlax-get-acad-object)))
  (princ "\nSelect All Objects To Proccess")
  (setq ssall (ssget))
  (setq p_list (entget (car (entsel "\nSelect the Polyline Boundery For ''exist'' Layer: "))))
  (setq i 0)
;;;;;;;;;;;;;;;;;;;;;;;;;;;Change Objects To site Layer;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(if ssall
  (progn
    (sssetfirst nil nil)
    (setq newLayerName1 "site");;(getstring T "\nEnter new layer name: "))
      (repeat (setq i (sslength ssall))
        (setq i (1- i))
        (setq ent (ssname ssall i))
        (setq obj (vlax-ename->vla-object ent))
        (vla-put-Layer obj newLayerName1)
      );;repeat
      (vla-Regen acdoc acAllViewports)
      (sssetfirst nil nil)
    );;progn
    (princ "\nNo objects found in the drawing.")
  );;if
;;;;;;;;;;;;;;;;;;;;;;;;;;;Change Objects To site Layer;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  (setq ent nil)
  (setq obj nil)
  (setq i 0)
;;;;;;;;;;;https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/selection-set-using-existing-polygon/td-p/11307274
;;;;;;;;;;;calderg1000 msg-7
  (if (setq
        p_coord (mapcar 'cdr
                        (vl-remove-if-not '(lambda (x) (= (car x) 10)) p_list)
                );;end setq p_coord
      );;end if condition
    (sssetfirst nil (setq sset (ssget "_wp" p_coord)))
  )
;;;;;;;;;;;;;;;;;;;;;;;;;;;;Select Objects In polygon;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

;;;;;;;;;;;;;;;;;;;;;;;;;;;;Change Objects Layer;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  (if sset
    (progn
      (sssetfirst nil nil)
      (setq newLayerName "exist");;(getstring T "\nEnter new layer name: "))
      (repeat (setq i (sslength sset))
        (setq i (1- i))
        (setq ent (ssname sset i))
        (setq obj (vlax-ename->vla-object ent))
        (vla-put-Layer obj newLayerName)
      );;repeat
      (vla-Regen acdoc acAllViewports)
      (sssetfirst nil nil)
    );;progn
    (princ "\nNo objects found in the drawing.")
  );;if
;;;;;;;;;;;;;;;;;;;;;;;;;;;;Change Objects To exist Layer;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

  (sssetfirst nil nil)
  (princ)
);;end defun

 

 

Edited by aridzv

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