<?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: LISP/Command - new layers in Visual LISP, AutoLISP and General Customization Forum</title>
    <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/lisp-command-new-layers/m-p/7902216#M106534</link>
    <description>&lt;P&gt;Try this as a start:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;(defun C:DEMO (/ esel ent DLname)
  (while (setq esel (entsel "\nPick object to put on its Demo Layer: "))
    (setq
      ent (car esel)
      DLname (strcat (cdr (assoc 8 (entget ent))) "-DEMO")
    )
    (command
      "_.layer" "_make" DLname "_color" 8 "" "_ltype" "HIDDEN2" "" ""
      "_.chprop" ent "" "_layer" DLname ""
    )
  )
  (princ)
)&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Use a color and linetype suited to your needs -- mine are assumptions.&amp;nbsp; Although it's not necessary, it could be made to check, for each object, &lt;EM&gt;whether&lt;/EM&gt;&amp;nbsp; its corresponding -DEMO Layer already exists, instead of just Making it regardless -- more code, but perhaps faster by milliseconds that you'd never notice when selecting something with such a Layer already in the drawing.&amp;nbsp; And it could check that a selected object is not &lt;EM&gt;already&lt;/EM&gt;&amp;nbsp; on a -DEMO Layer, so you don't get Layer names ending in -DEMO-DEMO and so on.&amp;nbsp; And it could check for locked Layers, and override Properties, and probably some other potential complications.&amp;nbsp; And it could be made to let you select everything at once, instead of only one at a time, and process each according to its own current Layer.&lt;/P&gt;</description>
    <pubDate>Mon, 02 Apr 2018 21:13:16 GMT</pubDate>
    <dc:creator>Kent1Cooper</dc:creator>
    <dc:date>2018-04-02T21:13:16Z</dc:date>
    <item>
      <title>LISP/Command - new layers</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/lisp-command-new-layers/m-p/7902185#M106533</link>
      <description>&lt;P&gt;Trying to create a Demolition plan. I want to create new layers with the same name but add a -demo to the suffix. But I also want to keep the original layer.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;For example:&lt;/P&gt;&lt;P&gt;E-CONCRETE&lt;/P&gt;&lt;P&gt;E-CONCRETE-DEMO&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Ultimately I would love to have a demo command button. This button would allow me to select the entity, change it to the new layer with the -demo suffix, and change the color. This way I can go around the survey, and easily click the items i want to be demo'd.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Hope that makes sense.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Does something like this already exist?&lt;/P&gt;</description>
      <pubDate>Mon, 02 Apr 2018 20:55:39 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/lisp-command-new-layers/m-p/7902185#M106533</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2018-04-02T20:55:39Z</dc:date>
    </item>
    <item>
      <title>Re: LISP/Command - new layers</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/lisp-command-new-layers/m-p/7902216#M106534</link>
      <description>&lt;P&gt;Try this as a start:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;(defun C:DEMO (/ esel ent DLname)
  (while (setq esel (entsel "\nPick object to put on its Demo Layer: "))
    (setq
      ent (car esel)
      DLname (strcat (cdr (assoc 8 (entget ent))) "-DEMO")
    )
    (command
      "_.layer" "_make" DLname "_color" 8 "" "_ltype" "HIDDEN2" "" ""
      "_.chprop" ent "" "_layer" DLname ""
    )
  )
  (princ)
)&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Use a color and linetype suited to your needs -- mine are assumptions.&amp;nbsp; Although it's not necessary, it could be made to check, for each object, &lt;EM&gt;whether&lt;/EM&gt;&amp;nbsp; its corresponding -DEMO Layer already exists, instead of just Making it regardless -- more code, but perhaps faster by milliseconds that you'd never notice when selecting something with such a Layer already in the drawing.&amp;nbsp; And it could check that a selected object is not &lt;EM&gt;already&lt;/EM&gt;&amp;nbsp; on a -DEMO Layer, so you don't get Layer names ending in -DEMO-DEMO and so on.&amp;nbsp; And it could check for locked Layers, and override Properties, and probably some other potential complications.&amp;nbsp; And it could be made to let you select everything at once, instead of only one at a time, and process each according to its own current Layer.&lt;/P&gt;</description>
      <pubDate>Mon, 02 Apr 2018 21:13:16 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/lisp-command-new-layers/m-p/7902216#M106534</guid>
      <dc:creator>Kent1Cooper</dc:creator>
      <dc:date>2018-04-02T21:13:16Z</dc:date>
    </item>
    <item>
      <title>Re: LISP/Command - new layers</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/lisp-command-new-layers/m-p/7904749#M106535</link>
      <description>&lt;P&gt;This is perfect! thank you! I will have to research on how to add the additional code so I don't get the -demo-demo and add multiple entity selection.&lt;/P&gt;</description>
      <pubDate>Tue, 03 Apr 2018 15:50:37 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/lisp-command-new-layers/m-p/7904749#M106535</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2018-04-03T15:50:37Z</dc:date>
    </item>
    <item>
      <title>Re: LISP/Command - new layers</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/lisp-command-new-layers/m-p/7905210#M106536</link>
      <description>&lt;P&gt;Give this a try for multiple selection:&lt;/P&gt;&lt;PRE&gt;(defun c:laysuf	(/ e el l f s tm)
  ;; RJP - 04.03.2018
  (or (setq f (getenv "RJP_LayerSuffix")) (setq f (getenv "username")))
  (if (and (setq f (cond ((/= "" (setq tm (getstring (strcat "\nEnter suffix [&amp;lt;" f "&amp;gt;]: "))) tm))
			 (f)
		   )
	   )
	   (setq s (ssget ":L" (list (cons 8 (strcat "~*" f)))))
      )
    (progn (setenv "RJP_LayerSuffix" f)
	   (foreach e (vl-remove-if 'listp (mapcar 'cadr (ssnamex s)))
	     (setq l (cdr (assoc 8 (entget e))))
	     (setq el (entget (tblobjname "layer" l)))
	     (if (not (tblobjname "layer" (strcat l f)))
	       (entmakex (subst (cons 2 (strcat l f)) (assoc 2 el) el))
	     )
	     (entmod (subst (cons 8 (strcat l f)) (assoc 8 (entget e)) (entget e)))
	   )
    )
  )
  (princ)
)&lt;/PRE&gt;</description>
      <pubDate>Tue, 03 Apr 2018 18:00:39 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/lisp-command-new-layers/m-p/7905210#M106536</guid>
      <dc:creator>ronjonp</dc:creator>
      <dc:date>2018-04-03T18:00:39Z</dc:date>
    </item>
    <item>
      <title>Re: LISP/Command - new layers</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/lisp-command-new-layers/m-p/7905244#M106537</link>
      <description>&lt;P&gt;That works the same as the previous lisp. I guess what I meant by multiple selection was using a window'd selection.&lt;/P&gt;</description>
      <pubDate>Tue, 03 Apr 2018 18:10:08 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/lisp-command-new-layers/m-p/7905244#M106537</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2018-04-03T18:10:08Z</dc:date>
    </item>
    <item>
      <title>Re: LISP/Command - new layers</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/lisp-command-new-layers/m-p/7905275#M106538</link>
      <description>&lt;P&gt;Did you try it? it also clears up your "&lt;SPAN&gt;-demo-demo" problem.&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 03 Apr 2018 18:19:10 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/lisp-command-new-layers/m-p/7905275#M106538</guid>
      <dc:creator>ronjonp</dc:creator>
      <dc:date>2018-04-03T18:19:10Z</dc:date>
    </item>
    <item>
      <title>Re: LISP/Command - new layers</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/lisp-command-new-layers/m-p/7905319#M106539</link>
      <description>&lt;P&gt;ah ha! New to the lisp routines and how they work. Was using the wrong command to execute it. works great!&lt;/P&gt;</description>
      <pubDate>Tue, 03 Apr 2018 18:30:47 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/lisp-command-new-layers/m-p/7905319#M106539</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2018-04-03T18:30:47Z</dc:date>
    </item>
    <item>
      <title>Re: LISP/Command - new layers</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/lisp-command-new-layers/m-p/7905510#M106540</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;@Anonymous wrote:&lt;BR /&gt;
&lt;P&gt;This is perfect! thank you! I will have to research on how to add the additional code so I don't get the -demo-demo and add multiple entity selection.&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;You have a solution, but here's the extension of my earlier routine to incorporate those aspects.&amp;nbsp; [And as with that one, it's DEMO-specific, rather than usable for any Layer-name suffix.]&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;(defun C:DEMO (/ esel ent DLname)
  (prompt "\nTo move object(s) to corresponding -DEMO Layers,")
  (if (setq ss (ssget ":L"))
    (repeat (setq n (sslength ss))
      (setq
        ent (ssname ss (setq n (1- n)))
        edata (entget ent)
      ); setq
      (if (not (wcmatch (strcase (cdr (assoc 8 edata))) "*-DEMO")); not already on such a Layer
        (command
          "_.layer" "_make" (setq DLname (strcat (cdr (assoc 8 (entget ent))) "-DEMO")) "_color" 8 "" "_ltype" "HIDDEN2" "" ""
          "_.chprop" ent "" "_layer" DLname ""
        ); command
      ); if
    ); repeat
  ); if
  (princ)
); defun&lt;/PRE&gt;</description>
      <pubDate>Tue, 03 Apr 2018 19:21:10 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/lisp-command-new-layers/m-p/7905510#M106540</guid>
      <dc:creator>Kent1Cooper</dc:creator>
      <dc:date>2018-04-03T19:21:10Z</dc:date>
    </item>
    <item>
      <title>Re: LISP/Command - new layers</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/lisp-command-new-layers/m-p/7905542#M106541</link>
      <description>&lt;P&gt;Kent,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;FWIW, you could filter out the selection first like so:&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;(setq ss (ssget ":L" '((8 . "~*-DEMO"))))&lt;/PRE&gt;&lt;P&gt;There is a typo in my code above but I'm unable to edit:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;;; Change this&lt;BR /&gt;((/= "" (setq tm (getstring (strcat "\nEnter suffix [&amp;lt;" f "&amp;gt;]: "))) tm))&lt;BR /&gt;;; to this&lt;BR /&gt;((/= "" (setq tm (getstring (strcat "\nEnter suffix [&amp;lt;" f "&amp;gt;]: ")))) tm)&lt;BR /&gt;&lt;BR /&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 03 Apr 2018 19:37:46 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/lisp-command-new-layers/m-p/7905542#M106541</guid>
      <dc:creator>ronjonp</dc:creator>
      <dc:date>2018-04-03T19:37:46Z</dc:date>
    </item>
  </channel>
</rss>

