<?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 Betreff: If/expression/true/false logic for a layer color toggle in AutoCAD Forum</title>
    <link>https://forums.autodesk.com/t5/autocad-forum/if-expression-true-false-logic-for-a-layer-color-toggle/m-p/12552705#M21478</link>
    <description>&lt;P&gt;You can't check the current-Layer color, so it will never work for the "current layer" (not with diesel only).&lt;/P&gt;
&lt;P&gt;If you need it for "current layer", you need Lisp or any other API.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;For a specific layer, lets say layer "MyFavLayer" it is possible (by accepting one small issue, because you still can check the initial layer color).&lt;/P&gt;
&lt;P&gt;Sample to toggle between freeze and thawed, Layername "TET"&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;$M=$(if,$(eq,$(getvar,USERR1),0),USERR1;1;_.-LAYER;_f;TET;,USERR1;0;_.-LAYER;_th;TET; )&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Sat, 10 Feb 2024 17:16:17 GMT</pubDate>
    <dc:creator>cadffm</dc:creator>
    <dc:date>2024-02-10T17:16:17Z</dc:date>
    <item>
      <title>If/expression/true/false logic for a layer color toggle</title>
      <link>https://forums.autodesk.com/t5/autocad-forum/if-expression-true-false-logic-for-a-layer-color-toggle/m-p/12552669#M21477</link>
      <description>&lt;P&gt;&lt;SPAN&gt;In a previous post, I presented an issue that needs to be solved by a DIESEL expression. The task is to create a macro that toggles the current layer color between red and green.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;I set up USERI1 and USERI2 via -setvar as values "1", and "3" to act as their respective&amp;nbsp;color values for red and green. Then I created a layer command to set the layer color via the variable vice a straight, typed-in value (in this case "1" for "red" using the -layer color command). I also set the cecolor to "bylayer", so both the block and layer match.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;I know my variable works, because when I use this macro, the layer turns red (from any color):&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;^C^C-layer;c;$M=$(getvar, USERI1);;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;However, I don't know enough about DIESEL syntax to set up the logic toggle between layer color red and green properly. I am not a programmer nor do I have any experience beyond a week or so of Autocad automation.&amp;nbsp; What mistakes am I making below?&amp;nbsp; Is the logic sound?&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;^C^C-layer;c;$M=$(if,$(=,$(getvar,USERI1),getvar,USERI2);;,getvar,USERI1;;)&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;I also toyed with this which sets up the layer color in red first, then moves on to the logic toggle:&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;^C^C-layer;c;$M=$(getvar, USERI1)^C;$M=$(if,$(=,$(getvar,USERI1),getvar,USERI2;;,getvar,USERI1;;)&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Beyond the first macro listed above, none of the others work. Any CONCRETE, non-cryptic, help would be appreciated. Even a tangential example using a USERI variable&amp;nbsp;working properly would help. I'm a working family guy, taking night school classes so my ability to spend hours trying to learn DIESEL is limited, but I'm trying!&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Sat, 10 Feb 2024 16:48:11 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/autocad-forum/if-expression-true-false-logic-for-a-layer-color-toggle/m-p/12552669#M21477</guid>
      <dc:creator>dpierson6B4ETP</dc:creator>
      <dc:date>2024-02-10T16:48:11Z</dc:date>
    </item>
    <item>
      <title>Betreff: If/expression/true/false logic for a layer color toggle</title>
      <link>https://forums.autodesk.com/t5/autocad-forum/if-expression-true-false-logic-for-a-layer-color-toggle/m-p/12552705#M21478</link>
      <description>&lt;P&gt;You can't check the current-Layer color, so it will never work for the "current layer" (not with diesel only).&lt;/P&gt;
&lt;P&gt;If you need it for "current layer", you need Lisp or any other API.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;For a specific layer, lets say layer "MyFavLayer" it is possible (by accepting one small issue, because you still can check the initial layer color).&lt;/P&gt;
&lt;P&gt;Sample to toggle between freeze and thawed, Layername "TET"&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;$M=$(if,$(eq,$(getvar,USERR1),0),USERR1;1;_.-LAYER;_f;TET;,USERR1;0;_.-LAYER;_th;TET; )&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 10 Feb 2024 17:16:17 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/autocad-forum/if-expression-true-false-logic-for-a-layer-color-toggle/m-p/12552705#M21478</guid>
      <dc:creator>cadffm</dc:creator>
      <dc:date>2024-02-10T17:16:17Z</dc:date>
    </item>
    <item>
      <title>Re: If/expression/true/false logic for a layer color toggle</title>
      <link>https://forums.autodesk.com/t5/autocad-forum/if-expression-true-false-logic-for-a-layer-color-toggle/m-p/12552872#M21479</link>
      <description>&lt;P&gt;I remember your previous &lt;A href="https://forums.autodesk.com/t5/autocad-forum/layer-green-red-toggle/m-p/12537989#M1123994" target="_blank" rel="noopener"&gt;post&lt;/A&gt;. So did you learn the answer on your class assignment from that post?&lt;/P&gt;</description>
      <pubDate>Sat, 10 Feb 2024 20:11:51 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/autocad-forum/if-expression-true-false-logic-for-a-layer-color-toggle/m-p/12552872#M21479</guid>
      <dc:creator>paullimapa</dc:creator>
      <dc:date>2024-02-10T20:11:51Z</dc:date>
    </item>
    <item>
      <title>Betreff: If/expression/true/false logic for a layer color toggle</title>
      <link>https://forums.autodesk.com/t5/autocad-forum/if-expression-true-false-logic-for-a-layer-color-toggle/m-p/12553770#M21480</link>
      <description>&lt;P&gt;SUCCESS...sorta...&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I co-opted your DIESEL and came up with this:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;$M=$(if,$(eq,$(getvar,USERR1),0),USERR1;1;_.-LAYER;_c;3;0;,USERR1;0;_.-LAYER;_c;1;0; )&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;It will toggle either red or green to the opposite color and back, then it stops.&amp;nbsp; However, if I do this:&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;$M=$(if,$(eq,$(getvar,USERR1),0),USERR1;1;_.-LAYER;_c;3;0;,USERR1;0;_.-LAYER;_c;1;0;^C )&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;It toggle indefinitely. I know that last ^C is a kludge to make it stop working...is there another command to "reset" the toggle, or is that it?&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Sun, 11 Feb 2024 17:27:59 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/autocad-forum/if-expression-true-false-logic-for-a-layer-color-toggle/m-p/12553770#M21480</guid>
      <dc:creator>dpierson6B4ETP</dc:creator>
      <dc:date>2024-02-11T17:27:59Z</dc:date>
    </item>
    <item>
      <title>Betreff: If/expression/true/false logic for a layer color toggle</title>
      <link>https://forums.autodesk.com/t5/autocad-forum/if-expression-true-false-logic-for-a-layer-color-toggle/m-p/12553779#M21481</link>
      <description>&lt;P&gt;Oh, and THANK YOU!!!&amp;nbsp; You have NO idea how long (embarrassingly) I have been working on this.&amp;nbsp; I really appreciate the assist.&lt;/P&gt;</description>
      <pubDate>Sun, 11 Feb 2024 17:32:19 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/autocad-forum/if-expression-true-false-logic-for-a-layer-color-toggle/m-p/12553779#M21481</guid>
      <dc:creator>dpierson6B4ETP</dc:creator>
      <dc:date>2024-02-11T17:32:19Z</dc:date>
    </item>
  </channel>
</rss>

