<?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: Request for AutoLISP in Visual LISP, AutoLISP and General Customization Forum</title>
    <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/request-for-autolisp/m-p/10116548#M77704</link>
    <description>&lt;P&gt;With received key sequences you would use function entmode to modify one or more entities or use for what ever you need. If you need further help, &lt;FONT face="impact,chicago" color="#FF0000"&gt;please start new tread in this forum&lt;/FONT&gt; and describe your problem in details i.e. what you want to achieve. Attach sample drawing or part of your code.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Sat, 27 Feb 2021 10:48:49 GMT</pubDate>
    <dc:creator>hak_vz</dc:creator>
    <dc:date>2021-02-27T10:48:49Z</dc:date>
    <item>
      <title>Request for AutoLISP</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/request-for-autolisp/m-p/9353994#M77663</link>
      <description>&lt;P&gt;Hi all, I am new to posting so please forgive me if I make any mistakes.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am looking to create an Lisp that will change the color of a specific layer name. For example in a landscape drawing I have xrefenced in some civil files that contain layers "Project#-HC|C-BLDG-OTLN" or "Project#-HC|C-UTIL-WATR". Now I have to go through and change these layers to their specific color in when working in a landscape drawing for landscape plotting purposes. Is there a way to make a lisp so that anytime I run the command it will change layer color&amp;nbsp; of "Project#-HC|C-BLDG-OTLN" to color 152 and&amp;nbsp;"Project#-HC|C-UTIL-WATR" to color 190.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Hopefully I am making sense if not please let me know and I will try to be more clear.&lt;/P&gt;&lt;P&gt;Thank you.&lt;/P&gt;</description>
      <pubDate>Mon, 02 Mar 2020 23:01:53 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/request-for-autolisp/m-p/9353994#M77663</guid>
      <dc:creator>SnickerinTurtles</dc:creator>
      <dc:date>2020-03-02T23:01:53Z</dc:date>
    </item>
    <item>
      <title>Betreff: Request for AutoLISP</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/request-for-autolisp/m-p/9354067#M77664</link>
      <description>&lt;P&gt;For LAyer properties you can easily use the -LAYER command,&lt;/P&gt;
&lt;P&gt;if ok for you, use the -LAYER command in Lisp too. (Command "_.-LAYER" and so on "")&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Because of -LAYER is a normal command, you can also use a simple menumacro - with the same command sequence&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;'_.-LAYER;_co;152;Project`#-HC|C-BLDG-OTLN;_co;190;Project`#-HC|C-UTIL-WATR;;&lt;/P&gt;</description>
      <pubDate>Mon, 02 Mar 2020 23:47:13 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/request-for-autolisp/m-p/9354067#M77664</guid>
      <dc:creator>cadffm</dc:creator>
      <dc:date>2020-03-02T23:47:13Z</dc:date>
    </item>
    <item>
      <title>Re: Request for AutoLISP</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/request-for-autolisp/m-p/9354071#M77665</link>
      <description>&lt;P&gt;try this&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;(defun c:xrlyrc ( / c_doc c_lyrs)
  (setq c_doc (vla-get-activedocument (vlax-get-acad-obect))
        c_lyrs (vla-get-layers c_doc)
  )
  (vlax-for lyr c_lyrs
    (cond ( (or (wcmatch (vlax-get lyr 'name) "*|C-BLDG-OTLN")
                (wcmatch (vlax-get lyr 'name) "*|C-UTIL-WATR")
            )
            (if (wcmatch (vlax-get lyr 'name) "*|C-BLDG-OTLN") (vlax-put lyr 'color 152) (vlax-put lyr 'color 190))
          )
    )
  )
  (princ)
)&lt;/LI-CODE&gt;</description>
      <pubDate>Mon, 02 Mar 2020 23:48:36 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/request-for-autolisp/m-p/9354071#M77665</guid>
      <dc:creator>dlanorh</dc:creator>
      <dc:date>2020-03-02T23:48:36Z</dc:date>
    </item>
    <item>
      <title>Re: Request for AutoLISP</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/request-for-autolisp/m-p/9354097#M77666</link>
      <description>&lt;P&gt;When I run the code I get this error.&lt;/P&gt;&lt;P&gt;"error: no function definition: VLAX-GET-ACAD-OBECT"&lt;/P&gt;&lt;P&gt;&amp;nbsp;I am guessing I need a way to select the xrefence before telling the layers on that xref to change color?&lt;/P&gt;</description>
      <pubDate>Mon, 02 Mar 2020 23:58:46 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/request-for-autolisp/m-p/9354097#M77666</guid>
      <dc:creator>SnickerinTurtles</dc:creator>
      <dc:date>2020-03-02T23:58:46Z</dc:date>
    </item>
    <item>
      <title>Re: Request for AutoLISP</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/request-for-autolisp/m-p/9354152#M77667</link>
      <description>&lt;P&gt;Sorry a spelling mistake on my part. Corrected code below&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;(defun c:xrlyrc ( / c_doc c_lyrs)
 (vl-load-com)
  (setq c_doc (vla-get-activedocument (vlax-get-acad-object))
        c_lyrs (vla-get-layers c_doc)
  )
  (vlax-for lyr c_lyrs
    (cond ( (or (wcmatch (vlax-get lyr 'name) "*|C-BLDG-OTLN")
                (wcmatch (vlax-get lyr 'name) "*|C-UTIL-WATR")
            )
            (if (wcmatch (vlax-get lyr 'name) "*|C-BLDG-OTLN") (vlax-put lyr 'color 152) (vlax-put lyr 'color 190))
          )
    )
  )
  (princ)
)&lt;/LI-CODE&gt;&lt;P&gt;. C&lt;/P&gt;</description>
      <pubDate>Tue, 03 Mar 2020 00:40:23 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/request-for-autolisp/m-p/9354152#M77667</guid>
      <dc:creator>dlanorh</dc:creator>
      <dc:date>2020-03-03T00:40:23Z</dc:date>
    </item>
    <item>
      <title>Re: Request for AutoLISP</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/request-for-autolisp/m-p/9354260#M77668</link>
      <description>&lt;P&gt;Sorry I don't know very much about coding in CAD, but I do know an okay amount of C++.&lt;/P&gt;&lt;P&gt;I do think I understand&amp;nbsp; and correct me if I am wrong , that it would be several lines of if this then that nested several times. Asking does it match any of these layers if so make it color 1, if it matches any of these layers if so make it color 2, so on and so forth. I tested it but I replaced the * with the xref file name and it ran perfectly.&lt;/P&gt;&lt;P&gt;I am not sure how to replace the * with the xref selected. I thought it may have been the first few lines of code with get-acad-object but it did not asking for an xref. Also I would assume we can freeze specific layers instead of changing the color and linetype?&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 03 Mar 2020 02:24:25 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/request-for-autolisp/m-p/9354260#M77668</guid>
      <dc:creator>SnickerinTurtles</dc:creator>
      <dc:date>2020-03-03T02:24:25Z</dc:date>
    </item>
    <item>
      <title>Re: Request for AutoLISP</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/request-for-autolisp/m-p/9354261#M77669</link>
      <description>&lt;P&gt;A variation pick color then object for layer.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;(defun c:xrlyrc2 ( / c_lyrs obj lay)
  (vl-load-com)
  (setvar 'xrefoverride 1)
  (setq c_lyrs (vla-get-layers (vla-get-activedocument (vlax-get-acad-object))))
  (while (setq col (getreal "\nEnter colour number 1-255 Enter to Exit "))
    (setq obj (vlax-ename-&amp;gt;vla-object (car (nentsel "\nselect xref layer"))))
    (setq lay (vla-get-layer obj))
    (vlax-for lyr c_lyrs
      (if (= (vlax-get lyr 'name) lay) (vlax-put lyr 'color col))
    )
	(command "regen")
  )
  (princ)
)
(c:xrlyrc2)&lt;/LI-CODE&gt;</description>
      <pubDate>Tue, 03 Mar 2020 02:25:18 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/request-for-autolisp/m-p/9354261#M77669</guid>
      <dc:creator>Sea-Haven</dc:creator>
      <dc:date>2020-03-03T02:25:18Z</dc:date>
    </item>
    <item>
      <title>Re: Request for AutoLISP</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/request-for-autolisp/m-p/9354297#M77670</link>
      <description>&lt;P&gt;This is really useful did a few tests on it at home and works well so far. Like the idea and I do admit this is more versatile for more than just one use. Thanks for coming up with a different solution.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 03 Mar 2020 03:05:49 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/request-for-autolisp/m-p/9354297#M77670</guid>
      <dc:creator>SnickerinTurtles</dc:creator>
      <dc:date>2020-03-03T03:05:49Z</dc:date>
    </item>
    <item>
      <title>Re: Request for AutoLISP</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/request-for-autolisp/m-p/9354306#M77671</link>
      <description>&lt;P&gt;No worries had a little bit of time.&lt;/P&gt;</description>
      <pubDate>Tue, 03 Mar 2020 03:13:27 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/request-for-autolisp/m-p/9354306#M77671</guid>
      <dc:creator>Sea-Haven</dc:creator>
      <dc:date>2020-03-03T03:13:27Z</dc:date>
    </item>
    <item>
      <title>Re: Request for AutoLISP</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/request-for-autolisp/m-p/9354339#M77672</link>
      <description>&lt;P&gt;Although, I do like your way and see that it is more versatile, I would like to know how to do it the other way as well. I think using a conditional would be better than a nested if statement if I were to go the other way. I am still trying to do some more research and learn how to do this but grabbing the first part of any xref to check with my conditional statements and how to create those, but I am slowing getting it.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 03 Mar 2020 03:57:56 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/request-for-autolisp/m-p/9354339#M77672</guid>
      <dc:creator>SnickerinTurtles</dc:creator>
      <dc:date>2020-03-03T03:57:56Z</dc:date>
    </item>
    <item>
      <title>Re: Request for AutoLISP</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/request-for-autolisp/m-p/9354957#M77673</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/2918796"&gt;@SnickerinTurtles&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;&lt;P&gt;Sorry I don't know very much about coding in CAD, but I do know an okay amount of C++.&lt;/P&gt;&lt;P&gt;I do think I understand&amp;nbsp; and correct me if I am wrong , that it would be several lines of if this then that nested several times. Asking does it match any of these layers if so make it color 1, if it matches any of these layers if so make it color 2, so on and so forth. I tested it but I replaced the * with the xref file name and it ran perfectly.&lt;/P&gt;&lt;P&gt;I am not sure how to replace the * with the xref selected. I thought it may have been the first few lines of code with get-acad-object but it did not asking for an xref. Also I would assume we can freeze specific layers instead of changing the color and linetype?&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;The "*" is a wild card character in the match string and was intended to negate using the x-ref file name since any layer that has a "|" is an x-ref layer (it is forbidden/restricted character and you cannot create a layer which contains it). The bar divides the x-ref file name from the layer name, but wont pick up non x-ref drawing layers as these cannot contain a bar. &lt;A href="http://help.autodesk.com/view/ACD/2015/ENU/?guid=GUID-EC257AF7-72D4-4B38-99B6-9B09952A53AD" target="_blank" rel="noopener"&gt;WCMATCH&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;That said I should probably have done this&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;(defun c:xrlyrc ( / c_doc c_lyrs)
  (setq c_doc (vla-get-activedocument (vlax-get-acad-obect))
        c_lyrs (vla-get-layers c_doc)
  )
  (vlax-for lyr c_lyrs
    (cond ( (or (wcmatch (strcase (vlax-get lyr 'name)) "*|C-BLDG-OTLN")
                (wcmatch (strcase (vlax-get lyr 'name)) "*|C-UTIL-WATR")
            )
            (if (wcmatch (vlax-get lyr 'name) "*|C-BLDG-OTLN") (vlax-put lyr 'color 152) (vlax-put lyr 'color 190))
          )
          ( (wcmatch (strcase (vlax-get lyr 'name)) "*|C-BLDG-CLMN")
            (vlax-put-property lyr 'freeze :vlax-true)
          )
    )
  )
  (princ)
)&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;As wcmatch is case sensitive in its checking&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The (vlax-put lyr 'color ..) is easily replaced with (vlax-put lyr 'freeze ..) see above; or any of the other layer properties&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 03 Mar 2020 10:56:35 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/request-for-autolisp/m-p/9354957#M77673</guid>
      <dc:creator>dlanorh</dc:creator>
      <dc:date>2020-03-03T10:56:35Z</dc:date>
    </item>
    <item>
      <title>Re: Request for AutoLISP</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/request-for-autolisp/m-p/9354985#M77674</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/5644077"&gt;@dlanorh&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;...
    (cond ( (or (wcmatch (strcase (vlax-get lyr 'name)) "*|C-BLDG-OTLN")
                (wcmatch (strcase (vlax-get lyr 'name)) "*|C-UTIL-WATR")
            )
...&lt;/PRE&gt;
&lt;P&gt;...&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Or just use &lt;STRONG&gt;a comma&lt;/STRONG&gt; to delimit the masks.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;(cond ((wcmatch (strcase (vlax-get lyr 'name)) "*|C-BLDG-OTLN&lt;FONT color="#FF0000"&gt;&lt;STRONG&gt;,&lt;/STRONG&gt;&lt;/FONT&gt;*|C-UTIL-WATR")&lt;BR /&gt;       ...)&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 03 Mar 2020 11:05:08 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/request-for-autolisp/m-p/9354985#M77674</guid>
      <dc:creator>ВeekeeCZ</dc:creator>
      <dc:date>2020-03-03T11:05:08Z</dc:date>
    </item>
    <item>
      <title>Re: Request for AutoLISP</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/request-for-autolisp/m-p/9355282#M77675</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;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/5644077"&gt;@dlanorh&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;...
    (cond ( (or (wcmatch (strcase (vlax-get lyr 'name)) "*|C-BLDG-OTLN")
                (wcmatch (strcase (vlax-get lyr 'name)) "*|C-UTIL-WATR")
            )
...&lt;/PRE&gt;&lt;P&gt;...&lt;/P&gt;&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Or just use &lt;STRONG&gt;a comma&lt;/STRONG&gt; to delimit the masks.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;(cond ((wcmatch (strcase (vlax-get lyr 'name)) "*|C-BLDG-OTLN&lt;FONT color="#FF0000"&gt;&lt;STRONG&gt;,&lt;/STRONG&gt;&lt;/FONT&gt;*|C-UTIL-WATR")&lt;BR /&gt;       ...)&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;You learn something new every day &lt;span class="lia-unicode-emoji" title=":beaming_face_with_smiling_eyes:"&gt;😁&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 03 Mar 2020 13:15:33 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/request-for-autolisp/m-p/9355282#M77675</guid>
      <dc:creator>dlanorh</dc:creator>
      <dc:date>2020-03-03T13:15:33Z</dc:date>
    </item>
    <item>
      <title>Re: Request for AutoLISP</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/request-for-autolisp/m-p/9355410#M77676</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/2918796"&gt;@SnickerinTurtles&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;&lt;SPAN style="font-family: inherit;"&gt;..... Is there a way to make a lisp so that anytime I run the command it will change layer color&amp;nbsp; of "Project#-HC|C-BLDG-OTLN" to color 152 and&amp;nbsp;"Project#-HC|C-UTIL-WATR" to color 190.&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="font-family: inherit;"&gt;....&lt;/SPAN&gt;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;This can be a lot simpler.&amp;nbsp; The following uses no variables, is &lt;EM&gt;not&lt;/EM&gt;&amp;nbsp; case-sensitive as (wcmatch) is, nor will it care if a Layer does not exist in the drawing:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;(defun C:CallItWhatYouWill ()&lt;/P&gt;
&lt;P&gt;&amp;nbsp; (command "_.layer"&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp; "_color" 152&amp;nbsp;&lt;SPAN style="font-family: inherit;"&gt;"*-HC|C-BLDG-OTLN"&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp; "_color" 190 &lt;SPAN style="font-family: inherit;"&gt;"*-HC|C-UTIL-WATR"&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp; ""&lt;/P&gt;
&lt;P&gt;&amp;nbsp; )&lt;/P&gt;
&lt;P&gt;)&lt;/P&gt;</description>
      <pubDate>Tue, 03 Mar 2020 13:57:15 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/request-for-autolisp/m-p/9355410#M77676</guid>
      <dc:creator>Kent1Cooper</dc:creator>
      <dc:date>2020-03-03T13:57:15Z</dc:date>
    </item>
    <item>
      <title>Re: Request for AutoLISP</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/request-for-autolisp/m-p/9356000#M77677</link>
      <description>&lt;P&gt;Pretty cool and it works. But I have a question how does the program know to make the C-UTIL-WATR layer to 190 and not 152. Is it for each layer specified there needs to be a corresponding color associated with it?&amp;nbsp;&lt;/P&gt;&lt;P&gt;Like this line here. There isn't a "*|C-UTIL-WATR" to be set to color 190. But it still took the 2nd layer listed and made it 190.&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;(if (wcmatch (vlax-get lyr 'name) "*|C-BLDG-OTLN") (vlax-put lyr 'color 152) (vlax-put lyr 'color 190))&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;Or is it that it takes everything in this list and makes it 152 and then everything in the next list 190? Such that if I did this it would make everything in the 1st list color 152 the next 190 and the next 156.&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;(defun c:xrlyrc ( / c_doc c_lyrs)
  (setq c_doc (vla-get-activedocument (vlax-get-acad-object))
        c_lyrs (vla-get-layers c_doc)
  )
  (vlax-for lyr c_lyrs
    (cond ( (or (wcmatch (strcase (vlax-get lyr 'name)) "*|C-BLDG-OVHG","*|C-BLDG-DOOR","*|C-BLDG-WNDW")
                (wcmatch (strcase (vlax-get lyr 'name)) "*|C-UTIL-MNHL","*|C-UTIL-SEWR","*|C-WATR-INLT","*|C-UTIL-WATR")
                (wcmatch (strcase (vlax-get lyr 'name)) "*|C-BLDG")
            )
            (if (wcmatch (vlax-get lyr 'name) "*|C-BLDG-OTLN") (vlax-put lyr 'color 152) (vlax-put lyr 'color 190) (vlax-put ltr 'color 156))
          )
          ( (wcmatch (strcase (vlax-get lyr 'name)) "*|C-BLDG-CLMN")
            (vlax-put-property lyr 'freeze :vlax-true)
          )
    )
  )
  (princ)
)&lt;/LI-CODE&gt;</description>
      <pubDate>Tue, 03 Mar 2020 17:47:27 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/request-for-autolisp/m-p/9356000#M77677</guid>
      <dc:creator>SnickerinTurtles</dc:creator>
      <dc:date>2020-03-03T17:47:27Z</dc:date>
    </item>
    <item>
      <title>Re: Request for AutoLISP</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/request-for-autolisp/m-p/9356175#M77678</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/2918796"&gt;@SnickerinTurtles&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;.... how does the program know to make the C-UTIL-WATR layer to 190 and not 152. ....&lt;SPAN style="font-family: inherit;"&gt;&amp;nbsp;is it that it takes everything in this list and makes it 152 and then everything in the next list 190? Such that if I did this it would make everything in the 1st list color 152 the next 190 and the next 156.&lt;/SPAN&gt;&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;....
            (if (wcmatch (vlax-get lyr 'name) "*|C-BLDG-OTLN") (vlax-put lyr 'color 152) (vlax-put lyr 'color 190) (vlax-put ltr 'color 156))
....&lt;/LI-CODE&gt;&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;No.&amp;nbsp; Read about (if) -- it wants a 'then' expression and an optional 'else' expression, but that has a third expression it won't be able to do anything with.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;What that code does [which is serious overkill in my opinion] is to step through &lt;EM&gt;every Layer in the drawing&lt;/EM&gt;&amp;nbsp; [what purpose is served by that?], and if one is among a certain group of Layer names, &lt;EM&gt;then&lt;/EM&gt;&amp;nbsp; if it's the ...BLDG-OTLN one, it makes it color 152, otherwise color 190.&amp;nbsp; What a lot of work!&amp;nbsp; Just tell it what color you want what Layer(s).&amp;nbsp; You can give it multiple Layer names with comma separators, and use wildcards.&amp;nbsp; See Message 14 again, but to extend that to do more of what's in your latest [I'm not sure I've got the Layer names all assigned to the right colors, but I hope you get the idea]:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;(defun c:xrlyrc ()&lt;BR /&gt;&amp;nbsp; (command "_.layer"&lt;BR /&gt;&amp;nbsp; &amp;nbsp; "_color" 152 "*|C-BLDG-OTLN"&lt;BR /&gt;&amp;nbsp; &amp;nbsp; "_color" 190 "*|C-BLDG-OVHG,*|C-BLDG-DOOR,*|C-BLDG-WNDW"&lt;BR /&gt;&amp;nbsp; &amp;nbsp; "_color" 156 "*|C-UTIL-MNHL,*|C-UTIL-SEWR,*|C-WATR-INLT,*|C-UTIL-WATR"&lt;BR /&gt;&amp;nbsp; &amp;nbsp; "_freeze" "*|C-BLDG-CLMN"&lt;BR /&gt;&amp;nbsp; &amp;nbsp; "" ; [complete Layer command]&lt;BR /&gt;&amp;nbsp; ); command&lt;BR /&gt;); defun&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;No variables, no digging through every Layer needlessly, hugely less code.&lt;/P&gt;</description>
      <pubDate>Tue, 03 Mar 2020 19:06:40 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/request-for-autolisp/m-p/9356175#M77678</guid>
      <dc:creator>Kent1Cooper</dc:creator>
      <dc:date>2020-03-03T19:06:40Z</dc:date>
    </item>
    <item>
      <title>Re: Request for AutoLISP</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/request-for-autolisp/m-p/9356203#M77679</link>
      <description>&lt;P&gt;I can see how this code is more simplified and I can use this code just fine for all the layers we go through. It does make it easier on me. I just have a question with * being a wild card. Lets say have 2 xrefs one is Civil and the other one is Topo and they both have the C-BLDG-OTLN layer in them. Will this function change the color on both xrefs with the layer "C-BLDG-OTLN"&amp;nbsp; to&amp;nbsp; color 152 or will it only happen to one xref? I would assume it would happen to both since it is * is a wildcard it won't care what xref is in the drawing it only care is it contains "|C-BLDG-OTLN". Is that correct?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 03 Mar 2020 19:33:10 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/request-for-autolisp/m-p/9356203#M77679</guid>
      <dc:creator>SnickerinTurtles</dc:creator>
      <dc:date>2020-03-03T19:33:10Z</dc:date>
    </item>
    <item>
      <title>Re: Request for AutoLISP</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/request-for-autolisp/m-p/9356355#M77680</link>
      <description>&lt;P&gt;The layer must first pass the (cond) statement which has two matches. If it does then it must be one or other of the layers. The (if) statement tests for one of the layers, if it's true then it carries out the first statement if this is false then it must be the layer not tested for. This is an either or scenario.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Yes, if you run this code on a drawing with multiple x-refs and each contain the layers then all layers that match will be changed across all of the x-refs. If you want to select a specific x-ref then the match pattern can be altered to include a unique part of the x-ref file name.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Your code snippet wouldn't work, as the "pattern_string" for the wcmatch must be a single comma delimited string.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;(defun c:xrlyrc ( / c_doc c_lyrs c_lst f_lst)
  (setq c_doc (vla-get-activedocument (vlax-get-acad-object))
        c_lyrs (vla-get-layers c_doc)
  );end_setq
  
  (vlax-for lyr c_lyrs
    (if (wcmatch (strcase (vlax-get lyr 'name)) "PROJECT#-HC*");This should uniquely identify a single x-ref
      (cond ( (wcmatch (strcase (vlax-get lyr 'name)) "*|C-BLDG-OVHG,*|C-BLDG-DOOR,*|C-BLDG-WNDW") (vlax-put lyr 'color 152))
            ( (wcmatch (strcase (vlax-get lyr 'name)) "*|C-UTIL-MNHL,*|C-UTIL-SEWR,*|C-WATR-INLT,*|C-UTIL-WATR") (vlax-put lyr 'color 190))
            ( (wcmatch (strcase (vlax-get lyr 'name)) "*|C-BLDG") (vlax-put lyr 'color 156))
            ( (wcmatch (strcase (vlax-get lyr 'name)) "*|C-BLDG-CLMN") (vlax-put-property lyr 'freeze :vlax-true))
      );end_cond
    );end_if
  );end_for
  (princ)
);end_defun&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The (if) statement tests if the first part of the layer name matches the specific x-ref file. If it does it drops into the condition (cond) statement. If it doesn't it loops to the next layer&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 03 Mar 2020 20:37:18 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/request-for-autolisp/m-p/9356355#M77680</guid>
      <dc:creator>dlanorh</dc:creator>
      <dc:date>2020-03-03T20:37:18Z</dc:date>
    </item>
    <item>
      <title>Re: Request for AutoLISP</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/request-for-autolisp/m-p/9356357#M77681</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/2918796"&gt;@SnickerinTurtles&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;.... Lets say have 2 xrefs ... and they both have the C-BLDG-OTLN layer in them. Will this function change the color on both xrefs with the layer "C-BLDG-OTLN"&amp;nbsp; ...? I would assume it would happen to both .... Is that correct?&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Yes, I believe [without setting up the situation to confirm -- presumably you have that ready for trial] that is correct.&lt;/P&gt;</description>
      <pubDate>Tue, 03 Mar 2020 20:37:31 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/request-for-autolisp/m-p/9356357#M77681</guid>
      <dc:creator>Kent1Cooper</dc:creator>
      <dc:date>2020-03-03T20:37:31Z</dc:date>
    </item>
    <item>
      <title>Re: Request for AutoLISP</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/request-for-autolisp/m-p/9356444#M77682</link>
      <description>&lt;P&gt;Thanks for staying with me dlanorh. I really do appreciate it. I see my mistake as you mentioned, my synat was incorrect I did "LAYER1","LAYER2","LAYER3" when I should have done "LAYER1, LAYER2, LAYER3". And I also needed to say what to happen to each grouping before setting out the next list of layers. Thank you for showing me what I had done wrong.&amp;nbsp;&lt;/P&gt;&lt;P&gt;So these xrefs will change from project to project. You said that there is a way&amp;nbsp;&lt;SPAN&gt;to select a specific x-ref then the match pattern can be altered to include a unique part of the x-ref file name. I would like feature as well.&amp;nbsp; So in your code here:&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;(setq c_doc (vla-get-activedocument (vlax-get-acad-object))
        c_lyrs (vla-get-layers c_doc)
  );end_setq&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;And please correct me if this wrong. This where you set the variable "c_doc" to be able to grab document objects (such as color,layer name, linetypes) from the document we are in. In the next line you set c_lyrs to be the layer name from the (vla-get-layers c_doc). Right? And as you stated the code then "tests if the first part of the layer name matches the specific x-ref file. If it does it drops into the condition (cond) statement." And between these two parts there would be a need for another variable and that variable would have to set, by user input, so it could replace the&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;PRE&gt;(if (wcmatch (strcase (vlax-get lyr 'name)) "PROJECT#-HC*");This should uniquely identify a single x-ref&lt;/PRE&gt;&lt;P&gt;&lt;SPAN&gt;So that "PROJECT#-HC" is what the user types in or more preferable clicking the xref in the drawing. So it checks everything before the "|" to make sure it is part of the specific xref. Then goes through the layers and checks to see if they match and makes the according adjustments.&amp;nbsp;&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN&gt;&amp;nbsp;Something like that? Thanks again for keeping with me. &lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 03 Mar 2020 21:48:04 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/request-for-autolisp/m-p/9356444#M77682</guid>
      <dc:creator>SnickerinTurtles</dc:creator>
      <dc:date>2020-03-03T21:48:04Z</dc:date>
    </item>
  </channel>
</rss>

