Visual LISP, AutoLISP and General Customization
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic to the Top
- Bookmark
- Subscribe
- Printer Friendly Page
LayCur to multiple objects
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
Hi all!
Is there any way to use the command "LAYCUR" to change all objects that are in the same layer?
With a lisp, maybe?
Solved! Go to Solution.
Re: LayCur to multiple objects
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
Your question is not clear enough , or at least to me .
can you explain your needs in more details ?
Re: LayCur to multiple objects
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
jjorovi wrote:....Is there any way to use the command "LAYCUR" to change all objects that are in the same layer?....
Here's one way to do the equivalent [without using LAYCUR itself]:
(defun C:LAYMRGC (/ lay clay layss edata); = LAYer MeRGe into Current layer
(setq
lay (cdr (assoc 8 (entget (car (entsel "\nSelect object on Layer to Merge into Current Layer: ")))))
clay (getvar 'clayer)
layss (ssget "_X" (list (cons 8 lay)))
); setq
(repeat (sslength layss)
(setq edata (entget (ssname layss 0)))
(entmod (subst (cons 8 clay) (assoc 8 edata) edata))
(ssdel (ssname layss 0) layss)
); repeat
); defun
If you don't need that "same layer" to remain in the drawing afterwards, you can just use LAYMRG to merge it into the current layer, but that would require you to either pick something on the current Layer for the Layer to Merge into, or use the Type-it option and type in the name of the current Layer.
It could also be set up to ask the User to enter a Layer name instead select something [which would mean you could do it even with nothing on that Layer visible], and no doubt in some other variants.
And to be more exactly like LAYMRG except for the built-in current-Layer part, it could be made to purge the other Layer, which the above doesn't do. But that wouldn't work anyway if there are, for example, things on that Layer that are parts of Block definitions -- LAYMRG would take care of those, too.
Another approach would be to use Qselect to find everything on a Layer, and when it has made its selection and has it highlighted/gripped, type LAYCUR. But I don't think that would change things in all spaces/tabs, as the above would.
Re: LayCur to multiple objects
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
If I have multiple objects on a specific layer and I want pass it to the current layer, use the command "laycur", but I want all objects belonging to that layer, change to the current layer.
More simple. Change objects to one layer to the other very quickly.
Thanks to response, Tharwat.
Re: LayCur to multiple objects
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
This is the tool.
Excellent.
Thanks Kent. ![]()
Re: LayCur to multiple objects
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
What's if one of these selected objects' layers is existed in a block ?
Re: LayCur to multiple objects
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
Good question.
Block layers do not change! ![]()
Re: LayCur to multiple objects
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
_Tharwat wrote:
jjorovi wrote:What's if one of these selected objects' layers is existed in a block ?
Good question.
Block layers do not change!
That's where LAYMRG does the most good [see the comments in my earlier post]. If you wanted to do that programmatically, I guess it would be possible, but it would require opening up every Block definition in the table, stepping through all the elements in each one, and changing the Layer of anything on the selected Layer.
Unfortunately, LAYMRG isn't a native AutoCAD Command, so you can't use it in a (command) function and feed in answers to its prompts. There may be some equivalent way to make use of it, but I don't know how [maybe a Search of the Discussion Group would find something...].
Re: LayCur to multiple objects
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
Try this please , and let me know your opinion .
(defun c:Test (/ ss cl i e lys lst sel in sel ent l)
(vl-load-com)
;;; Tharwat 19. September. 2012 ;;;
;;; This routine would change the layer of ;;;
;;; the selected objects to the current layer ;;;
;;; including all blocks ;;;
(if (not acdoc)
(setq acdoc (vla-get-activedocument (vlax-get-acad-object)))
)
(if (setq ss (ssget "_:L"))
(progn
(repeat (setq i (sslength ss))
(setq e (entget (ssname ss (setq i (1- i)))))
(if (not (member (cdr (assoc 8 e)) lst))
(setq lst (cons (cdr (assoc 8 e)) lst))
)
)
(foreach x lst (setq l (cons (strcat x ",") l)))
(setq lys (apply 'strcat l))
(setq cl (getvar 'clayer))
(if (setq
sel (ssget "_x"
(list (cons 8 (vl-string-right-trim "," lys)))
)
)
(repeat (setq in (sslength sel))
(setq ent (entget (ssname sel (setq in (1- in)))))
(entmod (subst (cons 8 cl) (assoc 8 ent) ent))
)
)
(vlax-for block (vla-get-blocks
acdoc
)
(if (and (eq :vlax-false (vla-get-isXref block))
(eq :vlax-false (vla-get-islayout block))
)
(vlax-for entity block
(if (member (vla-get-layer entity) lst)
(vla-put-layer entity cl)
)
)
)
)
)
)
(vla-regen acdoc AcAllviewports)
(princ)
)
Tharwat
Re: LayCur to multiple objects
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
It works fine.
Tested also with layers in nested blocks.
Thanks to collaborate Tharwat ![]()


