<?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: New layer with block name in Visual LISP, AutoLISP and General Customization Forum</title>
    <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/new-layer-with-block-name/m-p/10072336#M64585</link>
    <description>&lt;P&gt;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/69526"&gt;@Kent1Cooper&lt;/a&gt;&amp;nbsp;Thanks for the "reverse".&lt;/P&gt;&lt;P&gt;How can avoid to not select such others *u* , "as&amp;nbsp;&amp;nbsp;&lt;SPAN&gt;associative Array objects?"&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;</description>
    <pubDate>Wed, 10 Feb 2021 12:24:33 GMT</pubDate>
    <dc:creator>devitg</dc:creator>
    <dc:date>2021-02-10T12:24:33Z</dc:date>
    <item>
      <title>New layer with block name</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/new-layer-with-block-name/m-p/10070389#M64579</link>
      <description>&lt;P&gt;Hello Forum, I am not sure this is at all possible, but I figured you all would know.&amp;nbsp; I would like to write a comman/LISP routine where I can create a new layer with the same name as an already existing block.&amp;nbsp; For example, I have a block labeled "Frame_1" I then run this command, select this block and it creates a layer called "Frame_1".&amp;nbsp; I've been playing around with making layers from a few different ways, and I can't find a way to copy a name from a block...yet.&amp;nbsp; Any ideas?&lt;/P&gt;</description>
      <pubDate>Tue, 09 Feb 2021 18:26:49 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/new-layer-with-block-name/m-p/10070389#M64579</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2021-02-09T18:26:49Z</dc:date>
    </item>
    <item>
      <title>Re: New layer with block name</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/new-layer-with-block-name/m-p/10070846#M64580</link>
      <description>Search in the forum found this older post &lt;A href="https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/lisp-to-move-blocks-to-their-own-layers-based-on-block-name/td-p/5331511" target="_blank"&gt;https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/lisp-to-move-blocks-to-their-own-layers-based-on-block-name/td-p/5331511&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;HTH&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Tue, 09 Feb 2021 20:54:27 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/new-layer-with-block-name/m-p/10070846#M64580</guid>
      <dc:creator>pendean</dc:creator>
      <dc:date>2021-02-09T20:54:27Z</dc:date>
    </item>
    <item>
      <title>Re: New layer with block name</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/new-layer-with-block-name/m-p/10070847#M64581</link>
      <description>&lt;P&gt;If they're &lt;EM&gt;not Dynamic Blocks&lt;/EM&gt;, something like this [untested]:&lt;/P&gt;
&lt;LI-CODE lang="general"&gt;(defun C:LBN ; = Layer with Block's Name
  (/ esel edata)
  (if
    (and
      (setq esel (entsel "\nSelect Block to create Layer with its Name: "))
      (member '(0 . "INSERT") (setq edata (entget (car esel))))
    ); and
    (command "_.layer" "_new" (cdr (assoc 2 edata)) "")
  ); if
  (princ)
); defun&lt;/LI-CODE&gt;
&lt;P&gt;That will use the defaults for the properties of the Layer [color, linetype, etc.], but you can add options to set those.&amp;nbsp; It won't care if the Layer already exists, i.e. if you run it and pick a Block you had already done it with.&amp;nbsp; Be aware that it will do the same even if you pick an Xref, or an associative Array object, or a WMF image, but it can be made to avoid those if necessary.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;It could also be made to put the selected Block on the Layer named for it.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you might ever do it with &lt;EM&gt;Dynamic&lt;/EM&gt; Blocks, I assume it should be adjusted to get the "effective" name, rather than use the (assoc 2) Block name, which will be an "anonymous" type starting with *U.&lt;/P&gt;</description>
      <pubDate>Tue, 09 Feb 2021 20:54:35 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/new-layer-with-block-name/m-p/10070847#M64581</guid>
      <dc:creator>Kent1Cooper</dc:creator>
      <dc:date>2021-02-09T20:54:35Z</dc:date>
    </item>
    <item>
      <title>Re: New layer with block name</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/new-layer-with-block-name/m-p/10071005#M64582</link>
      <description>&lt;P&gt;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/69526"&gt;@Kent1Cooper&lt;/a&gt;&amp;nbsp; about DYN blocks , how to make the filter&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I try&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="general"&gt;(setq blk-references-ss (ssget "X" '((0 . "insert")    (2 . "*U*"))))&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;But it return NIL ,&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;It seem to be the * shall be treated in other way&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Please&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 09 Feb 2021 21:57:17 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/new-layer-with-block-name/m-p/10071005#M64582</guid>
      <dc:creator>devitg</dc:creator>
      <dc:date>2021-02-09T21:57:17Z</dc:date>
    </item>
    <item>
      <title>Re: New layer with block name</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/new-layer-with-block-name/m-p/10071099#M64583</link>
      <description>&lt;P&gt;Try the reverse-apostrophe prefix "&lt;FONT color="#FF00FF"&gt;&lt;STRONG&gt;`&lt;/STRONG&gt;&lt;/FONT&gt;*U*" to have it take the first asterisk literally, not as a wildcard.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;But be aware that the same *U prefix is used for the "names" of associative Array objects, which are also of the "INSERT" variety.&lt;/P&gt;</description>
      <pubDate>Tue, 09 Feb 2021 22:58:52 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/new-layer-with-block-name/m-p/10071099#M64583</guid>
      <dc:creator>Kent1Cooper</dc:creator>
      <dc:date>2021-02-09T22:58:52Z</dc:date>
    </item>
    <item>
      <title>Re: New layer with block name</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/new-layer-with-block-name/m-p/10071807#M64584</link>
      <description>&lt;P&gt;Here's another version that works with multiple selection.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;(vl-load-com)

(defun c:BNamesToLayer (/ s i o n)
  
  (if (setq s (ssget '((0 . "INSERT"))))
    (repeat (setq i (sslength s))
      (setq o (vlax-ename-&amp;gt;vla-object (ssname s (setq i (1- i))))
	    n (vlax-get-property o (if (vlax-property-available-p o 'EffectiveName) 'EffectiveName 'Name)))
      (if (tblsearch "LAYER" n)
	(princ (strcat "\nLayer '" n "' already exists."))
	(progn
	  (entmake (list '(0 . "LAYER") '(100 . "AcDbSymbolTableRecord") '(100 . "AcDbLayerTableRecord") (cons 2 n) '(70 . 0)))
	  (princ (strcat "\nLayer '" n "' created."))))))
  (princ)
  )
&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 10 Feb 2021 08:17:35 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/new-layer-with-block-name/m-p/10071807#M64584</guid>
      <dc:creator>ВeekeeCZ</dc:creator>
      <dc:date>2021-02-10T08:17:35Z</dc:date>
    </item>
    <item>
      <title>Re: New layer with block name</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/new-layer-with-block-name/m-p/10072336#M64585</link>
      <description>&lt;P&gt;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/69526"&gt;@Kent1Cooper&lt;/a&gt;&amp;nbsp;Thanks for the "reverse".&lt;/P&gt;&lt;P&gt;How can avoid to not select such others *u* , "as&amp;nbsp;&amp;nbsp;&lt;SPAN&gt;associative Array objects?"&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 10 Feb 2021 12:24:33 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/new-layer-with-block-name/m-p/10072336#M64585</guid>
      <dc:creator>devitg</dc:creator>
      <dc:date>2021-02-10T12:24:33Z</dc:date>
    </item>
    <item>
      <title>Re: New layer with block name</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/new-layer-with-block-name/m-p/10072471#M64586</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/58962"&gt;@devitg&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/69526"&gt;@Kent1Cooper&lt;/a&gt;&amp;nbsp;Thanks for the "reverse".&lt;/P&gt;
&lt;P&gt;How can avoid to not select such others *u* , "as&amp;nbsp;&amp;nbsp;&lt;SPAN&gt;associative Array objects?"&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;I &lt;EM&gt;think&lt;/EM&gt; [I'm not sure this is foolproof] that if the "effective name" is &lt;EM&gt;different from&lt;/EM&gt; the (assoc 2) name, it's a Dynamic Block, but if they are the same, it's an associative Array.&amp;nbsp; If 'ent' is the entity name:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;(if (= (vla-get-EffectiveName (vlax-ename-&amp;gt;vla-object ent)) (cdr (assoc 2 (entget ent))))&lt;/P&gt;
&lt;P&gt;&amp;nbsp; (.... then -- it's an associative Array ....)&lt;/P&gt;
&lt;P&gt;&amp;nbsp; (.... else -- it's a Dynamic Block ....)&lt;/P&gt;
&lt;P&gt;)&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;There are probably other ways to tell the difference, but I haven't dug into it.&lt;/P&gt;</description>
      <pubDate>Wed, 10 Feb 2021 13:13:36 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/new-layer-with-block-name/m-p/10072471#M64586</guid>
      <dc:creator>Kent1Cooper</dc:creator>
      <dc:date>2021-02-10T13:13:36Z</dc:date>
    </item>
    <item>
      <title>Re: New layer with block name</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/new-layer-with-block-name/m-p/10072534#M64587</link>
      <description>&lt;P&gt;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/69526"&gt;@Kent1Cooper&lt;/a&gt;&amp;nbsp;So there is no way to get it by filter list .&amp;nbsp;&lt;/P&gt;&lt;P&gt;Ok . Thanks .&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 10 Feb 2021 13:24:50 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/new-layer-with-block-name/m-p/10072534#M64587</guid>
      <dc:creator>devitg</dc:creator>
      <dc:date>2021-02-10T13:24:50Z</dc:date>
    </item>
    <item>
      <title>Re: New layer with block name</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/new-layer-with-block-name/m-p/10072582#M64588</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/58962"&gt;@devitg&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/69526"&gt;@Kent1Cooper&lt;/a&gt;&amp;nbsp;So there is no way to get it by filter list .&amp;nbsp;&lt;/P&gt;
&lt;P&gt;....&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Array objects have this kind of thing in their entity data:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;(102 . "{ACAD_REACTORS") (330 . &amp;lt;Entity name: 2af43f20&amp;gt;) (102 . "}")&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;which Blocks don't.&amp;nbsp; So it should be possible to filter for things &lt;EM&gt;without (102) entries&lt;/EM&gt;.&lt;/P&gt;</description>
      <pubDate>Wed, 10 Feb 2021 13:40:46 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/new-layer-with-block-name/m-p/10072582#M64588</guid>
      <dc:creator>Kent1Cooper</dc:creator>
      <dc:date>2021-02-10T13:40:46Z</dc:date>
    </item>
    <item>
      <title>Re: New layer with block name</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/new-layer-with-block-name/m-p/10108611#M64589</link>
      <description>&lt;P&gt;Thank you, I must not have looked for the right tag words.&amp;nbsp;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 24 Feb 2021 15:48:50 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/new-layer-with-block-name/m-p/10108611#M64589</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2021-02-24T15:48:50Z</dc:date>
    </item>
    <item>
      <title>Re: New layer with block name</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/new-layer-with-block-name/m-p/10158572#M64590</link>
      <description>&lt;P&gt;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/69526"&gt;@Kent1Cooper&lt;/a&gt;&amp;nbsp;I have been playing around with this LISP and added a part to put the block on the newly created layer, but now I am trying to change that layer color to a random color.&amp;nbsp; I have been doing research and am at a sticking point.&amp;nbsp; Based on what I have read and my understanding, the below lisp SHOULD work, but it clearly isn't.&amp;nbsp; Any advice?&amp;nbsp; I saw a couple of posts where you helped with random number generation especially pertaining to color and I don't think I care about repeating colors.&amp;nbsp; It would be nice to not include dark colors as I saw you did with another lisp, but not necessary.&amp;nbsp; Thank you!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="general"&gt;(defun C:LBN ; = Layer with Block's Name

  (if
    (and
      (setq esel (entsel "\nSelect Block to create Layer with its Name: "))
      (member '(0 . "INSERT") (setq edata (entget (car esel))))
    ); and
    (command "_.layer" "_new" (cdr (assoc 2 edata)) "")
 
  ); if
(command "-laymch" "l" "" "N" (cdr (assoc 2 edata)))
(defun LM:rand ( / a c m )
		(setq	m	4294967296.0
			a	1664525.0
			c	1013904223.0
			$xn	(rem (+ c (* a (cond ($xn) ((getvar 'date))))) m))
		(/ $xn m)
	)
	(defun LM:randrange ( a b )
		(+	(min a b)	(fix (* (LM:rand) (1+ (abs (- a b))))))
	)
  (/ esel edata)
(command "-layer" "c" (SETQ num (LM:randrange 1 200)) (cdr (assoc 2 edata)) "")

  (princ)
); defun&lt;/LI-CODE&gt;</description>
      <pubDate>Mon, 15 Mar 2021 19:32:03 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/new-layer-with-block-name/m-p/10158572#M64590</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2021-03-15T19:32:03Z</dc:date>
    </item>
  </channel>
</rss>

