enthralled Posted December 29, 2018 Posted December 29, 2018 How can I make this work, given that I want to select the descriptive text object before executing this lisp, and the only prompt I want is to select the objects to be transferred into the new layer: ;;; LYRFRMTXT ;;; Written by David Forbus ;;; LYRFRMTXT prompts a user for a Text string ;;; LYRFRMTXT then prompts a user for an object and then ;;; modifies the layer of the entity to a layer named by the text string. (defun c:LYRFRMTXT (/ o1 o1n o2 o2n txt elist cntr) (setvar "cmdecho" 0) (setq o1(entget(car(entsel "\nPick descriptive Text object: ")))) (setq o1n(assoc 1 o1)) (setq txt(cdr o1n)) (princ "\n Select entities for layer change.") (if (setq o2n(ssget)) (progn (setq cntr 0) (while (< cntr (sslength o2n)) (setq o2(ssname o2n cntr)) (setq elist(entget o2)) (setq elist(subst (cons 8 txt)(assoc 8 elist) elist)) (entmod elist) (setq cntr(+ cntr 1)) ) ) (princ "\n select error") ) ) Quote
Emmanuel Delay Posted December 31, 2018 Posted December 31, 2018 Sure, you can always take the user input out of the function. LYRFRMTXT only needs the txt variable, you can provide it as a parameter. For example: c:LM1 contains what I took away from LYRFRMTXT . c:LM2 just permits you to hard code a layer (defun c:LM2 ( / ) (LYRFRMTXT "Layer1") ) (defun c:LM1 ( / o1 o1n txt) (setq o1 (entget(car(entsel "\nPick descriptive Text object: ")))) (setq o1n (assoc 1 o1)) (setq txt (cdr o1n)) (LYRFRMTXT txt) (princ) ) (defun LYRFRMTXT ( txt / o2 o2n elist cntr) (setvar "cmdecho" 0) (princ "\nSelect entities for layer change: ") (if (setq o2n (ssget)) (progn (setq cntr 0) (while (< cntr (sslength o2n)) (setq o2(ssname o2n cntr)) (setq elist(entget o2)) (setq elist(subst (cons 8 txt)(assoc 8 elist) elist)) (entmod elist) (setq cntr(+ cntr 1)) ) ) (princ "\n select error") ) ) 1 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.