<?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: Recursive function in Visual LISP, AutoLISP and General Customization Forum</title>
    <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/recursive-function/m-p/9503313#M74858</link>
    <description>&lt;P&gt;Thanks all for viewing.&lt;/P&gt;&lt;P&gt;I found the bug...&amp;nbsp;&lt;span class="lia-unicode-emoji" title=":relieved_face:"&gt;😌&lt;/span&gt;&lt;BR /&gt;the variable "len" was open and so it was creating the issue.&lt;BR /&gt;&lt;BR /&gt;Thanks&amp;nbsp;&lt;span class="lia-unicode-emoji" title=":smiling_face_with_smiling_eyes:"&gt;😊&lt;/span&gt;&lt;/P&gt;</description>
    <pubDate>Sat, 09 May 2020 06:14:20 GMT</pubDate>
    <dc:creator>rajeshpatnaik2001</dc:creator>
    <dc:date>2020-05-09T06:14:20Z</dc:date>
    <item>
      <title>Recursive function</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/recursive-function/m-p/9503259#M74857</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have a drawing with network of lines and points. I am writing a program to select all points at the end of lines and do some processing.&lt;BR /&gt;- select a start point object&lt;BR /&gt;- function will do processing on the&amp;nbsp;point object&lt;/P&gt;&lt;P&gt;- function select the lines connecting the point object&lt;BR /&gt;- function select the points at the ends of these lines and do processing&lt;/P&gt;&lt;P&gt;- so on till all points are processed in all the branches&lt;/P&gt;&lt;P&gt;I have written the following code. This is not working properly. It process points in one branch and then stops.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="general"&gt;(defun c:run( / ent)
(setq line_last nil)
(setq ent (car(entsel)))
(find_point ent)
)

(defun find_point (ent / pt sst sst_line ent_line other_end ent_point cn)
(process_point ent)
(setq sst (ssget "_cp" (get-rect-points (cdr (assoc 10 (entget ent))) 0.1) '((0 . "LWPOLYLINE")) ));;select lines connecting to the point
(if line_last (setq sst_line (ssdel line_last sst)) (setq sst_line sst));;incoming line is removed from selection set
(if (/= (sslength sst_line) 0)
(progn
(setq len (sslength sst_line))
(setq cn 0)
(while (&amp;lt; cn len)
(setq ent_line (ssname sst_line cn))
(setq line_last ent_line)

;;select point on the other end of line
(setq other_end (cdr (assoc 10 (reverse(entget ent_line)))))
(setq ent (ssname (ssget "_cp" (get-rect-points other_end 0.1) '((0 . "POINT")) ) 0))
(if ent (find_point ent))
(setq cn (+ 1 cn))
);while
));if
)

(defun process_point(ent)
(command "change" ent "" "p" "color" "red" "")
)

;;get points of 4 sides at specified distance
(defun get-rect-points (pt dist / pt0$ pt1$ pt2$ pt3$ pt4$)
(setq pt0$ (polar pt 0 dist))
(setq pt1$ (polar pt0$ (/ pi 2) dist))
(setq pt2$ (polar pt1$ pi (* 2 dist)))
(setq pt3$ (polar pt2$ (/ (* 3 pi) 2) (* 2 dist)))
(setq pt4$ (polar pt3$ 0 (* 2 dist)))
(list pt1$ pt2$ pt3$ pt4$ pt1$)
)&lt;/LI-CODE&gt;&lt;P&gt;&lt;BR /&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Capture.PNG" style="width: 483px;"&gt;&lt;img src="https://forums.autodesk.com/t5/image/serverpage/image-id/767678iBC1AE683710F215C/image-size/large?v=v2&amp;amp;px=999" role="button" title="Capture.PNG" alt="Capture.PNG" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Any help would be highly appreciated.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks in advance.&lt;/P&gt;</description>
      <pubDate>Sat, 09 May 2020 04:24:45 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/recursive-function/m-p/9503259#M74857</guid>
      <dc:creator>rajeshpatnaik2001</dc:creator>
      <dc:date>2020-05-09T04:24:45Z</dc:date>
    </item>
    <item>
      <title>Re: Recursive function</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/recursive-function/m-p/9503313#M74858</link>
      <description>&lt;P&gt;Thanks all for viewing.&lt;/P&gt;&lt;P&gt;I found the bug...&amp;nbsp;&lt;span class="lia-unicode-emoji" title=":relieved_face:"&gt;😌&lt;/span&gt;&lt;BR /&gt;the variable "len" was open and so it was creating the issue.&lt;BR /&gt;&lt;BR /&gt;Thanks&amp;nbsp;&lt;span class="lia-unicode-emoji" title=":smiling_face_with_smiling_eyes:"&gt;😊&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Sat, 09 May 2020 06:14:20 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/recursive-function/m-p/9503313#M74858</guid>
      <dc:creator>rajeshpatnaik2001</dc:creator>
      <dc:date>2020-05-09T06:14:20Z</dc:date>
    </item>
    <item>
      <title>Re: Recursive function</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/recursive-function/m-p/9503330#M74859</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Here's a way.&lt;/P&gt;
&lt;P&gt;Instead of using selections which may not be reliable according to the zoom factor, I've rather use a list of points and a list of polylines.&lt;/P&gt;
&lt;LI-CODE lang="general"&gt;(defun c:run (/ procesPoint getPoints mainrec sslist point points plines)

  (defun processPoint (pt / elst pair)
    (setq elst (entget pt))
    (if	(setq pair (assoc 62 elst))
      (entmod (subst '(62 . 1) pair elst))
      (entmod (append elst '((62 . 1))))
    )
    (vl-remove pt points)
  )

  (defun getPoints (point / ss i)
    (setq pos (cdr (assoc 10 (entget point))))
    (vl-remove
      nil
      (mapcar
	'(lambda (pl)
	   (setq pt	(vlax-curve-getEndPoint pl)
		 plines	(vl-remove pl plines)
	   )
	   (vl-some
	     '(lambda (pt)
		(if (equal (vlax-curve-getEndPoint pl)
			   (cdr (assoc 10 (entget pt)))
		    )
		  pt
		)
	      )
	     points
	   )
	 )
	(vl-remove-if-not
	  '(lambda (pl)
	     (equal (vlax-curve-getStartPoint pl) pos)
	   )
	  plines
	)
      )
    )
  )

  (defun mainrec (point)
    (processPoint point)
    (foreach pt	(getPoints point)
      (mainrec pt)
    )
  )

  (defun sslist	(ss / i lst)
    (repeat (setq i (sslength ss))
      (setq lst (cons (ssname ss (setq i (1- i))) lst))
    )
  )

  (if
    (and
      (setq point (car (entsel "\nSelect start point: ")))
      (= (cdr (assoc 0 (entget point))) "POINT")
    )
     (progn
       (setq points (sslist (ssget "_X" '((0 . "POINT"))))
	     plines (sslist (ssget "_X" '((0 . "LWPOLYLINE"))))
       )
       (mainrec point)
     )
  )
  (princ)
)&lt;/LI-CODE&gt;</description>
      <pubDate>Sat, 09 May 2020 06:44:51 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/recursive-function/m-p/9503330#M74859</guid>
      <dc:creator>_gile</dc:creator>
      <dc:date>2020-05-09T06:44:51Z</dc:date>
    </item>
    <item>
      <title>Re: Recursive function</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/recursive-function/m-p/9503503#M74860</link>
      <description>&lt;P&gt;Thanks&amp;nbsp;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/109424"&gt;@_gile&lt;/a&gt;&amp;nbsp; for the excellent idea.&lt;/P&gt;</description>
      <pubDate>Sat, 09 May 2020 10:24:04 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/recursive-function/m-p/9503503#M74860</guid>
      <dc:creator>rajeshpatnaik2001</dc:creator>
      <dc:date>2020-05-09T10:24:04Z</dc:date>
    </item>
  </channel>
</rss>

