Author Topic: label xref layer  (Read 1842 times)

0 Members and 1 Guest are viewing this topic.

A_LOTA_NOTA

  • Guest
label xref layer
« on: March 21, 2011, 10:56:48 AM »
I can't think of a time I have ever needed something like this but a coworker asked for it. Someone had already done most of the code I just tried to make it work with xrefs also. I like to post things here to see how others would do it. Normally I find it could be done with a lot less code.

So here it is...

Code: [Select]
(defun c:LABEL (/ culay lead clay omode a a1 ent entl txt position pt1 pt2)
  (setvar "CMDECHO" 0)
  (setq culay (getvar "users1"))
  (setq lead (getvar "users2"))
  (setq clay (getvar "clayer")) 
  (setq omode (getvar "osmode"))
  (prompt (strcat "\nEnter Layer for label:" "<" culay ">")) 
  (setq a (getstring))
  (setq a1 (if (= a "") culay a))
  (setvar "users1" a1)
  (setvar "clayer" a1)
  (setvar "osmode" 0)
  (command "._mspace") 
  (cond
    ((setq ent (entsel))
     (setq entl (entget (car ent)))
     (and (= "INSERT" (cdr (assoc 0 entl))) (setq ient (nentselp (cadr ent))) (setq entl (entget (car ient))))
     (setq txt (cdr (assoc 8 entl)))
     (if (setq position (vl-string-position (ascii "|") txt))
       (setq txt (substr txt (+ position 2)))
       ); end if
     (command "._pspace")
     (command "._dim1" "_l" (getpoint "\nEnter Leader Start Point: ") (getpoint "\nEnter Possition For label: ") "" txt)
     )
    ) ; end cond
  (setvar "osmode" omode)
  (setvar "clayer" clay)
  (setvar "CMDECHO" 1)
  (princ)
  ); end defun

Matt__W

  • Seagull
  • Posts: 12955
  • I like my water diluted.
Re: label xref layer
« Reply #1 on: March 21, 2011, 10:57:53 AM »
You spelled "POSITION" wrong.   :wink:
Autodesk Expert Elite
Revit Subject Matter Expert (SME)
Owner/FAA sUAS Pilot @ http://skyviz.io