<?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: Automated Color Changes? in Visual LISP, AutoLISP and General Customization Forum</title>
    <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/automated-color-changes/m-p/11905661#M31322</link>
    <description>&lt;P&gt;Save it from a plain-text editor such as Notepad to a file with a &lt;STRONG&gt;.lsp&lt;/STRONG&gt; filetype ending [call it whatever you want as a file name otherwise].&amp;nbsp; In AutoCAD, use APPLOAD to load it, and type the command name &lt;STRONG&gt;RWGY&lt;/STRONG&gt; [always the part immediately following the &lt;STRONG&gt;C:&lt;/STRONG&gt;, and you can change that to anything you prefer] to use it.&amp;nbsp; If you want to try it first, you can just paste the code into AutoCAD at the command line, hit Enter if it ends at a &lt;STRONG&gt;)&lt;/STRONG&gt;, and then type the command name.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;There's a way to have it loaded automatically into every drawing you create or open, if it's something you would use often enough to want that.&amp;nbsp; If you have other things defined into a file of such things that you load, it can be added into that instead of having its own separate file.&lt;/P&gt;</description>
    <pubDate>Tue, 18 Apr 2023 21:47:57 GMT</pubDate>
    <dc:creator>Kent1Cooper</dc:creator>
    <dc:date>2023-04-18T21:47:57Z</dc:date>
    <item>
      <title>Automated Color Changes?</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/automated-color-changes/m-p/11905606#M31319</link>
      <description>&lt;P&gt;Hoping to get some ideas here! My company just switched sheet lasers, and the new machine doesn't read DWG color data (for determining laser power) the same as the old one. What I'm hoping to do is create a batch process to modify all the old files into compatible ones. Essentially, here are the steps I'm hoping to automate:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;- Open DWG&lt;/P&gt;&lt;P&gt;- Explode block (there's just one in each drawing)&lt;/P&gt;&lt;P&gt;- QSELECT all RED lines&lt;/P&gt;&lt;P&gt;- Change property to WHITE&lt;/P&gt;&lt;P&gt;- QSELECT all GREEN lines&lt;/P&gt;&lt;P&gt;- Change property to YELLOW&lt;/P&gt;&lt;P&gt;- SAVE&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;So far I've looked at BatchInEditor, but that doesn't quite seem to have the correct commands. I'm guessing this is a good situation for a custom LISP, but I don't have any experience writing those. I greatly appreciate any insights. Thanks!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;(Attached sample files for reference)&lt;/P&gt;</description>
      <pubDate>Tue, 18 Apr 2023 21:08:36 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/automated-color-changes/m-p/11905606#M31319</guid>
      <dc:creator>johnfischerLSI</dc:creator>
      <dc:date>2023-04-18T21:08:36Z</dc:date>
    </item>
    <item>
      <title>Re: Automated Color Changes?</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/automated-color-changes/m-p/11905639#M31320</link>
      <description>&lt;P&gt;(defun C:RWGY () ; = Red to White, Green to Yellow&lt;/P&gt;
&lt;P&gt;&amp;nbsp; (command&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp; "_.explode" (entlast)&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp; "_.chprop" (ssget "_X" '((62 . 1))) "" "_color" 7 ""&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp;&amp;nbsp;"_.chprop" (ssget "_X" '((62 . 3))) "" "_color" 2 ""&lt;/P&gt;
&lt;P&gt;&amp;nbsp; )&lt;/P&gt;
&lt;P&gt;&amp;nbsp; (prin1)&lt;/P&gt;
&lt;P&gt;)&lt;/P&gt;</description>
      <pubDate>Tue, 18 Apr 2023 21:21:50 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/automated-color-changes/m-p/11905639#M31320</guid>
      <dc:creator>Kent1Cooper</dc:creator>
      <dc:date>2023-04-18T21:21:50Z</dc:date>
    </item>
    <item>
      <title>Re: Automated Color Changes?</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/automated-color-changes/m-p/11905644#M31321</link>
      <description>&lt;P&gt;Wow, that was quick! I'm pretty new to using these sorts of commands, how do I enter this in, exactly? Do I need to add this to the body of a new LISP command?&lt;/P&gt;</description>
      <pubDate>Tue, 18 Apr 2023 21:24:34 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/automated-color-changes/m-p/11905644#M31321</guid>
      <dc:creator>johnfischerLSI</dc:creator>
      <dc:date>2023-04-18T21:24:34Z</dc:date>
    </item>
    <item>
      <title>Re: Automated Color Changes?</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/automated-color-changes/m-p/11905661#M31322</link>
      <description>&lt;P&gt;Save it from a plain-text editor such as Notepad to a file with a &lt;STRONG&gt;.lsp&lt;/STRONG&gt; filetype ending [call it whatever you want as a file name otherwise].&amp;nbsp; In AutoCAD, use APPLOAD to load it, and type the command name &lt;STRONG&gt;RWGY&lt;/STRONG&gt; [always the part immediately following the &lt;STRONG&gt;C:&lt;/STRONG&gt;, and you can change that to anything you prefer] to use it.&amp;nbsp; If you want to try it first, you can just paste the code into AutoCAD at the command line, hit Enter if it ends at a &lt;STRONG&gt;)&lt;/STRONG&gt;, and then type the command name.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;There's a way to have it loaded automatically into every drawing you create or open, if it's something you would use often enough to want that.&amp;nbsp; If you have other things defined into a file of such things that you load, it can be added into that instead of having its own separate file.&lt;/P&gt;</description>
      <pubDate>Tue, 18 Apr 2023 21:47:57 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/automated-color-changes/m-p/11905661#M31322</guid>
      <dc:creator>Kent1Cooper</dc:creator>
      <dc:date>2023-04-18T21:47:57Z</dc:date>
    </item>
    <item>
      <title>Re: Automated Color Changes?</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/automated-color-changes/m-p/11905835#M31323</link>
      <description>&lt;P&gt;Going back to &lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/69526"&gt;@Kent1Cooper&lt;/a&gt;&amp;nbsp;'s proposal and you want to do a batch process on a folder, try this&lt;/P&gt;&lt;P&gt;For security purposes:&lt;BR /&gt;You open a single Autocad session (a new drawing, no other drawings open)&lt;BR /&gt;You copy-paste the given code directly into the command line.&lt;BR /&gt;You choose the folder where all the drawings to be processed are contained.&lt;BR /&gt;And there you should have a command window which will run AcCoreConsole on each of your files.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="general"&gt;((lambda ( / f_exe ShlObj Folder FldObj Out_Fld file_scr file_bat)
  (vl-load-com)
  (setq f_exe (findfile "accoreconsole.exe"))
  (setq
    ShlObj (vla-getinterfaceobject (vlax-get-acad-object) "Shell.Application")
    Folder (vlax-invoke-method ShlObj 'BrowseForFolder 0 "" 0)
  )
  (vlax-release-object ShlObj)
  (if Folder
    (progn
      (setq
        FldObj (vlax-get-property Folder 'Self)
        Out_Fld (vlax-get-property FldObj 'Path)
      )
      (vlax-release-object Folder)
      (vlax-release-object FldObj)
    )
  )
  (setq file_scr (open (strcat (getvar "ROAMABLEROOTPREFIX") "support\\update.scr") "w"))
  (write-line "((lambda ( / ss n)" file_scr)
  (write-line " (setq ss (ssget \"_X\" '((0 . \"INSERT\") (2 . \"`*U*\"))))" file_scr)
  (write-line " (if ss" file_scr)
  (write-line "   (repeat (setq n (sslength ss))" file_scr)
  (write-line "     (command \"_.explode\" (ssname ss (setq n (1- n))))" file_scr)
  (write-line "   )" file_scr)
  (write-line " )" file_scr)
  (write-line " (setq ss (ssget \"_X\" '((62 . 1))))" file_scr)
  (write-line " (if ss (command \"_.chprop\" ss \"\" \"_color\" 7 \"\"))" file_scr)
  (write-line " (setq ss (ssget \"_X\" '((62 . 3))))" file_scr)
  (write-line " (if ss (command \"_.chprop\" ss \"\" \"_color\" 2 \"\"))" file_scr)
  (write-line "))" file_scr)
  (write-line "(command \"_.audit\" \"_Yes\")" file_scr)
  (write-line "(command \"_.-purge\" \"_Regapps\" \"*\" \"_No\")" file_scr)
  (write-line "(command \"_.-purge\" \"_All\" \"*\" \"_No\")" file_scr)
  (write-line "(command \"_.saveas\" \"_LT2013\" \"\" \"_Yes\")" file_scr)
  (close file_scr)
  (setq file_bat (open (strcat (getvar "ROAMABLEROOTPREFIX") "support\\update.bat") "w"))
  (write-line (eval (read "(strcat \"set accoreexe=\" \"\\\"\" f_exe \"\\\"\")")) file_bat)
  (write-line (eval (read "(strcat \"set source=\" \"\\\"\" Out_Fld \"\\\"\")")) file_bat)
  (write-line (eval (read "(strcat \"set script=\" \"\\\"\" (getvar \"ROAMABLEROOTPREFIX\") \"support\\\\update.scr\" \"\\\"\")")) file_bat)
  (write-line "FOR /f \"delims=\" %%f IN ('dir /b \"%source%\\\*.dwg\"') DO %accoreexe% /i \"%source%\\%%f\" /s %script%" file_bat)
  (close file_bat)
  (startapp (strcat (getvar "ROAMABLEROOTPREFIX") "support\\update.bat"))
  (princ"\Job finished")
  (prin1)
))&lt;/LI-CODE&gt;</description>
      <pubDate>Tue, 18 Apr 2023 23:57:31 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/automated-color-changes/m-p/11905835#M31323</guid>
      <dc:creator>CADaSchtroumpf</dc:creator>
      <dc:date>2023-04-18T23:57:31Z</dc:date>
    </item>
    <item>
      <title>Re: Automated Color Changes?</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/automated-color-changes/m-p/11906479#M31324</link>
      <description>&lt;P&gt;hey,&lt;/P&gt;&lt;P&gt;is there a necessity to explode a block?&lt;/P&gt;</description>
      <pubDate>Wed, 19 Apr 2023 08:06:42 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/automated-color-changes/m-p/11906479#M31324</guid>
      <dc:creator>komondormrex</dc:creator>
      <dc:date>2023-04-19T08:06:42Z</dc:date>
    </item>
    <item>
      <title>Re: Automated Color Changes?</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/automated-color-changes/m-p/11906990#M31325</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;.... is there a necessity to explode a block?&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;They would need to answer that, but some thoughts:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;It's certainly a lot easier to change the colors working with top-level objects rather than nested ones, so Exploding simplifies things considerably.&amp;nbsp; But with more complex code it could be done inside the Block definition.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Since in their case, as described, there's only the one Block in a drawing, it &lt;EM&gt;reduces the file size&lt;/EM&gt; to Explode it, if it is also then &lt;EM&gt;Purged&lt;/EM&gt; from the drawing.&amp;nbsp; It takes less memory to store the information about the pieces on their own than to store all of that &lt;EM&gt;and&lt;/EM&gt; the definition of it all into a Block &lt;EM&gt;and&lt;/EM&gt; the information about the Insertion of that Block.&lt;/P&gt;</description>
      <pubDate>Wed, 19 Apr 2023 12:29:13 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/automated-color-changes/m-p/11906990#M31325</guid>
      <dc:creator>Kent1Cooper</dc:creator>
      <dc:date>2023-04-19T12:29:13Z</dc:date>
    </item>
    <item>
      <title>Re: Automated Color Changes?</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/automated-color-changes/m-p/11912767#M31326</link>
      <description>&lt;P&gt;This worked like a charm! Thank you so much for your help!&lt;/P&gt;</description>
      <pubDate>Fri, 21 Apr 2023 13:58:10 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/automated-color-changes/m-p/11912767#M31326</guid>
      <dc:creator>johnfischerLSI</dc:creator>
      <dc:date>2023-04-21T13:58:10Z</dc:date>
    </item>
  </channel>
</rss>

