<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Lisp to select all text on a layer in Visual LISP, AutoLISP and General Customization Forum</title>
    <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/lisp-to-select-all-text-on-a-layer/m-p/9635251#M72201</link>
    <description>&lt;P&gt;Thank you, problem solved!&lt;/P&gt;</description>
    <pubDate>Tue, 14 Jul 2020 18:42:53 GMT</pubDate>
    <dc:creator>Anonymous</dc:creator>
    <dc:date>2020-07-14T18:42:53Z</dc:date>
    <item>
      <title>Lisp to select all text on a layer</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/lisp-to-select-all-text-on-a-layer/m-p/9634788#M72193</link>
      <description>&lt;P&gt;I'm trying to determine if a lisp command exists that will allow me to select all text on a particular layer and add a "0" in front of all of the text?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;i have a plan with room numbers ex. 4567 and i need to add a 0 to all of the room numbers to make them five digits ex. 04567.&amp;nbsp; i know this may be impossible but thought i'd check before i took hours to change the numbers.&lt;/P&gt;</description>
      <pubDate>Tue, 14 Jul 2020 15:17:08 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/lisp-to-select-all-text-on-a-layer/m-p/9634788#M72193</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2020-07-14T15:17:08Z</dc:date>
    </item>
    <item>
      <title>Re: Lisp to select all text on a layer</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/lisp-to-select-all-text-on-a-layer/m-p/9634820#M72194</link>
      <description>&lt;P&gt;Try this&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="general"&gt;(defun c:test ( / ent lyr ss cnt el nt)

  (setq ent (car (entsel "\nSelect Text on Layer to Process : "))
        lyr (cdr (assoc 8 (entget ent)))
        ss (ssget "_X" (list '(0 . "TEXT") (cons 8 lyr)))
  )

  (cond (ss
          (repeat (setq cnt (sslength ss))
            (setq el (entget (ssname ss (setq cnt (1- cnt))))
                  nt (strcat "0" (cdr (assoc 1 el)))
            )
            (entmod (subst (cons 1 nt) (assoc 1 el) el))
          )
        )
  )
  (princ)
)&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The first prompt to select text requires a single text on the required layer. The lisp will find all text on that layer and put a "0" in front of it.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 14 Jul 2020 15:33:23 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/lisp-to-select-all-text-on-a-layer/m-p/9634820#M72194</guid>
      <dc:creator>dlanorh</dc:creator>
      <dc:date>2020-07-14T15:33:23Z</dc:date>
    </item>
    <item>
      <title>Re: Lisp to select all text on a layer</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/lisp-to-select-all-text-on-a-layer/m-p/9634874#M72195</link>
      <description>&lt;P&gt;Misread the request ... let me see if I can fix this within the next 24 minutes! &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Here we go!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="general"&gt;(defun c:foo (/ e el l s)
  ;; RJP » 2020-07-14
  (if (and (setq e (car (entsel "\Pick something to get the layer: ")))
	   (setq s (ssget ":L" (list '(0 . "TEXT") (assoc 8 (entget e)))))
      )
    (foreach e (vl-remove-if 'listp (mapcar 'cadr (ssnamex s)))
      (setq l (cdr (assoc 1 (setq el (entget e)))))
      (entmod (append el (list (cons 1 (strcat "0" l)))))
    )
  )
  (princ)
)&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 14 Jul 2020 16:24:39 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/lisp-to-select-all-text-on-a-layer/m-p/9634874#M72195</guid>
      <dc:creator>ronjonp</dc:creator>
      <dc:date>2020-07-14T16:24:39Z</dc:date>
    </item>
    <item>
      <title>Re: Lisp to select all text on a layer</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/lisp-to-select-all-text-on-a-layer/m-p/9634904#M72196</link>
      <description>&lt;LI-CODE lang="general"&gt;(DEFUN C:TEST ()
  (setq ss (ssget '((0 . "*TEXT"))))
(vlax-for tx (vla-get-activeselectionset (vla-get-activedocument (vlax-get-acad-object)))
  	(if  (not (distof (vla-get-textstring tx)))
          	(ssdel  (vlax-vla-object-&amp;gt;ename tx)  ss))
          )
  (SETQ	INDEX 0)
  (REPEAT (SSLENGTH SS)
    (SETQ ENAME	  (SSNAME SS INDEX)
	  DATA	  (ENTGET ENAME)
	  CONTENT (CDR (ASSOC 1 (ENTGET ENAME)))
	  NEWCONT (STRCAT "0" CONTENT)
	  INDEX	  (1+ INDEX)
	  NEWCONT (subst (cons 1 (STRCAT "0" CONTENT)) (assoc 1 DATA) DATA)
    )
    (entmod NEWCONT)
  )
)&lt;/LI-CODE&gt;</description>
      <pubDate>Tue, 14 Jul 2020 16:07:51 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/lisp-to-select-all-text-on-a-layer/m-p/9634904#M72196</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2020-07-14T16:07:51Z</dc:date>
    </item>
    <item>
      <title>Re: Lisp to select all text on a layer</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/lisp-to-select-all-text-on-a-layer/m-p/9634906#M72197</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/593837"&gt;@ronjonp&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Misread the request ... let me see if I can fix this within the next 24 minutes! &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;FONT size="3"&gt;Tik-tok&amp;nbsp;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/593837"&gt;@ronjonp&lt;/a&gt;&amp;nbsp;&amp;nbsp;&lt;/FONT&gt;&lt;span class="lia-unicode-emoji" title=":beaming_face_with_smiling_eyes:"&gt;😁&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 14 Jul 2020 16:08:52 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/lisp-to-select-all-text-on-a-layer/m-p/9634906#M72197</guid>
      <dc:creator>pbejse</dc:creator>
      <dc:date>2020-07-14T16:08:52Z</dc:date>
    </item>
    <item>
      <title>Re: Lisp to select all text on a layer</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/lisp-to-select-all-text-on-a-layer/m-p/9634944#M72198</link>
      <description>&lt;P&gt;@Anonymous&amp;nbsp;,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Welcome to the forums!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;It appears that everybody else is assuming that ALL of your text will ONLY be 4 digits long already.&lt;/P&gt;&lt;P&gt;This code will instead assume that your text can vary in length and account for that:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;EDIT:&lt;/P&gt;&lt;P&gt;I REALLY liked&amp;nbsp;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/593837"&gt;@ronjonp&lt;/a&gt;&amp;nbsp;'s method for getting the layer, so I incorporated that.&lt;/P&gt;&lt;PRE&gt;(defun c:ADDZERO ( / ss cnt e key txt diff)
  (if (and (setq e (car (entsel "\nSelect object on Layer: ")))&lt;BR /&gt;           (setq ss (ssget "_X" (list '(0 . "TEXT,MTEXT") (assoc 8 (entget e))))))&lt;BR /&gt;    (progn
      (repeat (setq cnt (sslength ss))
        (setq e (ssname ss (setq cnt (1- cnt))))
        (if (eq "MTEXT" (cdr (assoc 0 (entget e))))
          (setq key "Contents")
          (setq key "TextString")
        );if
        (setq txt (getpropertyvalue e key))
        (setq diff (- 5 (strlen txt)))
        (if (&amp;gt; diff 0)
          (progn
            (repeat diff (setq txt (strcat "0" txt)))
            (setpropertyvalue e key txt)
          );progn
        );if
      );repeat
      (prompt "\nComplete.")
    );progn
  ;else
    (prompt "\nNo Text found on the designated layer.")
  );if
  (princ)
);defun&lt;/PRE&gt;&lt;P&gt;Best,&lt;/P&gt;&lt;P&gt;~DD&lt;/P&gt;</description>
      <pubDate>Tue, 14 Jul 2020 16:26:58 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/lisp-to-select-all-text-on-a-layer/m-p/9634944#M72198</guid>
      <dc:creator>CodeDing</dc:creator>
      <dc:date>2020-07-14T16:26:58Z</dc:date>
    </item>
    <item>
      <title>Re: Lisp to select all text on a layer</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/lisp-to-select-all-text-on-a-layer/m-p/9634976#M72199</link>
      <description>&lt;P&gt;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/5680873"&gt;@CodeDing&lt;/a&gt;&amp;nbsp; Nice idea &lt;span class="lia-unicode-emoji" title=":beer_mug:"&gt;🍺&lt;/span&gt;. Here's my offering that's a bit less restrictive. Still not doing MTEXT since my guess is the next question will be related to hardcoded formatting and the code not working.&lt;/P&gt;&lt;LI-CODE lang="general"&gt;(defun c:foo (/ e el l s)
  ;; RJP » 2020-07-14
  (if (and (setq e (car (entsel "\Pick something to get the layer: ")))
	   (setq s (ssget ":L" (list '(0 . "TEXT") (assoc 8 (entget e)) '(1 . "~0*"))))
      )
    (foreach e (vl-remove-if 'listp (mapcar 'cadr (ssnamex s)))
      (setq l (cdr (assoc 1 (setq el (entget e)))))
      (if (vl-every '(lambda (x) (&amp;lt;= 48 x 57)) (vl-string-&amp;gt;list l))
	(entmod (append el (list (cons 1 (strcat "0" l)))))
      )
    )
  )
  (princ)
)&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 14 Jul 2020 16:32:15 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/lisp-to-select-all-text-on-a-layer/m-p/9634976#M72199</guid>
      <dc:creator>ronjonp</dc:creator>
      <dc:date>2020-07-14T16:32:15Z</dc:date>
    </item>
    <item>
      <title>Re: Lisp to select all text on a layer</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/lisp-to-select-all-text-on-a-layer/m-p/9635005#M72200</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/5680873"&gt;@CodeDing&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;It appears that everybody else is assuming that ALL of your text will ONLY be 4 digits long already.&lt;/P&gt;
&lt;P&gt;This code will instead assume that your text can vary in length and account for that:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&lt;FONT size="3"&gt;You think thats bad. Then mine is worst, I assumed its targetting specific values&amp;nbsp;&lt;/FONT&gt;&lt;span class="lia-unicode-emoji" title=":beaming_face_with_smiling_eyes:"&gt;😁&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="general"&gt;(defun c:demo (/ ent data ss nstr i e )
  (if
    (and
      (setq ent (car (entsel "\nSelect Text ")))
      (setq ent	 (entget ent)
	    data (mapcar '(lambda (d) (assoc d ent)) '(1 8))
      )
      (setq nstr (cons 1 (strcat "0" (Cdr (car data)))))
      (setq ss (ssget "_X" (append '((0 . "TEXT")) data)))
    )
     (repeat (setq i (sslength ss))
      (Setq e (entget (ssname ss (setq i (1- i)))))
       (entmod (subst nstr (assoc 1 e) e))
    )
  )
  (princ)
)&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 14 Jul 2020 16:46:53 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/lisp-to-select-all-text-on-a-layer/m-p/9635005#M72200</guid>
      <dc:creator>pbejse</dc:creator>
      <dc:date>2020-07-14T16:46:53Z</dc:date>
    </item>
    <item>
      <title>Re: Lisp to select all text on a layer</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/lisp-to-select-all-text-on-a-layer/m-p/9635251#M72201</link>
      <description>&lt;P&gt;Thank you, problem solved!&lt;/P&gt;</description>
      <pubDate>Tue, 14 Jul 2020 18:42:53 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/lisp-to-select-all-text-on-a-layer/m-p/9635251#M72201</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2020-07-14T18:42:53Z</dc:date>
    </item>
  </channel>
</rss>

