Visual LISP, AutoLISP and General Customization
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

lisp to find mtext and put it on another layer that exist

4 REPLIES 4
SOLVED
Reply
Message 1 of 5
dglenn9000
334 Views, 4 Replies

lisp to find mtext and put it on another layer that exist

I am trying to create a simple lisp that will find a mtext with the string "design variance" and  put that mtext on an existing layer called Project. I always have trouble with scripts that have to find or get something. 

 

Thanks

 

 

4 REPLIES 4
Message 2 of 5
rkmcswain
in reply to: dglenn9000

Quick and dirty, no error checking, and may not work if the mtext string is > 255 characters

 

(vl-cmdf "._change"
	 (ssget "_X" '((0 . "MTEXT")(1 . "*DESIGN VARIANCE*")))
	 ""
	 "_P"
	 "_LA"
	 "Project"
	 ""
	 "")

 

R.K. McSwain     | CADpanacea | on twitter
Message 3 of 5
hmsilva
in reply to: dglenn9000


@dglenn9000 wrote:

I am trying to create a simple lisp that will find a mtext with the string "design variance" and  put that mtext on an existing layer called Project. I always have trouble with scripts that have to find or get something.  


Another, also quick and dirty, no error checking...

 

(defun c:test (/ ent i ss)
  (if (setq ss (ssget "X" '((0 . "MTEXT") (1 . "*design variance*"))))
    (repeat (setq i (sslength ss))
      (setq ent (entget (ssname ss (setq i (1- i)))))
      (entmod (subst (cons 8 "Project") (assoc 8 ent) ent))
    )
  )
  (princ)
)

 

If the layer Project does not exist, will be created.

 

HTH
Henrique

EESignature

Message 4 of 5
dglenn9000
in reply to: dglenn9000

Thanks rkmcswain and hmsilva.  Both of these do exactly what I need it to.

 

Message 5 of 5
hmsilva
in reply to: dglenn9000

You're welcome, dglenn9000
Glad I could help

Henrique

EESignature

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report

”Boost