<?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 identify polyline micro vertices / deviations. in Visual LISP, AutoLISP and General Customization Forum</title>
    <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/lisp-to-identify-polyline-micro-vertices-deviations/m-p/12741619#M14646</link>
    <description>&lt;P&gt;Might be just as easy to automatically fix them; however, this should fulfill your request. It does all the polylines in your current tab.&amp;nbsp;Adjust the tolerance and circle size as desired. I wasn't sure if you wanted the circles on a specific layer; I just left it on whatever one you currently have selected.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="lisp"&gt;(defun c:polyLineDeviations ( / lst flag tolerance circleSize p dist LWCircle segfinder)
	(setq tolerance 1) ;Change as desired
	(setq circleSize 20) ;Change as desired
	
	(defun LWCircle (center radius) ;circle entmake function
	  (entmakex 
		(append 
		  (list 
			(cons 0 "CIRCLE")
			(cons 100 "AcDbEntity")
			(cons 100 "AcDbCircle")
			(cons 10 center)
			(cons 40 radius)
		  )
		)
	  )
	)
	
	(defun ssList (ss / lst ct)
		(if ss
			(progn
				(setq ct 0)
				(repeat (sslength ss)
					(setq 
						lst (cons (ssname ss ct) lst)
						ct (+ ct 1)
					)
				)
			)
		)
		lst
	)
	
	(defun findpoints (elist)
		(if (= (cdr (assoc 0 elist)) "LWPOLYLINE")
			(foreach inf elist
				(if (= (car inf) 10)
					(setq pointlist (append pointlist (list (append (cdr inf) (list (cdr (assoc 38 elist)))))))
				)
			)
		)
		pointlist
	)
	
	;Finds the coordinate points of a line and returns a list of 2 point line segment lists. 
	(defun segfinder (entname / p1 p2 points pointlist count LastPoint entityValuebyCode) ;Takes a line or polyline and returns a list of points that make it up
		(defun entityValuebyCode (entity code)
			(cdr (assoc code (entget entity)))
		)
		(cond 
			((wcmatch (entityValueByCode entname 0) "*POLYLINE")
				(setq points (findpoints (entget entname)))
				(setq pointlist nil)
				(setq count 0)
				(foreach point points ;Loops through all the segments
					;If first point, do nothing. Starts with second point.
					(if (not (= count 0))
						(progn
							(setq 
								p1 (nth (- count 1) points) ;Set to previous point
								p2 point ;set to current point
							)
							(setq pointlist (append pointlist (list (list p1 p2))))
							(setq LastPoint p2) ;Keep track of last point
						)
					) ;end if
					(setq count (+ count 1))
				) ;end foreach
				;Check if entity is a closed object
				(if (or (= (entityValueByCode entname 70) 1) (= (entityValueByCode entname 70) 129))
					;Add closing segment to list
					(setq pointlist (append pointlist (list (list (nth 0 points) Lastpoint))))
				)
			)
			((= (entityValueByCode entname 0) "LINE")
				(setq pointlist (list (list (entityValueByCode entname 10) (entityValueByCode entname 11))))
			)
		)
		;Output
		pointlist
		
	) ;End segFinder
	
	(foreach polyline (sslist (ssget "_X" (list (cons 0 "LWPOLYLINE")(cons 410 (getvar "Ctab")))))
		(print polyline)
		(setq p (segfinder polyline))
		(foreach it p
			(setq dist (distance (car it) (cadr it)))
			(if (&amp;lt; dist tolerance)
				(if (not flag)
					(setq flag 1 lst (cons (car it) lst))
				)
				(setq flag nil)
			)
		)
	)
	(foreach it lst
		(LWCircle it circleSize)	
	)
	(princ)
)&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Mon, 29 Apr 2024 17:49:18 GMT</pubDate>
    <dc:creator>MrJSmith</dc:creator>
    <dc:date>2024-04-29T17:49:18Z</dc:date>
    <item>
      <title>LISP to identify polyline micro vertices / deviations.</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/lisp-to-identify-polyline-micro-vertices-deviations/m-p/12741488#M14645</link>
      <description>&lt;P&gt;Hello All,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I work with closed polylines a great deal with my job and they are usually created by others and I do extra edits / tagging on top of them. Sometimes I get a file with a massive amount of polyline islands and some of them look normal from a glance / initial selection but upon zooming in the linework is glitchy and messed up in certain areas. Could a lisp be created to select multiple polylines (potentially just one as well) and simply circle or highlight the areas (if applicable) where there are micro deviations in vertices? I will then go manually fix the problem but it would help a lot to have a quick way to identify where these deviations are.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;In the example images, I have a closed polyline that looks normal but within the circled area if you zoom in significantly it shows where the line work got messed up / glitched. This could be noticed by simply selecting the polyline and seeing stacked vertices but sometimes I work with thousands of islands that have thousands of corners each so searching for them is very time consuming.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Any help is appreciated!&lt;/P&gt;</description>
      <pubDate>Mon, 29 Apr 2024 16:35:15 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/lisp-to-identify-polyline-micro-vertices-deviations/m-p/12741488#M14645</guid>
      <dc:creator>3rduser</dc:creator>
      <dc:date>2024-04-29T16:35:15Z</dc:date>
    </item>
    <item>
      <title>Re: LISP to identify polyline micro vertices / deviations.</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/lisp-to-identify-polyline-micro-vertices-deviations/m-p/12741619#M14646</link>
      <description>&lt;P&gt;Might be just as easy to automatically fix them; however, this should fulfill your request. It does all the polylines in your current tab.&amp;nbsp;Adjust the tolerance and circle size as desired. I wasn't sure if you wanted the circles on a specific layer; I just left it on whatever one you currently have selected.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="lisp"&gt;(defun c:polyLineDeviations ( / lst flag tolerance circleSize p dist LWCircle segfinder)
	(setq tolerance 1) ;Change as desired
	(setq circleSize 20) ;Change as desired
	
	(defun LWCircle (center radius) ;circle entmake function
	  (entmakex 
		(append 
		  (list 
			(cons 0 "CIRCLE")
			(cons 100 "AcDbEntity")
			(cons 100 "AcDbCircle")
			(cons 10 center)
			(cons 40 radius)
		  )
		)
	  )
	)
	
	(defun ssList (ss / lst ct)
		(if ss
			(progn
				(setq ct 0)
				(repeat (sslength ss)
					(setq 
						lst (cons (ssname ss ct) lst)
						ct (+ ct 1)
					)
				)
			)
		)
		lst
	)
	
	(defun findpoints (elist)
		(if (= (cdr (assoc 0 elist)) "LWPOLYLINE")
			(foreach inf elist
				(if (= (car inf) 10)
					(setq pointlist (append pointlist (list (append (cdr inf) (list (cdr (assoc 38 elist)))))))
				)
			)
		)
		pointlist
	)
	
	;Finds the coordinate points of a line and returns a list of 2 point line segment lists. 
	(defun segfinder (entname / p1 p2 points pointlist count LastPoint entityValuebyCode) ;Takes a line or polyline and returns a list of points that make it up
		(defun entityValuebyCode (entity code)
			(cdr (assoc code (entget entity)))
		)
		(cond 
			((wcmatch (entityValueByCode entname 0) "*POLYLINE")
				(setq points (findpoints (entget entname)))
				(setq pointlist nil)
				(setq count 0)
				(foreach point points ;Loops through all the segments
					;If first point, do nothing. Starts with second point.
					(if (not (= count 0))
						(progn
							(setq 
								p1 (nth (- count 1) points) ;Set to previous point
								p2 point ;set to current point
							)
							(setq pointlist (append pointlist (list (list p1 p2))))
							(setq LastPoint p2) ;Keep track of last point
						)
					) ;end if
					(setq count (+ count 1))
				) ;end foreach
				;Check if entity is a closed object
				(if (or (= (entityValueByCode entname 70) 1) (= (entityValueByCode entname 70) 129))
					;Add closing segment to list
					(setq pointlist (append pointlist (list (list (nth 0 points) Lastpoint))))
				)
			)
			((= (entityValueByCode entname 0) "LINE")
				(setq pointlist (list (list (entityValueByCode entname 10) (entityValueByCode entname 11))))
			)
		)
		;Output
		pointlist
		
	) ;End segFinder
	
	(foreach polyline (sslist (ssget "_X" (list (cons 0 "LWPOLYLINE")(cons 410 (getvar "Ctab")))))
		(print polyline)
		(setq p (segfinder polyline))
		(foreach it p
			(setq dist (distance (car it) (cadr it)))
			(if (&amp;lt; dist tolerance)
				(if (not flag)
					(setq flag 1 lst (cons (car it) lst))
				)
				(setq flag nil)
			)
		)
	)
	(foreach it lst
		(LWCircle it circleSize)	
	)
	(princ)
)&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 29 Apr 2024 17:49:18 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/lisp-to-identify-polyline-micro-vertices-deviations/m-p/12741619#M14646</guid>
      <dc:creator>MrJSmith</dc:creator>
      <dc:date>2024-04-29T17:49:18Z</dc:date>
    </item>
    <item>
      <title>Re: LISP to identify polyline micro vertices / deviations.</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/lisp-to-identify-polyline-micro-vertices-deviations/m-p/12741837#M14647</link>
      <description>&lt;P&gt;This works great but could you make it so that I can just select certain polylines? I work in model space and have lots of polylines that don't need the deviation check and it will currently just make circles everywhere in areas I don't need them. Also how easy is it to automatically fix? Do you mean take the largest nearest lines outside of the tolerance and intersect them and go with that point while deleting the other vertices?&lt;/P&gt;</description>
      <pubDate>Mon, 29 Apr 2024 19:31:22 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/lisp-to-identify-polyline-micro-vertices-deviations/m-p/12741837#M14647</guid>
      <dc:creator>3rduser</dc:creator>
      <dc:date>2024-04-29T19:31:22Z</dc:date>
    </item>
    <item>
      <title>Re: LISP to identify polyline micro vertices / deviations.</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/lisp-to-identify-polyline-micro-vertices-deviations/m-p/12741903#M14648</link>
      <description>&lt;P&gt;You can change it to only do ones you select by changing this line:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="lisp"&gt;(foreach polyline (sslist (ssget "_X" (list (cons 0 "LWPOLYLINE")(cons 410 (getvar "Ctab")))))&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;To the following:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="lisp"&gt;(foreach polyline (sslist (ssget (list (cons 0 "LWPOLYLINE"))))&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Yes something like that. There are various methods you could consider, that being one. Personally I'd just go with the easiest to code which would probably be remove any vertices/points that are less than the tolerance.&amp;nbsp; Or something to that effect. Not sure how "accurate" these fixes need to be.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 29 Apr 2024 21:09:26 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/lisp-to-identify-polyline-micro-vertices-deviations/m-p/12741903#M14648</guid>
      <dc:creator>MrJSmith</dc:creator>
      <dc:date>2024-04-29T21:09:26Z</dc:date>
    </item>
    <item>
      <title>Re: LISP to identify polyline micro vertices / deviations.</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/lisp-to-identify-polyline-micro-vertices-deviations/m-p/12742012#M14649</link>
      <description>&lt;P&gt;Thank you! Deleted one parenthesis and it works great! Much appreciated, marked as solution.&lt;/P&gt;</description>
      <pubDate>Mon, 29 Apr 2024 21:00:00 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/lisp-to-identify-polyline-micro-vertices-deviations/m-p/12742012#M14649</guid>
      <dc:creator>3rduser</dc:creator>
      <dc:date>2024-04-29T21:00:00Z</dc:date>
    </item>
    <item>
      <title>Re: LISP to identify polyline micro vertices / deviations.</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/lisp-to-identify-polyline-micro-vertices-deviations/m-p/12742027#M14650</link>
      <description>&lt;P&gt;They don't call it Lost In Stupid Parenthesis for nothing &lt;span class="lia-unicode-emoji" title=":winking_face:"&gt;😉&lt;/span&gt; Glad it works! &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 29 Apr 2024 21:10:33 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/lisp-to-identify-polyline-micro-vertices-deviations/m-p/12742027#M14650</guid>
      <dc:creator>MrJSmith</dc:creator>
      <dc:date>2024-04-29T21:10:33Z</dc:date>
    </item>
  </channel>
</rss>

