<?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: A linetype lisp problem in Visual LISP, AutoLISP and General Customization Forum</title>
    <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/a-linetype-lisp-problem/m-p/11368760#M41960</link>
    <description>&lt;P&gt;Try this code.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;(vl-load-com)

(defun c:LTFromLayer (/ :fixblocknested adoc lst s i e d o l)
   
  (defun :fixblocknested (n / be o)
    (if (not (vl-position n lst))
      (progn
	(setq lst (cons n lst)
	      be (tblobjname "BLOCK" n))
	(while (setq be (entnext be))
	  (if (= (cdr (assoc 0 (entget be))) "INSERT")
	    (:fixblocknested (cdr (assoc 2 (entget be)))))
	  (setq o (vlax-ename-&amp;gt;vla-object be))
	  (vl-catch-all-apply 'vla-put-linetype (list o (cdr (assoc 6 (tblsearch "layer" (vla-get-layer o))))))))))
  
  ;; -------------------------------------------------------------------------------------------
  
  
  (vla-startundomark (setq adoc (vla-get-activedocument (vlax-get-acad-object))))
  
  (if (setq s (ssget "_:L"))

    (repeat (setq i (sslength s))

      (setq e (ssname s (setq i (1- i)))
	    d (entget e)
	    o (vlax-ename-&amp;gt;vla-object e)
	    l (vla-get-layer o))
      
      (if (not (assoc 6 d))
	(vla-put-linetype o (cdr (assoc 6 (tblsearch "layer" l)))))

      (if (and (= "INSERT" (cdr (assoc 0 d)))
	       (setq n (cdr (assoc 2 d)))
	       )
	(:fixblocknested n))))

  (vla-endundomark adoc)
  (command "_.regenall")
  (princ)
  )
&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Fri, 19 Aug 2022 12:08:28 GMT</pubDate>
    <dc:creator>ВeekeeCZ</dc:creator>
    <dc:date>2022-08-19T12:08:28Z</dc:date>
    <item>
      <title>A linetype lisp problem</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/a-linetype-lisp-problem/m-p/11368686#M41959</link>
      <description>&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="general"&gt;;-------- start of code ----

(defun c:ltypetoent (/ n sel entity name i)
     (setq i 0 n 0)
     (princ "\n Select entities to analyze ")
     (setq sel (ssget))
     (setq n (sslength sel))
     (repeat n
          (setq entity (ssname sel i))
          (setq name (entget entity))
          (if (not (assoc 6 name))
               (progn
                    (setq layer (cdr (assoc 8 name)))
     (setq layerinf (tblsearch "LAYER" layer))
     (setq layerltype (cdr (assoc 6 layerinf)))
     (setq name (append name (list (cons 6 layerltype))))
     (entmod name)
     (entupd entity)
               )
          )
          (setq i (+ 1 i))
     )
)
(princ "\n Type LTYPETOENT to run this command ")
(princ)

;------------ end of code ------&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Change BYLAYER linetype setting to linetype defined for layer&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;A href="https://knowledge.autodesk.com/support/autocad/troubleshooting/caas/sfdcarticles/sfdcarticles/Change-BYLAYER-linetype-setting-to-linetype-defined-for-layer.html" target="_blank" rel="noopener"&gt;https://knowledge.autodesk.com/support/autocad/troubleshooting/caas/sfdcarticles/sfdcarticles/Change-BYLAYER-linetype-setting-to-linetype-defined-for-layer.html&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This is the lisp I found on a website , it works fine , but only work on the entities you selected , doesn't work with entities inside blocks , is there a way to also change LTYPE inside a block?&lt;/P&gt;&lt;P&gt;Or in another word, make this command work in the whole drawing file like the SETBYLAYER command.&lt;/P&gt;&lt;P&gt;Sorry for my bad english , if you have trouble reading my question, I will try to explain more&amp;nbsp;&lt;SPAN&gt;precisely.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 19 Aug 2022 11:39:49 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/a-linetype-lisp-problem/m-p/11368686#M41959</guid>
      <dc:creator>tofumen0012</dc:creator>
      <dc:date>2022-08-19T11:39:49Z</dc:date>
    </item>
    <item>
      <title>Re: A linetype lisp problem</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/a-linetype-lisp-problem/m-p/11368760#M41960</link>
      <description>&lt;P&gt;Try this code.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;(vl-load-com)

(defun c:LTFromLayer (/ :fixblocknested adoc lst s i e d o l)
   
  (defun :fixblocknested (n / be o)
    (if (not (vl-position n lst))
      (progn
	(setq lst (cons n lst)
	      be (tblobjname "BLOCK" n))
	(while (setq be (entnext be))
	  (if (= (cdr (assoc 0 (entget be))) "INSERT")
	    (:fixblocknested (cdr (assoc 2 (entget be)))))
	  (setq o (vlax-ename-&amp;gt;vla-object be))
	  (vl-catch-all-apply 'vla-put-linetype (list o (cdr (assoc 6 (tblsearch "layer" (vla-get-layer o))))))))))
  
  ;; -------------------------------------------------------------------------------------------
  
  
  (vla-startundomark (setq adoc (vla-get-activedocument (vlax-get-acad-object))))
  
  (if (setq s (ssget "_:L"))

    (repeat (setq i (sslength s))

      (setq e (ssname s (setq i (1- i)))
	    d (entget e)
	    o (vlax-ename-&amp;gt;vla-object e)
	    l (vla-get-layer o))
      
      (if (not (assoc 6 d))
	(vla-put-linetype o (cdr (assoc 6 (tblsearch "layer" l)))))

      (if (and (= "INSERT" (cdr (assoc 0 d)))
	       (setq n (cdr (assoc 2 d)))
	       )
	(:fixblocknested n))))

  (vla-endundomark adoc)
  (command "_.regenall")
  (princ)
  )
&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 19 Aug 2022 12:08:28 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/a-linetype-lisp-problem/m-p/11368760#M41960</guid>
      <dc:creator>ВeekeeCZ</dc:creator>
      <dc:date>2022-08-19T12:08:28Z</dc:date>
    </item>
    <item>
      <title>Re: A linetype lisp problem</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/a-linetype-lisp-problem/m-p/11369637#M41961</link>
      <description>Thank you so much! It works nicely!</description>
      <pubDate>Fri, 19 Aug 2022 18:32:24 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/a-linetype-lisp-problem/m-p/11369637#M41961</guid>
      <dc:creator>tofumen0012</dc:creator>
      <dc:date>2022-08-19T18:32:24Z</dc:date>
    </item>
  </channel>
</rss>

