Author Topic: Need to lurn..  (Read 5795 times)

0 Members and 1 Guest are viewing this topic.

Andrea

  • Water Moccasin
  • Posts: 2372
Re: Need to lurn..
« Reply #15 on: November 24, 2005, 05:36:14 PM »
Oops, sorry..to much work i think.. :-D

by the way...

I have an error when trying to rename a layer who already exist..
I think I need to remake my routine... :-P
Keep smile...

Royalchill

  • Guest
Re: Need to lurn..
« Reply #16 on: November 29, 2005, 01:32:05 PM »
I found this old lisp. I did not write it but it works perfect. Hope it is some help

;At the command line, type (load "c:/lispdir/RENLYR")
;where c:/ is the drive where RENLYR.lsp is contained
;where lispdir/ is the directory where RENLYR.lsp is contained

(Defun C:RENLYR (/ e e-inf e-lyr txtlist sstxt sse see-inf sse-txt)
  (prompt "\n")
  (princ)
  (while (= (setq e (car (entsel "\rSelect entity of layer to rename: "))) nil))
  (setq
    e-inf (entget e)
    e-lyr (cdr (assoc 8 e-inf))
  )
  (if (/= e-lyr "0")
    (progn
      (setq txtlist (list (cons 0 "TEXT") (cons 1 e-lyr) (cons 10 (getvar "viewctr")) (cons 40 0.000001) (cons 50 0.0)))
      (entmake txtlist)
      (setq sstxt (entlast))
      (command "ddedit" sstxt "")
      (setq
        sse (entlast)
        sse-inf (entget sse)
        sse-txt (cdr (assoc 1 sse-inf))
      )
      (if (and (/= (strcase sse-txt) (strcase e-lyr)) (/= sse-txt "") (= (wcmatch sse-txt "* *") nil))
        (command "rename" "layer" e-lyr sse-txt)
        (cond
          ((= (strcase sse-txt) (strcase e-lyr))
              (prompt "\nLayer name has not been modified, name is identical")
              (princ)
           )
          ((= sse-txt "")
              (prompt "\nLayer name has not been modified, nil length string")
              (princ)
           )
          ((/= (wcmatch sse-txt "* *") nil)
              (prompt "\nLayer name has not been modified, name has space")
              (princ)
           )
         )
      )
      (command "erase" sstxt "")
    )
    (progn
      (if (= e-lyr "0")
        (progn
          (prompt "\nCannot rename layer 0")
          (princ)
        )
      )
    )
  )
  (princ)
)