<?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: How to change layer colour IF layer name CONTAINS in Visual LISP, AutoLISP and General Customization Forum</title>
    <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/how-to-change-layer-colour-if-layer-name-contains/m-p/11907286#M31357</link>
    <description>&lt;P&gt;Folks, below worked for what i needed.&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;EM&gt;-LAYER&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;C&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;220&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;"*CA(*"&lt;/EM&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;Pasted into notepad and saved as .scr file, and ran it with no issues.&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;</description>
    <pubDate>Wed, 19 Apr 2023 14:22:22 GMT</pubDate>
    <dc:creator>agedzevicius</dc:creator>
    <dc:date>2023-04-19T14:22:22Z</dc:date>
    <item>
      <title>How to change layer colour IF layer name CONTAINS</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/how-to-change-layer-colour-if-layer-name-contains/m-p/11904311#M31349</link>
      <description>&lt;P&gt;Hi folks, first time trying to write a script myself, and almost certain it's possible, because i used something similar before.&lt;BR /&gt;&lt;BR /&gt;What i'm looking ot achieve is:&lt;BR /&gt;&lt;BR /&gt;I have a drawing with many different layers.&lt;BR /&gt;I want to run a script that will:&lt;BR /&gt;&lt;BR /&gt;Apply colour &lt;FONT color="#FF00FF"&gt;220&lt;/FONT&gt; to &lt;EM&gt;all&lt;/EM&gt; layers that CONTAIN the phrase/letters&amp;nbsp; "&lt;FONT color="#FF0000"&gt;&lt;EM&gt;-CA(HQ)-&lt;/EM&gt;&lt;/FONT&gt;"&lt;BR /&gt;(Then repeat same command, to apply a different colour to all layers containing "-CA(INS)-".)&lt;BR /&gt;&lt;BR /&gt;Not sure where to start, but some help writing this would be very appreciated.&lt;BR /&gt;I'll pay it forward.&lt;/P&gt;</description>
      <pubDate>Tue, 18 Apr 2023 12:50:50 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/how-to-change-layer-colour-if-layer-name-contains/m-p/11904311#M31349</guid>
      <dc:creator>agedzevicius</dc:creator>
      <dc:date>2023-04-18T12:50:50Z</dc:date>
    </item>
    <item>
      <title>Re: How to change layer colour IF layer name CONTAINS</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/how-to-change-layer-colour-if-layer-name-contains/m-p/11904378#M31350</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/12988094"&gt;@agedzevicius&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;....&lt;/P&gt;
&lt;P&gt;Apply colour &lt;FONT color="#FF00FF"&gt;220&lt;/FONT&gt; to &lt;EM&gt;all&lt;/EM&gt; layers that CONTAIN the phrase/letters&amp;nbsp; "&lt;FONT color="#FF0000"&gt;&lt;EM&gt;-CA(HQ)-&lt;/EM&gt;&lt;/FONT&gt;"&lt;BR /&gt;(Then repeat same command, to apply a different colour to all layers containing "-CA(INS)-".)&lt;BR /&gt;....&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Wildcards can be used to include multiple Layer names under a given option such as a color assignment -- see &lt;A href="https://help.autodesk.com/view/ACD/2023/ENU/?guid=GUID-68373F99-17F1-4AC4-8D37-184C49164705" target="_blank" rel="noopener"&gt;&amp;gt;this&amp;lt;&lt;/A&gt;.&amp;nbsp; Each * below stands for &lt;EM&gt;any other content&lt;/EM&gt; [including nothing].&amp;nbsp; If you're talking about a Script as AutoCAD means the word:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;-LAYER&lt;BR /&gt;Color&lt;/P&gt;
&lt;P&gt;220&lt;/P&gt;
&lt;P&gt;*-CA(HQ)-*&lt;/P&gt;
&lt;P&gt;Color&lt;/P&gt;
&lt;P&gt;&lt;FONT size="2"&gt;&lt;EM&gt;{yourDifferentColor}&lt;/EM&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;*-CA(INS)-*&lt;/P&gt;
&lt;P&gt;&lt;FONT size="2"&gt;&lt;EM&gt;{empty line for final Enter to end Layer command}&lt;/EM&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The same can be done in AutoLisp or command macro format [I never know what people mean by the word "script," but we see a lot of people using the word when they really mean an AutoLisp routine or a macro].&lt;/P&gt;</description>
      <pubDate>Tue, 18 Apr 2023 13:17:35 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/how-to-change-layer-colour-if-layer-name-contains/m-p/11904378#M31350</guid>
      <dc:creator>Kent1Cooper</dc:creator>
      <dc:date>2023-04-18T13:17:35Z</dc:date>
    </item>
    <item>
      <title>Re: How to change layer colour IF layer name CONTAINS</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/how-to-change-layer-colour-if-layer-name-contains/m-p/11904443#M31351</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The same can be done in AutoLisp or command macro format [I never know what people mean by the word "script," but we see a lot of people using the word when they really mean an AutoLisp routine or a macro].&lt;/P&gt;&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;Apologies, just used to using scripts in terms of groups of commands to be carried out.&lt;BR /&gt;&lt;BR /&gt;I'll bookmark the page for future reference, very curious to try it out. Will get back to you with results.&lt;BR /&gt;Thanks Kent&amp;nbsp;&lt;span class="lia-unicode-emoji" title=":thumbs_up:"&gt;👍&lt;/span&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 18 Apr 2023 13:29:43 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/how-to-change-layer-colour-if-layer-name-contains/m-p/11904443#M31351</guid>
      <dc:creator>agedzevicius</dc:creator>
      <dc:date>2023-04-18T13:29:43Z</dc:date>
    </item>
    <item>
      <title>Re: How to change layer colour IF layer name CONTAINS</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/how-to-change-layer-colour-if-layer-name-contains/m-p/11904480#M31352</link>
      <description>&lt;P&gt;what is right with you, Kent?&lt;/P&gt;&lt;P&gt;script partly or entirely just mimics your manual inputting commands and their modifiers/options in command line.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 18 Apr 2023 13:40:07 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/how-to-change-layer-colour-if-layer-name-contains/m-p/11904480#M31352</guid>
      <dc:creator>komondormrex</dc:creator>
      <dc:date>2023-04-18T13:40:07Z</dc:date>
    </item>
    <item>
      <title>Re: How to change layer colour IF layer name CONTAINS</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/how-to-change-layer-colour-if-layer-name-contains/m-p/11904533#M31353</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/13423916"&gt;@komondormrex&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;what is right with you, Kent?&lt;/P&gt;
&lt;P&gt;script partly or entirely just mimics your manual inputting commands and their modifiers/options in command line.&amp;nbsp;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Any of the possible approaches can be "right" -- they just need to pick one.&amp;nbsp; I wrote something that should [untested] work in a SCRIPT &lt;EM&gt;as AutoCAD uses the word&lt;/EM&gt; [specific file type, specific command to invoke it], but the OP's wording "&lt;SPAN&gt;groups of commands to be carried out" can also be done by an AutoLisp routine [presumably defined into a custom command name] or a command macro [with certain limitations, though those should not interfere in this instance], with some similarities but also meaningful differences in format &amp;amp; syntax.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;As much as anything else, the "right" way may depend on how they want to invoke whatever it is.&amp;nbsp; An AutoLisp command definition would mean they could &lt;EM&gt;type in&lt;/EM&gt; the command name.&amp;nbsp; A Tool Palette button could contain a command macro without a defined command, or could contain just the name of a defined command.&amp;nbsp; A Script would require use of a .scr file and the SCRIPT command to run it, but that could also be contained in a Tool Palette button command macro or even in an AutoLisp command definition.&amp;nbsp; A Script file can just run an AutoLisp-defined command name, rather than contain the commands itself.&amp;nbsp; I haven't used the action recorder, but that's another way, and there's assignment to a keystroke combination, and....&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 18 Apr 2023 13:59:25 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/how-to-change-layer-colour-if-layer-name-contains/m-p/11904533#M31353</guid>
      <dc:creator>Kent1Cooper</dc:creator>
      <dc:date>2023-04-18T13:59:25Z</dc:date>
    </item>
    <item>
      <title>Re: How to change layer colour IF layer name CONTAINS</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/how-to-change-layer-colour-if-layer-name-contains/m-p/11904657#M31354</link>
      <description>&lt;P&gt;When i start the command group with -layer, it only changes the colour of the current layer.&lt;BR /&gt;Is there a way to apply this command to ALL layers?&lt;BR /&gt;&lt;BR /&gt;After some messing about, my colleague figured out that by using below will work for all layers.&lt;BR /&gt;(Learning process for me to understand that " is treated as list.)&lt;BR /&gt;&lt;BR /&gt;Below works for what i need, how would i go about turning this into a loadable script?&amp;nbsp;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/69526"&gt;@Kent1Cooper&lt;/a&gt;&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;&lt;EM&gt;-LAYER&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;C&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;220&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;"*CA(*"&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;[enter]&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;[enter]&lt;/EM&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 18 Apr 2023 14:41:34 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/how-to-change-layer-colour-if-layer-name-contains/m-p/11904657#M31354</guid>
      <dc:creator>agedzevicius</dc:creator>
      <dc:date>2023-04-18T14:41:34Z</dc:date>
    </item>
    <item>
      <title>Re: How to change layer colour IF layer name CONTAINS</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/how-to-change-layer-colour-if-layer-name-contains/m-p/11904689#M31355</link>
      <description>&lt;P&gt;hey,&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="lisp"&gt;(defun c:change_layer_color_220 ()
	(vlax-map-collection (vla-get-layers (vla-get-activedocument (vlax-get-acad-object)))
		'(lambda (layer)
			(if (wcmatch (vla-get-name layer) "*-CA(HQ)-*")
				(vla-put-color layer 220)
			)
		)
	)
	(princ)
)&lt;/LI-CODE&gt;</description>
      <pubDate>Tue, 18 Apr 2023 14:54:11 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/how-to-change-layer-colour-if-layer-name-contains/m-p/11904689#M31355</guid>
      <dc:creator>komondormrex</dc:creator>
      <dc:date>2023-04-18T14:54:11Z</dc:date>
    </item>
    <item>
      <title>Re: How to change layer colour IF layer name CONTAINS</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/how-to-change-layer-colour-if-layer-name-contains/m-p/11904740#M31356</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/12988094"&gt;@agedzevicius&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;.... by using below will work for all layers.&lt;BR /&gt;(Learning process for me to understand that " is treated as list.)&lt;BR /&gt;&lt;BR /&gt;Below works for what i need, how would i go about turning this into a loadable script? ....&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;&lt;EM&gt;-LAYER&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;C&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;220&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;"*CA(*"&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;[enter]&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;[enter]&lt;/EM&gt;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Something is off here.&amp;nbsp; In a Script, at least, you should not need those double-quotes, which define the bounds of a &lt;EM&gt;text string&lt;/EM&gt;, not of a &lt;EM&gt;list&lt;/EM&gt;.&amp;nbsp; If you were doing this in an AutoLisp function where list is an appropriate term [but would not be used here], yes, those quotes would be needed, but they should not be in a Script or a command macro.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You can turn it into a "loadable script" in different ways, depending again on what you mean by the word.&amp;nbsp; If you really mean SCRIPT in AutoCAD's usage, put that text [it should work without the quotes], with a blank line in place of the first&amp;nbsp;&lt;EM&gt;[enter]&lt;/EM&gt;&amp;nbsp;(the second is extraneous), into a plain-text editor such as Notepad, and save it to a file with a &lt;STRONG&gt;.scr&lt;/STRONG&gt; filetype ending.&amp;nbsp; Use the SCRIPT command to run it.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;But I used the word "run" there.&amp;nbsp; Your word "loadable" makes me wonder.&amp;nbsp; "Load" is something one does with AutoLisp routines.&amp;nbsp; That could be like this:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;(defun C:&lt;FONT color="#00CCFF"&gt;&lt;EM&gt;YourCommandName&lt;/EM&gt;&lt;/FONT&gt; ()&lt;/P&gt;
&lt;P&gt;&amp;nbsp; (command "_.layer" "_color" 220 "*CA(*" "")&lt;/P&gt;
&lt;P&gt;&amp;nbsp; (prin1)&lt;/P&gt;
&lt;P&gt;)&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Save that [with a command name that means something to you substituted], similarly in a plain-text editor, to a file with a &lt;STRONG&gt;.lsp&lt;/STRONG&gt; filetype ending, and use APPLOAD to Load it, then type in the &lt;EM&gt;&lt;FONT color="#00CCFF"&gt;YourCommandName&lt;/FONT&gt;&lt;/EM&gt; to use it.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You could also do it in a command macro built into a Tool Palette button, such as [untested]:&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;
&lt;P&gt;^C^C_.-LAYER _color 220 *CA(* ;&lt;/P&gt;</description>
      <pubDate>Tue, 18 Apr 2023 15:17:36 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/how-to-change-layer-colour-if-layer-name-contains/m-p/11904740#M31356</guid>
      <dc:creator>Kent1Cooper</dc:creator>
      <dc:date>2023-04-18T15:17:36Z</dc:date>
    </item>
    <item>
      <title>Re: How to change layer colour IF layer name CONTAINS</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/how-to-change-layer-colour-if-layer-name-contains/m-p/11907286#M31357</link>
      <description>&lt;P&gt;Folks, below worked for what i needed.&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;EM&gt;-LAYER&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;C&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;220&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;"*CA(*"&lt;/EM&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;Pasted into notepad and saved as .scr file, and ran it with no issues.&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 19 Apr 2023 14:22:22 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/how-to-change-layer-colour-if-layer-name-contains/m-p/11907286#M31357</guid>
      <dc:creator>agedzevicius</dc:creator>
      <dc:date>2023-04-19T14:22:22Z</dc:date>
    </item>
  </channel>
</rss>

