<?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: Modify texts in a dwg file in Visual LISP, AutoLISP and General Customization Forum</title>
    <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/modify-texts-in-a-dwg-file/m-p/8418361#M96300</link>
    <description>&lt;PRE&gt;(defun c:RoundFirstNumber ( / dz ss i ed tx mx dc)
  
  (setq dz (getvar 'dimzin))
  (setvar 'dimzin 0)
  
  (if (and (setq ss (ssget '((0 . "MTEXT") (1 . "#*"))))
           (setq mx 0)
           (repeat (setq i (sslength ss))
             (setq tx (cdr (assoc 1 (entget (ssname ss (setq i (1- i))))))
                   mx (max mx
                           (if (vl-string-search "." tx) 		; if the are decimals
                             (- (cond ((vl-string-search "x" tx))	; then substruct from x position
                                      ((strlen tx)))			;      or from last position if there is no x
                                (1+ (vl-string-search "." tx)))		;      the position of delimiter
                             0))))					; else, use 0 as no decimal
           (setq dc (cond ((getint (strcat "\nNumber of decimal places &amp;lt;" (itoa mx) "&amp;gt;: ")))
                          (mx)))
           )
    (repeat (setq i (sslength ss))
      (setq ed (entget (ssname ss (setq i (1- i)))))
      (entmod (append (subst (cons 1 (rtos (atof (cdr (assoc 1 ed))) 2 dc))
			     (assoc 1 ed)
			     ed)
		      '((41 . 0.) (71 . 5) (72 . 5) (75 . 0))))))
  
  (setvar 'dimzin dz)
  (princ)
  )&lt;/PRE&gt;</description>
    <pubDate>Thu, 22 Nov 2018 09:44:52 GMT</pubDate>
    <dc:creator>ВeekeeCZ</dc:creator>
    <dc:date>2018-11-22T09:44:52Z</dc:date>
    <item>
      <title>Modify texts in a dwg file</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/modify-texts-in-a-dwg-file/m-p/8417192#M96294</link>
      <description>&lt;P&gt;Hello boys how are you.&lt;/P&gt;
&lt;P&gt;You could help me with a routine to modify some texts.&lt;/P&gt;
&lt;P&gt;I will attach a dwg so you can understand me.&lt;/P&gt;
&lt;P&gt;Thank you.&lt;/P&gt;
&lt;P&gt;Excuse my English, I only speak Spanish. &lt;span class="lia-unicode-emoji" title=":disappointed_face:"&gt;😞&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 21 Nov 2018 18:49:38 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/modify-texts-in-a-dwg-file/m-p/8417192#M96294</guid>
      <dc:creator>carlos_m_gil_p</dc:creator>
      <dc:date>2018-11-21T18:49:38Z</dc:date>
    </item>
    <item>
      <title>Re: Modify texts in a dwg file</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/modify-texts-in-a-dwg-file/m-p/8417269#M96295</link>
      <description>&lt;P&gt;code edited.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;(defun c:FixNumbers ( / dz ss i ed tx)
  
  (setq dz (getvar 'dimzin))
  (setvar 'dimzin 0)
  (if (setq ss (ssget '((0 . "*TEXT") (1 . "#*"))))
    (repeat (setq i (sslength ss))
      (setq ed (entget (ssname ss (setq i (1- i)))))
      (entmod (append (subst (cons 1 (rtos (atof (cdr (assoc 1 ed))) 2 3))
			     (assoc 1 ed)
			     ed)
		      '((41 . 0.) (71 . 5) (72 . 5) (75 . 0))))))
  
  (setvar 'dimzin dz)
  (princ)
  )&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 21 Nov 2018 19:40:01 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/modify-texts-in-a-dwg-file/m-p/8417269#M96295</guid>
      <dc:creator>ВeekeeCZ</dc:creator>
      <dc:date>2018-11-21T19:40:01Z</dc:date>
    </item>
    <item>
      <title>Re: Modify texts in a dwg file</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/modify-texts-in-a-dwg-file/m-p/8417298#M96296</link>
      <description>&lt;P&gt;In very simplest terms, try this:&lt;/P&gt;
&lt;PRE&gt;(defun C:TEST ()
  (setq
    ss (ssget ":L" '((0 . "MTEXT")))
    dec (getint "\nNumber of decimal places: ")
  )
  (repeat (setq n (sslength ss))
    (setq txt (vlax-ename-&amp;gt;vla-object (ssname ss (setq n (1- n)))))
    (vla-put-TextString txt (rtos (atof (vla-get-TextString txt)) 2 dec))
    (vla-put-AttachmentPoint txt 5)&lt;FONT color="#999999"&gt;; middle-center justification&lt;/FONT&gt;
  )
)&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Set DIMZIN to some value to include trailing zeros, such as 3 [that could be built in if you want].&amp;nbsp; It depends on their being Mtext only, not plain Text.&amp;nbsp; And it depends on their all starting with numbers -- (atof) very conveniently translates only as far as numbers go, so there's no need to search for where the x is.&lt;/P&gt;</description>
      <pubDate>Wed, 21 Nov 2018 19:51:38 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/modify-texts-in-a-dwg-file/m-p/8417298#M96296</guid>
      <dc:creator>Kent1Cooper</dc:creator>
      <dc:date>2018-11-21T19:51:38Z</dc:date>
    </item>
    <item>
      <title>Re: Modify texts in a dwg file</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/modify-texts-in-a-dwg-file/m-p/8417369#M96297</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/1779365"&gt;@ВeekeeCZ&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;....&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;....&lt;BR /&gt;		      '((41 . 0.) (71 . 5) (72 . 5) (75 . 0))))))
....&lt;/PRE&gt;
&lt;HR /&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;That may be appropriate for Mtext, but not for Text [which&amp;nbsp;is permitted in the selection, but shouldn't be if this is how it changes the justification].&amp;nbsp; The justification of plain Text is stored in a combination of the 72- and 73-code entries.&lt;/P&gt;</description>
      <pubDate>Wed, 21 Nov 2018 19:59:51 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/modify-texts-in-a-dwg-file/m-p/8417369#M96297</guid>
      <dc:creator>Kent1Cooper</dc:creator>
      <dc:date>2018-11-21T19:59:51Z</dc:date>
    </item>
    <item>
      <title>Re: Modify texts in a dwg file</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/modify-texts-in-a-dwg-file/m-p/8417903#M96298</link>
      <description>&lt;P&gt;Hello how are you.&lt;BR /&gt;Thanks for the help, both solutions work very well.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;One more question.&lt;/P&gt;
&lt;P&gt;There is some way to know which is the largest number of decimals that the selected text has.&lt;/P&gt;
&lt;P&gt;For example:&lt;BR /&gt;In the file that I had attached, of the original texts the one with the highest decimals was 3 decimals.&lt;BR /&gt;I ask this, because it would be the value that I would use to put the number of decimals to the new texts.&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt;Thank you.&lt;/P&gt;</description>
      <pubDate>Thu, 22 Nov 2018 02:53:18 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/modify-texts-in-a-dwg-file/m-p/8417903#M96298</guid>
      <dc:creator>carlos_m_gil_p</dc:creator>
      <dc:date>2018-11-22T02:53:18Z</dc:date>
    </item>
    <item>
      <title>Re: Modify texts in a dwg file</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/modify-texts-in-a-dwg-file/m-p/8418059#M96299</link>
      <description>&lt;P&gt;Hi&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;For.....&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;BLOCKQUOTE&gt;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/2573929"&gt;@carlos_m_gil_p&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
...................
&lt;P&gt;One more question.&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#FF0000"&gt;There is some way to know which is the largest number of decimals that the selected text has.&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;For example:&lt;BR /&gt;&lt;FONT color="#FF0000"&gt;In the file that I had attached, of the original texts the one with the highest decimals was 3 decimals.&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#FF0000"&gt;I ask this, because it would be the value that I would use to put the number of decimals to the new texts.&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;.......................&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Try this........(For your particular type of drawings).....lightly tested&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;(defun C:CHN (/)
  (setq ss (ssget ":L" '((0 . "*TEXT"))))
  (setq dec 0)
  (repeat (setq n1 (sslength ss))
    (setq txt (vlax-ename-&amp;gt;vla-object (ssname ss (setq n1 (1- n1)))))
    (setq NO (vla-get-TextString txt))
    (setq lst1 (parse NO "."))
    (setq DP (- (strlen (rtos (atoi (nth 1 lst1)) 2 1)) 2))
    (if (&amp;gt; DP dec) (setq dec DP))
  )
  (repeat (setq n (sslength ss))
    (setq txt (vlax-ename-&amp;gt;vla-object (ssname ss (setq n (1- n)))))
    (vla-put-TextString txt (rtos (atof (vla-get-TextString txt)) 2 dec))
  )
(command "_.justifytext" ss "" "M")  
)
(defun parse (str delim / lst pos)
(setq pos (vl-string-search delim str))
   (while (&amp;gt; pos 0)
	(setq lst (cons (substr str 1 pos) lst)
	      str (substr str (+ pos 2))
              pos (vl-string-search delim str)
	)
   )
(if (&amp;gt; (strlen str) 0)(setq lst (cons str lst)))
(reverse lst)
)
&lt;/PRE&gt;</description>
      <pubDate>Thu, 22 Nov 2018 06:50:58 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/modify-texts-in-a-dwg-file/m-p/8418059#M96299</guid>
      <dc:creator>dbhunia</dc:creator>
      <dc:date>2018-11-22T06:50:58Z</dc:date>
    </item>
    <item>
      <title>Re: Modify texts in a dwg file</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/modify-texts-in-a-dwg-file/m-p/8418361#M96300</link>
      <description>&lt;PRE&gt;(defun c:RoundFirstNumber ( / dz ss i ed tx mx dc)
  
  (setq dz (getvar 'dimzin))
  (setvar 'dimzin 0)
  
  (if (and (setq ss (ssget '((0 . "MTEXT") (1 . "#*"))))
           (setq mx 0)
           (repeat (setq i (sslength ss))
             (setq tx (cdr (assoc 1 (entget (ssname ss (setq i (1- i))))))
                   mx (max mx
                           (if (vl-string-search "." tx) 		; if the are decimals
                             (- (cond ((vl-string-search "x" tx))	; then substruct from x position
                                      ((strlen tx)))			;      or from last position if there is no x
                                (1+ (vl-string-search "." tx)))		;      the position of delimiter
                             0))))					; else, use 0 as no decimal
           (setq dc (cond ((getint (strcat "\nNumber of decimal places &amp;lt;" (itoa mx) "&amp;gt;: ")))
                          (mx)))
           )
    (repeat (setq i (sslength ss))
      (setq ed (entget (ssname ss (setq i (1- i)))))
      (entmod (append (subst (cons 1 (rtos (atof (cdr (assoc 1 ed))) 2 dc))
			     (assoc 1 ed)
			     ed)
		      '((41 . 0.) (71 . 5) (72 . 5) (75 . 0))))))
  
  (setvar 'dimzin dz)
  (princ)
  )&lt;/PRE&gt;</description>
      <pubDate>Thu, 22 Nov 2018 09:44:52 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/modify-texts-in-a-dwg-file/m-p/8418361#M96300</guid>
      <dc:creator>ВeekeeCZ</dc:creator>
      <dc:date>2018-11-22T09:44:52Z</dc:date>
    </item>
    <item>
      <title>Re: Modify texts in a dwg file</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/modify-texts-in-a-dwg-file/m-p/8418873#M96301</link>
      <description>&lt;P&gt;Hi brother.&lt;BR /&gt;Thank you very much, it works very well.&lt;/P&gt;</description>
      <pubDate>Thu, 22 Nov 2018 14:19:26 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/modify-texts-in-a-dwg-file/m-p/8418873#M96301</guid>
      <dc:creator>carlos_m_gil_p</dc:creator>
      <dc:date>2018-11-22T14:19:26Z</dc:date>
    </item>
    <item>
      <title>Re: Modify texts in a dwg file</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/modify-texts-in-a-dwg-file/m-p/8418941#M96302</link>
      <description>&lt;P&gt;Hello dbhunia.&lt;BR /&gt;Thanks for your help and help too.&lt;BR /&gt;I did the test but it did not work.&lt;BR /&gt;I do not know why.&lt;BR /&gt;Anyway later I review it calmly.&lt;BR /&gt;Thanks anyway.&lt;/P&gt;</description>
      <pubDate>Thu, 22 Nov 2018 15:01:38 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/modify-texts-in-a-dwg-file/m-p/8418941#M96302</guid>
      <dc:creator>carlos_m_gil_p</dc:creator>
      <dc:date>2018-11-22T15:01:38Z</dc:date>
    </item>
    <item>
      <title>Re: Modify texts in a dwg file</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/modify-texts-in-a-dwg-file/m-p/8419043#M96303</link>
      <description>&lt;P&gt;Hi&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You are right in your drawing .......&lt;STRONG&gt;"DIMZIN"&amp;nbsp; is set to "8"&lt;/STRONG&gt;...... I forgot to take care of that......&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Capture.PNG" style="width: 304px;"&gt;&lt;img src="https://forums.autodesk.com/t5/image/serverpage/image-id/572602i65631CF7E151CF28/image-size/large?v=v2&amp;amp;px=999" role="button" title="Capture.PNG" alt="Capture.PNG" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Now I&amp;nbsp;&lt;SPAN&gt;take care of that...... Try this.......&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;(defun C:CHN (/)
  &lt;FONT color="#FF0000"&gt;(setq DIM (getvar 'dimzin))
  (setvar 'dimzin 0)&lt;/FONT&gt;
  (setvar 'cmdecho 0)
  (setq ss (ssget ":L" '((0 . "*TEXT"))))
  (setq dec 0)
  (repeat (setq n1 (sslength ss))
    (setq txt (vlax-ename-&amp;gt;vla-object (ssname ss (setq n1 (1- n1)))))
    (setq NO (vla-get-TextString txt))
    (setq lst1 (parse NO "."))
    (setq DP (- (strlen (rtos (atoi (nth 1 lst1)) 2 1)) 2))
    (if (&amp;gt; DP dec) (setq dec DP))
  )
  (repeat (setq n (sslength ss))
    (setq txt (vlax-ename-&amp;gt;vla-object (ssname ss (setq n (1- n)))))
    (vla-put-TextString txt (rtos (atof (vla-get-TextString txt)) 2 dec))
  )
(command "_.justifytext" ss "" "M") 
&lt;FONT color="#FF0000"&gt;(setvar 'dimzin DIM)&lt;/FONT&gt; 
(setvar 'cmdecho 1)
(princ)
)
(defun parse (str delim / lst pos)
(setq pos (vl-string-search delim str))
   (while (&amp;gt; pos 0)
	(setq lst (cons (substr str 1 pos) lst)
	      str (substr str (+ pos 2))
              pos (vl-string-search delim str)
	)
   )
(if (&amp;gt; (strlen str) 0)(setq lst (cons str lst)))
(reverse lst)
)&lt;/PRE&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>Thu, 22 Nov 2018 15:44:45 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/modify-texts-in-a-dwg-file/m-p/8419043#M96303</guid>
      <dc:creator>dbhunia</dc:creator>
      <dc:date>2018-11-22T15:44:45Z</dc:date>
    </item>
    <item>
      <title>Re: Modify texts in a dwg file</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/modify-texts-in-a-dwg-file/m-p/8419394#M96304</link>
      <description>&lt;P&gt;Thanks for your solution.&lt;BR /&gt;It also works very well for me.&lt;BR /&gt;Greetings.&lt;/P&gt;</description>
      <pubDate>Thu, 22 Nov 2018 19:36:54 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/modify-texts-in-a-dwg-file/m-p/8419394#M96304</guid>
      <dc:creator>carlos_m_gil_p</dc:creator>
      <dc:date>2018-11-22T19:36:54Z</dc:date>
    </item>
  </channel>
</rss>

