Caracolalbino Posted June 22, 2022 Posted June 22, 2022 Hi, I'm kind of new to the forum, and I was looking for a routine that allows me to select one object and swap its layer with another objects' current one. Is it something that has been done? So far, I haven't found any built-in commands that do this, but I just might haven't searched thoroughly enough. Anyhow, thanks in advance! Quote
mhupp Posted June 22, 2022 Posted June 22, 2022 (edited) Its easy enough to do but are we talking about one layer or multiple layers? if its multiple layers what layer goes where? Sorry you said object I was thinking blocks. ;;----------------------------------------------------------------------------;; ;; SWITCH LAYERS BETWEEN OBJECTS (defun C:SwapLayer (/ OA OB LA LB) (setq OA (car (entsel "\nSelect first object: ")) LA (cdr (assoc 8 (setq OA (entget OA)))) OB (car (entsel "\nSelect second object: ")) LB (cdr (assoc 8 (setq OB (entget OB)))) ) (if (eq LA LB) (prompt "\nBoth Entities are on same layer") (progn (entmod (subst (cons 8 LB) (assoc 8 OA) OA)) (entmod (subst (cons 8 LA) (assoc 8 OB) OB)) ) ) (princ) ) Edited June 22, 2022 by mhupp 1 1 Quote
Caracolalbino Posted June 22, 2022 Author Posted June 22, 2022 Wonderful, works like a charm! I really need to learn how to write lisp routines, what would you say would be the best way for someone to get started on the language/syntax? 1 Quote
mhupp Posted June 23, 2022 Posted June 23, 2022 18 minutes ago, Caracolalbino said: Wonderful, works like a charm! I really need to learn how to write lisp routines, what would you say would be the best way for someone to get started on the language/syntax? https://www.afralisp.net/ is nice with simple step by step instructions. https://www.cadtutor.net/tutorials/autolisp/quick-start.php also good start but one page. Coming to the forums regularly to see how people problem solve. look for answer from people with high scores. there are multiple ways to code things in lisp. usually it comes down to performance (what runs the fastest) but depending on user preference or other factors one type of code might win out over a faster code. Reading over the functions to understand how to use them. https://help.autodesk.com/view/OARX/2023/ENU/?guid=GUID-4CEE5072-8817-4920-8A2D-7060F5E16547 Welcome and hope to see you around. 4 Quote
BIGAL Posted June 23, 2022 Posted June 23, 2022 Get a copy of Notepad++ a text editor has functions built in that helps when writing lisp's. A lot of us use it. 2 Quote
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.