<?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 or native way to close polylines that appear closed but aren't in Visual LISP, AutoLISP and General Customization Forum</title>
    <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/lisp-or-native-way-to-close-polylines-that-appear-closed-but/m-p/7521100#M112398</link>
    <description>&lt;P&gt;I should have kept a copy of the file with the 2000+ unclosed polylines so I could check the speed, but I didn't, so I can't compare the speed of the new with the old routine, but I'll assume the new one is better and go with that.&lt;/P&gt;</description>
    <pubDate>Mon, 06 Nov 2017 18:21:35 GMT</pubDate>
    <dc:creator>mpa-la</dc:creator>
    <dc:date>2017-11-06T18:21:35Z</dc:date>
    <item>
      <title>Lisp or native way to close polylines that appear closed but aren't</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/lisp-or-native-way-to-close-polylines-that-appear-closed-but/m-p/7520929#M112391</link>
      <description>&lt;P&gt;Looking for a way to select many polylines at once and close the ones that have the same start and end point but aren't closed. I want to do this so that the linetype generation looks perfect (on non-continuous linetypes).&amp;nbsp; I do NOT want to close ones that do not have the same start and end point.&amp;nbsp; Thanks!&lt;/P&gt;</description>
      <pubDate>Mon, 06 Nov 2017 17:25:53 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/lisp-or-native-way-to-close-polylines-that-appear-closed-but/m-p/7520929#M112391</guid>
      <dc:creator>mpa-la</dc:creator>
      <dc:date>2017-11-06T17:25:53Z</dc:date>
    </item>
    <item>
      <title>Re: Lisp or native way to close polylines that appear closed but aren't</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/lisp-or-native-way-to-close-polylines-that-appear-closed-but/m-p/7520994#M112392</link>
      <description>&lt;P&gt;Maybe try below. Something very quick and dirty. Minimal testing&lt;/P&gt;
&lt;PRE&gt;(defun c:somefunc  (/ etdata lst)
 (mapcar '(lambda (x)
           (setq lst (cdr (reverse (vl-remove-if-not 'listp (mapcar 'cdr (setq etdata (entget x)))))))
           (if (equal (car lst) (last lst) 1e-6)
            (entmod (subst '(70 . 129) (assoc 70 etdata) etdata))))
         (vl-remove-if 'listp
                       (mapcar 'cadr
                               (ssnamex (ssget '((0 . "lwpolyline") (-4 . "&amp;lt;NOT") (-4 . "&amp;amp;") (70 . 1) (-4 . "NOT&amp;gt;"))))))))&lt;/PRE&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="apparently_close.gif" style="width: 651px;"&gt;&lt;img src="https://forums.autodesk.com/t5/image/serverpage/image-id/422486i4C73125CD3719AE0/image-size/large?v=v2&amp;amp;px=999" role="button" title="apparently_close.gif" alt="apparently_close.gif" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;I am using a fuzz factor of 0.000001 to check the proximity of start and end points. You can eliminate that to make sure the points truly lie on top of each other.&lt;/P&gt;
&lt;PRE&gt;...............
           (if (equal (car lst) (last lst) &lt;FONT color="#999999"&gt;&lt;STRIKE&gt;1e-6&lt;/STRIKE&gt;&lt;/FONT&gt;&lt;FONT color="#000000"&gt;)&lt;/FONT&gt;
            .............&lt;/PRE&gt;</description>
      <pubDate>Mon, 06 Nov 2017 17:47:43 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/lisp-or-native-way-to-close-polylines-that-appear-closed-but/m-p/7520994#M112392</guid>
      <dc:creator>Ranjit_Singh</dc:creator>
      <dc:date>2017-11-06T17:47:43Z</dc:date>
    </item>
    <item>
      <title>Re: Lisp or native way to close polylines that appear closed but aren't</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/lisp-or-native-way-to-close-polylines-that-appear-closed-but/m-p/7521023#M112393</link>
      <description>&lt;P&gt;Perfect!! I just tried it on 2514 polylines at once, and it worked perfectly.&amp;nbsp; Took about 10-15 seconds to run, but I can't imagine using it on more polylines than that at once, so that is no problem!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks!!&lt;/P&gt;</description>
      <pubDate>Mon, 06 Nov 2017 17:56:02 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/lisp-or-native-way-to-close-polylines-that-appear-closed-but/m-p/7521023#M112393</guid>
      <dc:creator>mpa-la</dc:creator>
      <dc:date>2017-11-06T17:56:02Z</dc:date>
    </item>
    <item>
      <title>Re: Lisp or native way to close polylines that appear closed but aren't</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/lisp-or-native-way-to-close-polylines-that-appear-closed-but/m-p/7521028#M112394</link>
      <description>&lt;P&gt;It does dump a boatload of text on the command line, I know there's an easy way to suppress that, but I don't recall how...&lt;/P&gt;</description>
      <pubDate>Mon, 06 Nov 2017 17:57:44 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/lisp-or-native-way-to-close-polylines-that-appear-closed-but/m-p/7521028#M112394</guid>
      <dc:creator>mpa-la</dc:creator>
      <dc:date>2017-11-06T17:57:44Z</dc:date>
    </item>
    <item>
      <title>Re: Lisp or native way to close polylines that appear closed but aren't</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/lisp-or-native-way-to-close-polylines-that-appear-closed-but/m-p/7521041#M112395</link>
      <description>&lt;P&gt;Add a (princ) before the function close&lt;/P&gt;
&lt;PRE&gt;(defun c:somefunc  (/ etdata lst)
 (mapcar '(lambda (x)
           (setq lst (cdr (reverse (vl-remove-if-not 'listp (mapcar 'cdr (setq etdata (entget x)))))))
           (if (equal (car lst) (last lst) 1e-6)
            (entmod (subst '(70 . 129) (assoc 70 etdata) etdata))))
         (vl-remove-if 'listp
                       (mapcar 'cadr
                               (ssnamex (ssget '((0 . "lwpolyline") (-4 . "&amp;lt;NOT") (-4 . "&amp;amp;") (70 . 1) (-4 . "NOT&amp;gt;")))))))
 (princ))&lt;/PRE&gt;</description>
      <pubDate>Mon, 06 Nov 2017 18:01:38 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/lisp-or-native-way-to-close-polylines-that-appear-closed-but/m-p/7521041#M112395</guid>
      <dc:creator>Ranjit_Singh</dc:creator>
      <dc:date>2017-11-06T18:01:38Z</dc:date>
    </item>
    <item>
      <title>Re: Lisp or native way to close polylines that appear closed but aren't</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/lisp-or-native-way-to-close-polylines-that-appear-closed-but/m-p/7521057#M112396</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/56278"&gt;@mpa-la&lt;/a&gt; wrote:&lt;BR /&gt;
&lt;P&gt;.........Took about 10-15 seconds to run........&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Try below. It maybe&amp;nbsp;faster.&lt;/P&gt;
&lt;PRE&gt;(defun c:somefunc  (/ etdata lst ctr ss1)
 (setq ss1 (ssget '((0 . "lwpolyline") (-4 . "&amp;lt;NOT") (-4 . "&amp;amp;") (70 . 1) (-4 . "NOT&amp;gt;")))
       ctr -1)
 (if ss1
  (repeat (sslength ss1)
   (setq lst (vl-remove-if-not '(lambda (x) (= 10 (car x)))
                               (setq etdata (entget (ssname ss1 (setq ctr (1+ ctr)))))))
   (if (equal (cdar lst) (cdr (last lst)) 1e-6)
    (entmod (subst '(70 . 129) (assoc 70 etdata) etdata)))))
 (princ))&lt;/PRE&gt;</description>
      <pubDate>Mon, 06 Nov 2017 18:10:24 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/lisp-or-native-way-to-close-polylines-that-appear-closed-but/m-p/7521057#M112396</guid>
      <dc:creator>Ranjit_Singh</dc:creator>
      <dc:date>2017-11-06T18:10:24Z</dc:date>
    </item>
    <item>
      <title>Re: Lisp or native way to close polylines that appear closed but aren't</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/lisp-or-native-way-to-close-polylines-that-appear-closed-but/m-p/7521078#M112397</link>
      <description>&lt;P&gt;Be aware, if it matters to you, that the routine closes them by &lt;EM&gt;adding a closing segment of zero length&lt;/EM&gt;, that is, a triangular one will&amp;nbsp;still have 4 segments, and&amp;nbsp;4&amp;nbsp;vertices with the 4th one in the same place as the 1st one.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;For several routines designed to close them &lt;EM&gt;without&lt;/EM&gt;&amp;nbsp; that added zero-length without the added zero-length segment [a triangular one ends up with segments and 3 vertices], see &lt;A href="https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/filleting-own-polyline-or-closing-it-without-new-vertice/td-p/2519823/highlight/true" target="_blank"&gt;this thread&lt;/A&gt;. &amp;nbsp;Whatever you may find appropriate there would need to be modified [easy enough to do] if you want it to fix apparently-closed ones but leave clearly-unclosed ones alone, because that thread is about closing &lt;EM&gt;all&lt;/EM&gt; selected Polylines, with the no-extra-segment part for those that look closed being a refinement.&lt;/P&gt;</description>
      <pubDate>Mon, 06 Nov 2017 18:14:04 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/lisp-or-native-way-to-close-polylines-that-appear-closed-but/m-p/7521078#M112397</guid>
      <dc:creator>Kent1Cooper</dc:creator>
      <dc:date>2017-11-06T18:14:04Z</dc:date>
    </item>
    <item>
      <title>Re: Lisp or native way to close polylines that appear closed but aren't</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/lisp-or-native-way-to-close-polylines-that-appear-closed-but/m-p/7521100#M112398</link>
      <description>&lt;P&gt;I should have kept a copy of the file with the 2000+ unclosed polylines so I could check the speed, but I didn't, so I can't compare the speed of the new with the old routine, but I'll assume the new one is better and go with that.&lt;/P&gt;</description>
      <pubDate>Mon, 06 Nov 2017 18:21:35 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/lisp-or-native-way-to-close-polylines-that-appear-closed-but/m-p/7521100#M112398</guid>
      <dc:creator>mpa-la</dc:creator>
      <dc:date>2017-11-06T18:21:35Z</dc:date>
    </item>
    <item>
      <title>Re: Lisp or native way to close polylines that appear closed but aren't</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/lisp-or-native-way-to-close-polylines-that-appear-closed-but/m-p/7521104#M112399</link>
      <description>&lt;P&gt;Thanks Kent, that is good to know.&amp;nbsp; Having that extra segment in there shouldn't cause a problem.&amp;nbsp; You are correct, I don't want to close them all, just the apparently closed ones.&lt;/P&gt;</description>
      <pubDate>Mon, 06 Nov 2017 18:22:36 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/lisp-or-native-way-to-close-polylines-that-appear-closed-but/m-p/7521104#M112399</guid>
      <dc:creator>mpa-la</dc:creator>
      <dc:date>2017-11-06T18:22:36Z</dc:date>
    </item>
    <item>
      <title>Re: Lisp or native way to close polylines that appear closed but aren't</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/lisp-or-native-way-to-close-polylines-that-appear-closed-but/m-p/7522531#M112400</link>
      <description>&lt;P&gt;This is a little simpler is an example but again adds a missing line&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;(while (/= (setq obj (vlax-ename-&amp;gt;vla-object (car (entsel)))) nil)&lt;BR /&gt;(vla-put-closed obj :vlax-true)&lt;BR /&gt;)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 07 Nov 2017 04:41:54 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/lisp-or-native-way-to-close-polylines-that-appear-closed-but/m-p/7522531#M112400</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2017-11-07T04:41:54Z</dc:date>
    </item>
    <item>
      <title>Re: Lisp or native way to close polylines that appear closed but aren't</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/lisp-or-native-way-to-close-polylines-that-appear-closed-but/m-p/10586848#M112401</link>
      <description>&lt;P&gt;Hy from France,&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;A simple way to close POLYLINE without lisp is to use the PEDIT command&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;If you want to close all POLYLINE in the drawing the used&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="YAUBRY_1-1630399833764.png" style="width: 400px;"&gt;&lt;img src="https://forums.autodesk.com/t5/image/serverpage/image-id/959263i3E58C1009F9DAD1A/image-size/medium?v=v2&amp;amp;px=400" role="button" title="YAUBRY_1-1630399833764.png" alt="YAUBRY_1-1630399833764.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;If you want to close all POLYLINE in a previous selectionset the used&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="YAUBRY_0-1630399740937.png" style="width: 400px;"&gt;&lt;img src="https://forums.autodesk.com/t5/image/serverpage/image-id/959262iCFF7143E16DC1457/image-size/medium?v=v2&amp;amp;px=400" role="button" title="YAUBRY_0-1630399740937.png" alt="YAUBRY_0-1630399740937.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 31 Aug 2021 08:54:52 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/lisp-or-native-way-to-close-polylines-that-appear-closed-but/m-p/10586848#M112401</guid>
      <dc:creator>Y.AUBRY</dc:creator>
      <dc:date>2021-08-31T08:54:52Z</dc:date>
    </item>
    <item>
      <title>Re: Lisp or native way to close polylines that appear closed but aren't</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/lisp-or-native-way-to-close-polylines-that-appear-closed-but/m-p/10587435#M112402</link>
      <description>&lt;P&gt;That would close polylines with different end and beginning points, so a C shaped polyline would become an 0 shaped polyline, not what I wanted.&amp;nbsp; I only wanted to close polylines that appear closed, but are not.&lt;/P&gt;</description>
      <pubDate>Tue, 31 Aug 2021 13:23:22 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/lisp-or-native-way-to-close-polylines-that-appear-closed-but/m-p/10587435#M112402</guid>
      <dc:creator>mpa-la</dc:creator>
      <dc:date>2021-08-31T13:23:22Z</dc:date>
    </item>
    <item>
      <title>Re: Lisp or native way to close polylines that appear closed but aren't</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/lisp-or-native-way-to-close-polylines-that-appear-closed-but/m-p/10587668#M112403</link>
      <description>&lt;P&gt;In looking through this Topic again, one thing I notice about both accepted solutions above is that &lt;EM&gt;they force linetype generation on&lt;/EM&gt;, whether or not it was on for a given Polyline.&amp;nbsp; If you want to &lt;EM&gt;preserve&lt;/EM&gt; the linetype generation on/off status of Polylines, this does that, though it still only closes with a zero-length segment, leaving the coincident start/end vertices:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="general"&gt;(vl-load-com); if needed
(defun C:CLPC
  ; = Closed-Looking Polyline Close [keeping coincident start/end vertices, with 0-length segment]
  (/ ss n pl pldata)
  (if (setq ss (ssget "_:L" '((0 . "lwpolyline") (-4 . "&amp;lt;NOT") (-4 . "&amp;amp;") (70 . 1) (-4 . "NOT&amp;gt;"))))
    (repeat (setq n (sslength ss))
      (setq
        pl (ssname ss (setq n (1- n)))
        pldata (entget pl)
      ); setq
      (if (equal (vlax-curve-getStartPoint pl) (vlax-curve-getEndPoint pl) 1e-6)
        (entmod (subst (cons 70 (1+ (cdr (assoc 70 pldata)))) (assoc 70 pldata) pldata))
      ); if [start/end at same place]
    ); repeat
  ); if [found unclosed Polylines]
  (princ)
); defun&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;[It also uses a different approach to some things, principally that it's not necessary to extract a list of &lt;EM&gt;all&lt;/EM&gt; vertices in order to compare whether the start and end ones are in the same place.]&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;But I keep mentioning the zero-length closing segment and coincident start-end vertices issue [see Message 7], because there have been several topics raised here in which some routine didn't work right on Polylines, and it turned out the reason was that they contained coincident vertices.&amp;nbsp; They can definitely cause problems with certain operations.&amp;nbsp; If you want to take Polylines that &lt;EM&gt;look&lt;/EM&gt; closed but are not really, and close them &lt;EM&gt;without&lt;/EM&gt; keeping both vertices at the start/end location, and &lt;EM&gt;without&lt;/EM&gt; a zero-length closing segment, this [a modification of something from the Topic linked at Message 7] will do that:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;(vl-load-com); if needed
(defun C:CLPCE ; = Closed-Looking Polyline Close Eliminating coincident start/end vertices
  (/ ss n pl pldata)
  (if (setq ss (ssget "_:L" '((0 . "lwpolyline") (-4 . "&amp;lt;NOT") (-4 . "&amp;amp;") (70 . 1) (-4 . "NOT&amp;gt;"))))
    (repeat (setq n (sslength ss))
      (setq
        pl (ssname ss (setq n (1- n)))
        pldata (entget pl)
      ); setq
      (if (equal (vlax-curve-getStartPoint pl) (vlax-curve-getEndPoint pl) 1e-6)
        (progn ; then - edit off last segment, and close
          (command "_.pedit" pl "_edit"); end command
          (repeat (- (cdr (assoc 90 pldata)) 2) (command "_next")); move to next-to-last vertex
          (command "_break" "_next" "_go" "_eXit" "_close" "")
        ); progn
      ); if [start/end at same place]
    ); repeat
  ); if [found unclosed Polylines]
  (princ)
); defun&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 31 Aug 2021 14:46:08 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/lisp-or-native-way-to-close-polylines-that-appear-closed-but/m-p/10587668#M112403</guid>
      <dc:creator>Kent1Cooper</dc:creator>
      <dc:date>2021-08-31T14:46:08Z</dc:date>
    </item>
  </channel>
</rss>

