<?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 to create boundaries for each hatch layer in Visual LISP, AutoLISP and General Customization Forum</title>
    <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/lisp-to-create-boundaries-for-each-hatch-layer/m-p/10255445#M61274</link>
    <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;@Anonymous&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I'm trying to create a LISP routine to process every hatch within a drawing file.&lt;/P&gt;
&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&lt;FONT size="3"&gt;Try this first, and see if that works for you&lt;/FONT&gt;&amp;nbsp;&amp;nbsp;&lt;A href="https://jtbworld.com/autocad-hatchb-lsp" target="_blank" rel="noopener"&gt;HATCHB.LSP by JTB&lt;/A&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Wed, 21 Apr 2021 03:57:12 GMT</pubDate>
    <dc:creator>pbejse</dc:creator>
    <dc:date>2021-04-21T03:57:12Z</dc:date>
    <item>
      <title>LISP to create boundaries for each hatch layer</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/lisp-to-create-boundaries-for-each-hatch-layer/m-p/10255275#M61273</link>
      <description>&lt;P&gt;Hi Everyone,&lt;/P&gt;&lt;P&gt;I'm trying to create a LISP routine to process every hatch within a drawing file. The steps required are:&lt;/P&gt;&lt;P&gt;&amp;gt;for each hatch layer in the drawing&lt;/P&gt;&lt;P&gt;&amp;gt;set it as the current layer&lt;/P&gt;&lt;P&gt;&amp;gt;then generate a polyline boundary&lt;/P&gt;&lt;P&gt;&amp;gt;save drawing&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I want the routine iterate through each hatch layer and create a polyline on that hatch layer.&lt;/P&gt;&lt;P&gt;The hatches are nonassociative.&lt;/P&gt;&lt;P&gt;I'm new to LISP so below is a snippet with which I would appreciate some help:&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:rehash ()
(vl-load-com)
(while (setq OBJ (ssname SSET (setq CNT (1+ CNT))))
    (setvar 'clayer (cdr (assoc 8 (entget OBJ))))
    (command "-hatchedit" OBJ "b" "r" "y")
    (command "_.HATCHGENERATEBOUNDARY" hnd "")
)
)
 (princ)
) &lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 21 Apr 2021 01:34:39 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/lisp-to-create-boundaries-for-each-hatch-layer/m-p/10255275#M61273</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2021-04-21T01:34:39Z</dc:date>
    </item>
    <item>
      <title>Re: LISP to create boundaries for each hatch layer</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/lisp-to-create-boundaries-for-each-hatch-layer/m-p/10255445#M61274</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;@Anonymous&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I'm trying to create a LISP routine to process every hatch within a drawing file.&lt;/P&gt;
&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&lt;FONT size="3"&gt;Try this first, and see if that works for you&lt;/FONT&gt;&amp;nbsp;&amp;nbsp;&lt;A href="https://jtbworld.com/autocad-hatchb-lsp" target="_blank" rel="noopener"&gt;HATCHB.LSP by JTB&lt;/A&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 21 Apr 2021 03:57:12 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/lisp-to-create-boundaries-for-each-hatch-layer/m-p/10255445#M61274</guid>
      <dc:creator>pbejse</dc:creator>
      <dc:date>2021-04-21T03:57:12Z</dc:date>
    </item>
    <item>
      <title>Re: LISP to create boundaries for each hatch layer</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/lisp-to-create-boundaries-for-each-hatch-layer/m-p/10255446#M61275</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:rehash ( / obj sset oldlay)
(setq oldlay (getvar 'clayer))
  (setq sset (ssget '((0 . "HATCH"))))
  (repeat (setq x (sslength sset))
    (setq OBJ (ssname SSET (setq x (- x 1))))
    (setvar 'clayer (cdr (assoc 8 (entget OBJ))))
    (command "-hatchedit" OBJ "b" "P" "N")
  )
  (setvar 'clayer oldlay)
  (command "regen")
  (princ)
)
(c:rehash)&lt;/LI-CODE&gt;</description>
      <pubDate>Wed, 21 Apr 2021 03:56:10 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/lisp-to-create-boundaries-for-each-hatch-layer/m-p/10255446#M61275</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2021-04-21T03:56:10Z</dc:date>
    </item>
    <item>
      <title>Ynt: LISP to create boundaries for each hatch layer</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/lisp-to-create-boundaries-for-each-hatch-layer/m-p/10255448#M61276</link>
      <description>&lt;P&gt;try this&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="csharp"&gt;(defun c:test (/ ss i en)
(if (setq ss (ssget "_X" '((0 . "HATCH") )))
  (progn
(repeat (setq i (sslength ss))
  
(setq en (ssname ss (setq i (1- i))))
  (setq objvl (vlax-ename-&amp;gt;vla-object en)) 
 
  (vlax-put-property objvl 'layer (getvar "clayer"))
  
  (command"_hatchedit"  en  "_boundary"  "_polyline"  "_yes" )
  
); repeat

(setvar "filedia" 0)

(vl-cmdf "_Saveas" "2013" "" "Y")

(setvar "filedia" 1)

)
); if
(princ)
)&lt;/LI-CODE&gt;</description>
      <pubDate>Wed, 21 Apr 2021 03:56:36 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/lisp-to-create-boundaries-for-each-hatch-layer/m-p/10255448#M61276</guid>
      <dc:creator>hosneyalaa</dc:creator>
      <dc:date>2021-04-21T03:56:36Z</dc:date>
    </item>
    <item>
      <title>Ynt: LISP to create boundaries for each hatch layer</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/lisp-to-create-boundaries-for-each-hatch-layer/m-p/10255453#M61277</link>
      <description>&lt;P&gt;8:55 8:56 8:57 all at same time.&lt;/P&gt;</description>
      <pubDate>Wed, 21 Apr 2021 03:59:53 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/lisp-to-create-boundaries-for-each-hatch-layer/m-p/10255453#M61277</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2021-04-21T03:59:53Z</dc:date>
    </item>
    <item>
      <title>Ynt: LISP to create boundaries for each hatch layer</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/lisp-to-create-boundaries-for-each-hatch-layer/m-p/10255554#M61278</link>
      <description>&lt;P&gt;Although this lisp did create polyline boundaries, it also mixed up my hatch layers....so it didn't work&lt;/P&gt;</description>
      <pubDate>Wed, 21 Apr 2021 05:26:57 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/lisp-to-create-boundaries-for-each-hatch-layer/m-p/10255554#M61278</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2021-04-21T05:26:57Z</dc:date>
    </item>
    <item>
      <title>Re: LISP to create boundaries for each hatch layer</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/lisp-to-create-boundaries-for-each-hatch-layer/m-p/10255573#M61279</link>
      <description>&lt;P&gt;crashes...&lt;/P&gt;</description>
      <pubDate>Wed, 21 Apr 2021 05:41:10 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/lisp-to-create-boundaries-for-each-hatch-layer/m-p/10255573#M61279</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2021-04-21T05:41:10Z</dc:date>
    </item>
    <item>
      <title>Re: LISP to create boundaries for each hatch layer</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/lisp-to-create-boundaries-for-each-hatch-layer/m-p/10255578#M61280</link>
      <description>&lt;P&gt;This routine requires that I select hatches....there are hundreds! Also, it creates boundaries on layer 0 and not on the hatch layer as required.&lt;/P&gt;</description>
      <pubDate>Wed, 21 Apr 2021 05:47:33 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/lisp-to-create-boundaries-for-each-hatch-layer/m-p/10255578#M61280</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2021-04-21T05:47:33Z</dc:date>
    </item>
    <item>
      <title>Re: LISP to create boundaries for each hatch layer</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/lisp-to-create-boundaries-for-each-hatch-layer/m-p/10255735#M61281</link>
      <description>&lt;P&gt;This is what I'm using for this.&lt;/P&gt;
&lt;P&gt;Change ssget to&amp;nbsp;(ssget "_X" (list '(0 . "HATCH") (cons 410 (getvar 'ctab)))) if you want to process all of them without user prompt to select them. And learn about ssget&amp;nbsp;&lt;A href="http://www.lee-mac.com/ssget.html" target="_self"&gt;HERE&lt;/A&gt;&amp;nbsp;&lt;/P&gt;
&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;PRE&gt;(defun c:BoundaryMultiple (/ *error* adoc clay ss i enl i ssl clay) ; pgp B 
  
  (defun *error* (errmsg)
    (if (not (wcmatch errmsg "Function cancelled,quit / exit abort,console break,end"))
      (princ (strcat "\nError: " errmsg)))
    (and (= (logand 8 (getvar 'undoctl)) 8) adoc (vla-endundomark adoc))
    (if clay (setvar 'clayer clay))
    (princ))
  
  (if (setq ss (ssget "_:L" '((0 . "HATCH"))))
    (progn
      (setq clay (getvar 'CLAYER))
      (setvar 'PEDITACCEPT 1)
      (vla-startundomark (setq adoc (vla-get-activedocument (vlax-get-acad-object))))
      
      (repeat (setq i (sslength ss))
	(setq ent (ssname ss (setq i (1- i)))
	      enl (entlast)
	      ssl (ssadd))
	(setvar 'CLAYER (cdr (assoc 8 (entget ent))))
	(command "_.-HATCHEDIT" ent "_b" "_p" "_y")
	(while (setq enl (entnext enl))
	  (ssadd enl ssl))
	(if (&amp;gt; (sslength ssl) 1) 
	  (command "_.PEDIT" "_m" ssl "" "_j" "_j" "_b" "0.05" "")))
      (vla-endundomark adoc)
      ;(command "_erase" ss "")
      ;(vla-endundomark adoc)
      ;(princ "\n&amp;gt;&amp;gt; To restore hatches hit UNDO once.")&lt;BR /&gt;  ))
  (princ)
  )
&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 21 Apr 2021 07:18:16 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/lisp-to-create-boundaries-for-each-hatch-layer/m-p/10255735#M61281</guid>
      <dc:creator>ВeekeeCZ</dc:creator>
      <dc:date>2021-04-21T07:18:16Z</dc:date>
    </item>
    <item>
      <title>Re: LISP to create boundaries for each hatch layer</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/lisp-to-create-boundaries-for-each-hatch-layer/m-p/10259195#M61282</link>
      <description>&lt;P&gt;As we had no test dwg just made something and it worked fine, you should post a test dwg so we can see why it crashes.&lt;/P&gt;</description>
      <pubDate>Thu, 22 Apr 2021 10:57:19 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/lisp-to-create-boundaries-for-each-hatch-layer/m-p/10259195#M61282</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2021-04-22T10:57:19Z</dc:date>
    </item>
  </channel>
</rss>

