<?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: Text string to a field IF/THEN condition in Visual LISP, AutoLISP and General Customization Forum</title>
    <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/text-string-to-a-field-if-then-condition/m-p/13386994#M1626</link>
    <description>&lt;P&gt;Thanks for your reply.&lt;/P&gt;&lt;P&gt;The expression don't work, keep the same&amp;nbsp;&lt;SPAN&gt;"$(IF,??) " error.&lt;BR /&gt;Now there's something I found... if I replace alphabetic (e.g., RED) for a numeric value (e.g., 01), it works...&lt;BR /&gt;So, the problem is there... extracted substring alphabetic/numeric comparation...&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Any clue?&lt;/SPAN&gt;&lt;/P&gt;</description>
    <pubDate>Mon, 24 Mar 2025 12:15:44 GMT</pubDate>
    <dc:creator>PauloMiranda8553</dc:creator>
    <dc:date>2025-03-24T12:15:44Z</dc:date>
    <item>
      <title>Text string to a field IF/THEN condition</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/text-string-to-a-field-if-then-condition/m-p/13386893#M1624</link>
      <description>&lt;P&gt;I need some help here, I'm trying to set a text string to a field that read a 2 characters from the file name. Kinda of read characters 12 and 13, and if content is RD, the value should be RED, if YL, Yellow, GR - Green, and so on. I have 5 or 6 possible values.&lt;BR /&gt;&lt;BR /&gt;The file name is like:&amp;nbsp;X-25-034-A-PE-PGR-.dwg&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I alread set this, but always get a&amp;nbsp;&amp;nbsp;"$(IF,??) " error:&lt;BR /&gt;&lt;SPAN&gt;$(IF,$(=$(substr,$(getvar,dwgname),12,2)RD),"RED")&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;The IF/THEN is correct?&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Can a text string be assigned to the field? Is this the way?&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Help will be very apreciated.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Thanks to all.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Paulo Miranda&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 24 Mar 2025 11:10:15 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/text-string-to-a-field-if-then-condition/m-p/13386893#M1624</guid>
      <dc:creator>PauloMiranda8553</dc:creator>
      <dc:date>2025-03-24T11:10:15Z</dc:date>
    </item>
    <item>
      <title>Re: Text string to a field IF/THEN condition</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/text-string-to-a-field-if-then-condition/m-p/13386950#M1625</link>
      <description>&lt;P&gt;From chatGPT:&lt;BR /&gt;&lt;BR /&gt;You're on the right track, but the issue comes from how the string comparison is done in AutoCAD fields. The $(IF) function expects a specific format, and the way you're trying to compare the substring isn't quite right.&lt;/P&gt;&lt;P&gt;Here's an improved version of your field expression:&lt;/P&gt;&lt;PRE&gt;$(IF,$(=,$(substr,$(getvar,dwgname),12,2),RD),RED, $(IF,$(=,$(substr,$(getvar,dwgname),12,2),YL),Yellow, $(IF,$(=,$(substr,$(getvar,dwgname),12,2),GR),Green, Other)))&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Explanation:&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;$(substr,$(getvar,dwgname),12,2) gets the substring starting from the 12th character and extracts 2 characters.&lt;/LI&gt;&lt;LI&gt;$(=, ...) compares the extracted substring to a specific value (e.g., RD, YL, GR).&lt;/LI&gt;&lt;LI&gt;$(IF, ...) checks if the condition is true. If it is, it returns the first value (e.g., RED). If it's false, it checks the next condition.&lt;/LI&gt;&lt;LI&gt;I've added an Other value at the end for any unmatched cases.&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;This expression should work, provided the file name is correct and consistent with your pattern. It will check for RD, YL, and GR, and return the corresponding color name.&lt;/P&gt;</description>
      <pubDate>Mon, 24 Mar 2025 11:55:00 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/text-string-to-a-field-if-then-condition/m-p/13386950#M1625</guid>
      <dc:creator>Brock_Olly</dc:creator>
      <dc:date>2025-03-24T11:55:00Z</dc:date>
    </item>
    <item>
      <title>Re: Text string to a field IF/THEN condition</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/text-string-to-a-field-if-then-condition/m-p/13386994#M1626</link>
      <description>&lt;P&gt;Thanks for your reply.&lt;/P&gt;&lt;P&gt;The expression don't work, keep the same&amp;nbsp;&lt;SPAN&gt;"$(IF,??) " error.&lt;BR /&gt;Now there's something I found... if I replace alphabetic (e.g., RED) for a numeric value (e.g., 01), it works...&lt;BR /&gt;So, the problem is there... extracted substring alphabetic/numeric comparation...&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Any clue?&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 24 Mar 2025 12:15:44 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/text-string-to-a-field-if-then-condition/m-p/13386994#M1626</guid>
      <dc:creator>PauloMiranda8553</dc:creator>
      <dc:date>2025-03-24T12:15:44Z</dc:date>
    </item>
    <item>
      <title>Re: Text string to a field IF/THEN condition</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/text-string-to-a-field-if-then-condition/m-p/13387300#M1627</link>
      <description>&lt;P&gt;Make any difference if surround the characters with quotes?&lt;/P&gt;&lt;LI-CODE lang="general"&gt;$(IF,$(=,$(substr,$(getvar,dwgname),12,2),"RD"),"RED")&lt;/LI-CODE&gt;</description>
      <pubDate>Mon, 24 Mar 2025 14:42:14 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/text-string-to-a-field-if-then-condition/m-p/13387300#M1627</guid>
      <dc:creator>paullimapa</dc:creator>
      <dc:date>2025-03-24T14:42:14Z</dc:date>
    </item>
    <item>
      <title>Re: Text string to a field IF/THEN condition</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/text-string-to-a-field-if-then-condition/m-p/13387324#M1628</link>
      <description>&lt;P&gt;If Pauls doesn't work, does this work?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="general"&gt;$(IF,$(=,$(substr,$(getvar,dwgname),12,2),RD),"RED",$(IF,$(=,$(substr,$(getvar,dwgname),12,2),YL),"Yellow",$(IF,$(=,$(substr,$(getvar,dwgname),12,2),GR),"Green","Other"))))&lt;/LI-CODE&gt;</description>
      <pubDate>Mon, 24 Mar 2025 14:48:36 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/text-string-to-a-field-if-then-condition/m-p/13387324#M1628</guid>
      <dc:creator>Brock_Olly</dc:creator>
      <dc:date>2025-03-24T14:48:36Z</dc:date>
    </item>
    <item>
      <title>Re: Text string to a field IF/THEN condition</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/text-string-to-a-field-if-then-condition/m-p/13387398#M1629</link>
      <description>&lt;P&gt;Nope... &lt;span class="lia-unicode-emoji" title=":crying_face:"&gt;😢&lt;/span&gt;&lt;span class="lia-unicode-emoji" title=":crying_face:"&gt;😢&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 24 Mar 2025 15:14:45 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/text-string-to-a-field-if-then-condition/m-p/13387398#M1629</guid>
      <dc:creator>PauloMiranda8553</dc:creator>
      <dc:date>2025-03-24T15:14:45Z</dc:date>
    </item>
    <item>
      <title>Re: Text string to a field IF/THEN condition</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/text-string-to-a-field-if-then-condition/m-p/13387399#M1630</link>
      <description>&lt;P&gt;No, either way...&lt;BR /&gt;&lt;BR /&gt;So strange...&lt;/P&gt;</description>
      <pubDate>Mon, 24 Mar 2025 15:15:09 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/text-string-to-a-field-if-then-condition/m-p/13387399#M1630</guid>
      <dc:creator>PauloMiranda8553</dc:creator>
      <dc:date>2025-03-24T15:15:09Z</dc:date>
    </item>
    <item>
      <title>Re: Text string to a field IF/THEN condition</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/text-string-to-a-field-if-then-condition/m-p/13387407#M1631</link>
      <description>&lt;P&gt;&lt;STRONG&gt;Workaround Approach&lt;/STRONG&gt;&lt;/P&gt;&lt;OL&gt;&lt;LI&gt;&lt;P&gt;&lt;STRONG&gt;Create a field to extract the substring&lt;/STRONG&gt; (store it in a hidden attribute or text field):&lt;/P&gt;&lt;PRE&gt;$(substr,$(getvar,dwgname),12,2)&lt;/PRE&gt;&lt;UL&gt;&lt;LI&gt;This extracts the 12th and 13th characters from the drawing name.&lt;/LI&gt;&lt;/UL&gt;&lt;/LI&gt;&lt;LI&gt;&lt;P&gt;&lt;STRONG&gt;Reference that extracted value in a second field for conditional logic&lt;/STRONG&gt;:&lt;/P&gt;&lt;PRE&gt;$(IF,$(=,$(substr,$(getvar,dwgname),12,2),"RD"),"RED",
$(IF,$(=,$(substr,$(getvar,dwgname),12,2),"YL"),"YELLOW",
$(IF,$(=,$(substr,$(getvar,dwgname),12,2),"GR"),"GREEN","OTHER"))))&lt;/PRE&gt;&lt;UL&gt;&lt;LI&gt;&lt;STRONG&gt;Important:&lt;/STRONG&gt; Ensure that "RD", "YL", and "GR" are explicitly treated as &lt;STRONG&gt;strings&lt;/STRONG&gt;.&lt;/LI&gt;&lt;LI&gt;If AutoCAD still refuses to recognize it, try inserting the substring field into an attribute or MTEXT first, then referencing it in the condition.&lt;/LI&gt;&lt;/UL&gt;&lt;/LI&gt;&lt;/OL&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 24 Mar 2025 15:17:55 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/text-string-to-a-field-if-then-condition/m-p/13387407#M1631</guid>
      <dc:creator>Brock_Olly</dc:creator>
      <dc:date>2025-03-24T15:17:55Z</dc:date>
    </item>
    <item>
      <title>Re: Text string to a field IF/THEN condition</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/text-string-to-a-field-if-then-condition/m-p/13387412#M1632</link>
      <description>&lt;P&gt;I'm kind of going in the dark here so if you could upload your DWG or a sample with the field so we can test it out too that'd be nice.&lt;/P&gt;</description>
      <pubDate>Mon, 24 Mar 2025 15:20:11 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/text-string-to-a-field-if-then-condition/m-p/13387412#M1632</guid>
      <dc:creator>Brock_Olly</dc:creator>
      <dc:date>2025-03-24T15:20:11Z</dc:date>
    </item>
    <item>
      <title>Re: Text string to a field IF/THEN condition</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/text-string-to-a-field-if-then-condition/m-p/13387470#M1633</link>
      <description>&lt;P&gt;Thank you&amp;nbsp; my friends, nothing work.&lt;BR /&gt;I attached my sample...&lt;/P&gt;&lt;P&gt;The field should read from the file name... but only in the numeric characteres it work.&lt;BR /&gt;Thanks.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 24 Mar 2025 15:47:41 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/text-string-to-a-field-if-then-condition/m-p/13387470#M1633</guid>
      <dc:creator>PauloMiranda8553</dc:creator>
      <dc:date>2025-03-24T15:47:41Z</dc:date>
    </item>
    <item>
      <title>Re: Text string to a field IF/THEN condition</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/text-string-to-a-field-if-then-condition/m-p/13387488#M1634</link>
      <description>&lt;P&gt;I wonder perhaps the problem is with using &lt;STRONG&gt;=&lt;/STRONG&gt; since that’s for number comparisons. Maybe try &lt;STRONG&gt;eq&lt;/STRONG&gt; instead since that’s for string comparisons&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;A href="https://help.autodesk.com/view/ACDLT/2025/ENU/?guid=GUID-F94A885A-4DA2-432B-AC1A-EB49CC6C1C72" target="_blank"&gt;https://help.autodesk.com/view/ACDLT/2025/ENU/?guid=GUID-F94A885A-4DA2-432B-AC1A-EB49CC6C1C72&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 24 Mar 2025 15:57:42 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/text-string-to-a-field-if-then-condition/m-p/13387488#M1634</guid>
      <dc:creator>paullimapa</dc:creator>
      <dc:date>2025-03-24T15:57:42Z</dc:date>
    </item>
    <item>
      <title>Re: Text string to a field IF/THEN condition</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/text-string-to-a-field-if-then-condition/m-p/13387497#M1635</link>
      <description>&lt;P&gt;That's the problem...&lt;BR /&gt;You made it.&lt;BR /&gt;Thank you very much... Appreciate that.&lt;/P&gt;</description>
      <pubDate>Mon, 24 Mar 2025 16:03:18 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/text-string-to-a-field-if-then-condition/m-p/13387497#M1635</guid>
      <dc:creator>PauloMiranda8553</dc:creator>
      <dc:date>2025-03-24T16:03:18Z</dc:date>
    </item>
    <item>
      <title>Re: Text string to a field IF/THEN condition</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/text-string-to-a-field-if-then-condition/m-p/13387504#M1636</link>
      <description>&lt;P class="lia-align-justify"&gt;It was a group effort…cheers!!!&lt;/P&gt;</description>
      <pubDate>Mon, 24 Mar 2025 16:07:51 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/text-string-to-a-field-if-then-condition/m-p/13387504#M1636</guid>
      <dc:creator>paullimapa</dc:creator>
      <dc:date>2025-03-24T16:07:51Z</dc:date>
    </item>
  </channel>
</rss>

