Jump to content

Recommended Posts

Posted

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")
)
)

 

Posted

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")
  )
)

  • Like 1

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