Darrell Posted August 8 Share Posted August 8 I need a lisp that will find blocks of a specific name in a drawing and move them all to a certain layer. Quote Link to comment Share on other sites More sharing options...
ronjonp Posted August 8 Share Posted August 8 Give this a try, assuming they are not modified dynamic blocks. (defun c:foo (/ s) (if (setq s (ssget "_X" '((0 . "INSERT") (2 . "YOURBLOCKNAME")))) (foreach e (mapcar 'cadr (ssnamex s)) (entmod (append (entget e) '((8 . "YOURLAYERNAME"))))) ) (princ) ) 1 Quote Link to comment Share on other sites More sharing options...
Darrell Posted August 8 Author Share Posted August 8 49 minutes ago, ronjonp said: Give this a try, assuming they are not modified dynamic blocks. (defun c:foo (/ s) (if (setq s (ssget "_X" '((0 . "INSERT") (2 . "YOURBLOCKNAME")))) (foreach e (mapcar 'cadr (ssnamex s)) (entmod (append (entget e) '((8 . "YOURLAYERNAME"))))) ) (princ) ) Thanks I'll give it a try! Quote Link to comment Share on other sites More sharing options...
BIGAL Posted August 9 Share Posted August 9 (edited) Hope you don't mind @ronjonp just added get name and layer by object. (defun c:foo2 ( / s bname) (setq bname (cdr (assoc 2 (entget (car (entsel "\nPlease pick block for name search ")))))) (setq lay (cdr (assoc 8 (entget (car (entsel "\nPlease pick any object for destination layer ")))))) (if (setq s (ssget "_X" (list (cons 0 "INSERT") (cons 2 bname)))) (foreach e (mapcar 'cadr (ssnamex s)) (entmod (append (entget e) (list (cons 8 lay))))) ) (princ) ) Can also use CHPROP on selection set s, I think the foreach may be faster though. Edited August 9 by BIGAL Quote Link to comment Share on other sites More sharing options...
Recommended Posts
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.