<?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 Help with LISP - convert diagonal polyline to zig-zag polyline in Visual LISP, AutoLISP and General Customization Forum</title>
    <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/help-with-lisp-convert-diagonal-polyline-to-zig-zag-polyline/m-p/11188038#M45199</link>
    <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am looking for some AutoLISP expert to help with converting a diagonal polyline to a zig-zag polyline.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Something like the diagram below where I can select an angled polyline and convert it to a zig-zag (orthogonal lines), where it bends at the mid-point of the line. If I can select multiple lines and convert them at once, even better.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="polyline 1.png" style="width: 704px;"&gt;&lt;img src="https://forums.autodesk.com/t5/image/serverpage/image-id/1070880i329FE7E137A14512/image-dimensions/704x479?v=v2" width="704" height="479" role="button" title="polyline 1.png" alt="polyline 1.png" /&gt;&lt;/span&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="poly2.png" style="width: 704px;"&gt;&lt;img src="https://forums.autodesk.com/t5/image/serverpage/image-id/1070881iB3341F2A249D94D4/image-dimensions/704x471?v=v2" width="704" height="471" role="button" title="poly2.png" alt="poly2.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Or perhaps a LISP function to select two points and draw a a bunch of zig-zag polyline between two points is fine also.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I don't have much knowledge of LISP so I am hoping one of you experts can help me. Thank you!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Mon, 23 May 2022 22:31:06 GMT</pubDate>
    <dc:creator>kwatanabeM7CVP</dc:creator>
    <dc:date>2022-05-23T22:31:06Z</dc:date>
    <item>
      <title>Help with LISP - convert diagonal polyline to zig-zag polyline</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/help-with-lisp-convert-diagonal-polyline-to-zig-zag-polyline/m-p/11188038#M45199</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am looking for some AutoLISP expert to help with converting a diagonal polyline to a zig-zag polyline.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Something like the diagram below where I can select an angled polyline and convert it to a zig-zag (orthogonal lines), where it bends at the mid-point of the line. If I can select multiple lines and convert them at once, even better.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="polyline 1.png" style="width: 704px;"&gt;&lt;img src="https://forums.autodesk.com/t5/image/serverpage/image-id/1070880i329FE7E137A14512/image-dimensions/704x479?v=v2" width="704" height="479" role="button" title="polyline 1.png" alt="polyline 1.png" /&gt;&lt;/span&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="poly2.png" style="width: 704px;"&gt;&lt;img src="https://forums.autodesk.com/t5/image/serverpage/image-id/1070881iB3341F2A249D94D4/image-dimensions/704x471?v=v2" width="704" height="471" role="button" title="poly2.png" alt="poly2.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Or perhaps a LISP function to select two points and draw a a bunch of zig-zag polyline between two points is fine also.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I don't have much knowledge of LISP so I am hoping one of you experts can help me. Thank you!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 23 May 2022 22:31:06 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/help-with-lisp-convert-diagonal-polyline-to-zig-zag-polyline/m-p/11188038#M45199</guid>
      <dc:creator>kwatanabeM7CVP</dc:creator>
      <dc:date>2022-05-23T22:31:06Z</dc:date>
    </item>
    <item>
      <title>Re: Help with LISP - convert diagonal polyline to zig-zag polyline</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/help-with-lisp-convert-diagonal-polyline-to-zig-zag-polyline/m-p/11188349#M45200</link>
      <description>&lt;P&gt;Regards&amp;nbsp;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/9092895"&gt;@kwatanabeM7CVP&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Try this code&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:PZZ (/ p1 p2 p3 p4)
  (setq p1 (getpoint "\nPick Point 1: ")
        p2 (getpoint p1 "\nPick Point 2: ")
        p3 (list (+ (car p1) (/ (- (car p2) (car p1)) 2)) (cadr p1) 0.)
        p4 (list (+ (car p1) (/ (- (car p2) (car p1)) 2)) (cadr p2) 0.)
  )
  (setq lst (list p1 p3 p4 p2))
  (entmake (append (list
                     (cons 0 "lwpolyline")
                     (cons 100 "AcDbEntity")
                     (cons 100 "AcDbPolyline")
                     (cons 90 4)
                     (cons 70 0)
                   )
                   (mapcar '(lambda (x) (cons 10 x)) lst)
           )
  )
)&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 24 May 2022 03:40:57 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/help-with-lisp-convert-diagonal-polyline-to-zig-zag-polyline/m-p/11188349#M45200</guid>
      <dc:creator>calderg1000</dc:creator>
      <dc:date>2022-05-24T03:40:57Z</dc:date>
    </item>
    <item>
      <title>Re: Help with LISP - convert diagonal polyline to zig-zag polyline</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/help-with-lisp-convert-diagonal-polyline-to-zig-zag-polyline/m-p/11188495#M45201</link>
      <description>&lt;P&gt;That works great. Thank you&amp;nbsp;&lt;A href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/4920461" target="_self"&gt;&lt;SPAN class=""&gt;calderg1000&lt;/SPAN&gt;&lt;/A&gt;!&lt;/P&gt;</description>
      <pubDate>Tue, 24 May 2022 05:44:16 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/help-with-lisp-convert-diagonal-polyline-to-zig-zag-polyline/m-p/11188495#M45201</guid>
      <dc:creator>kwatanabeM7CVP</dc:creator>
      <dc:date>2022-05-24T05:44:16Z</dc:date>
    </item>
    <item>
      <title>Re: Help with LISP - convert diagonal polyline to zig-zag polyline</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/help-with-lisp-convert-diagonal-polyline-to-zig-zag-polyline/m-p/11188801#M45202</link>
      <description>&lt;P&gt;This one allows multiple selections. Pline could have multiple segments. It inherits the properties of the originals. Remove the last (noted) line to keep the originals.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;(vl-load-com)

(defun c:Ortoline ( / s i e f d l p q o z px)
  
  (if (setq s (ssget "_:L" '((0 . "LWPOLYLINE,LINE"))))
    (repeat (setq i (sslength s))
      (and (setq e (ssname s (setq i (1- i))))
	   (setq d (entget e))
	   (setq l (mapcar 'cdr (if (= "LINE" (cdr (assoc 0 d)))
				  (list (assoc 10 d) (assoc 11 d))
				  (vl-remove-if '(lambda (x) (/= (car x) 10)) d))))
	   (setq f (vlax-ename-&amp;gt;vla-object e))
	   (setq z (apply 'append (mapcar '(lambda (x) (if (vlax-property-available-p f x)
							 (list (list x (vlax-get f x)))))
					  '("Color" "Layer" "LineType" "LinetypeScale" "Lineweight"))))
	   (setq l (apply 'append (mapcar '(lambda (p q) (list p
							       (list (/ (+ (car p) (car q)) 2) (cadr p))
							       (list (/ (+ (car p) (car q)) 2) (cadr q))
							       q))
					  l (cdr l))))
	   (setq l (vl-remove 'nil (mapcar '(lambda (x) (if (not (equal x px 1e-6)) (setq px x))) l))) ; remove p if is same as previous one
	   (setq o (entmakex (append (list '(0 . "LWPOLYLINE") '(100 . "AcDbEntity") '(100 . "AcDbPolyline") (cons 90 (length l)) '(70 . 0))
				     (mapcar '(lambda (x) (cons 10 x)) l))))
	   (setq o (vlax-ename-&amp;gt;vla-object o))
	   (vlax-write-enabled-p o)
	   (mapcar '(lambda (x) (vl-catch-all-apply 'vlax-put (list o (car x) (cadr x)))) z)
	   (entdel e) ; remove this line to keep the originals
	   )))
  (princ)
  )
&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 24 May 2022 08:27:14 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/help-with-lisp-convert-diagonal-polyline-to-zig-zag-polyline/m-p/11188801#M45202</guid>
      <dc:creator>ВeekeeCZ</dc:creator>
      <dc:date>2022-05-24T08:27:14Z</dc:date>
    </item>
    <item>
      <title>Re: Help with LISP - convert diagonal polyline to zig-zag polyline</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/help-with-lisp-convert-diagonal-polyline-to-zig-zag-polyline/m-p/11189195#M45203</link>
      <description>&lt;P&gt;Another approach:&lt;/P&gt;
&lt;LI-CODE lang="general"&gt;(defun C:PLOJ ; = PolyLine Orthogonal Jog
  (/ ss n pl pldata start end midX)
  (if (setq ss (ssget "_:L" '((0 . "LWPOLYLINE"))))
    (repeat (setq n (sslength ss))
      (setq
        pl (ssname ss (setq n (1- n)))
        pldata (entget pl)
        start (cdr (assoc 10 pldata))
        end (cdr (assoc 10 (reverse pldata)))
        midX (/ (+ (car start) (car end)) 2)
      ); setq
      (vlax-put (vlax-ename-&amp;gt;vla-object pl) 'Coordinates
        (append start (list midX (cadr start) midX (cadr end)) end)
      ); ..put
    ); repeat
  ); if
  (princ)
); defun&lt;/LI-CODE&gt;
&lt;P&gt;Multiple selection;&lt;/P&gt;
&lt;P&gt;Goes from start to end with jog, regardless of shape of selected Polyline;&lt;/P&gt;
&lt;P&gt;Simply modifies the coordinates, so has no effect on Layer or any other properties, and no need to delete originals.&lt;/P&gt;</description>
      <pubDate>Tue, 24 May 2022 11:45:00 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/help-with-lisp-convert-diagonal-polyline-to-zig-zag-polyline/m-p/11189195#M45203</guid>
      <dc:creator>Kent1Cooper</dc:creator>
      <dc:date>2022-05-24T11:45:00Z</dc:date>
    </item>
    <item>
      <title>Re: Help with LISP - convert diagonal polyline to zig-zag polyline</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/help-with-lisp-convert-diagonal-polyline-to-zig-zag-polyline/m-p/11190025#M45204</link>
      <description>&lt;P&gt;Looks like it can be useful to convert complicated polyline to become orthogonal polyline. Thank you.&lt;/P&gt;</description>
      <pubDate>Tue, 24 May 2022 16:26:26 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/help-with-lisp-convert-diagonal-polyline-to-zig-zag-polyline/m-p/11190025#M45204</guid>
      <dc:creator>kwatanabeM7CVP</dc:creator>
      <dc:date>2022-05-24T16:26:26Z</dc:date>
    </item>
    <item>
      <title>Re: Help with LISP - convert diagonal polyline to zig-zag polyline</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/help-with-lisp-convert-diagonal-polyline-to-zig-zag-polyline/m-p/11190033#M45205</link>
      <description>&lt;P&gt;Thank you! - looks to be very efficient coding.&lt;/P&gt;</description>
      <pubDate>Tue, 24 May 2022 16:27:46 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/help-with-lisp-convert-diagonal-polyline-to-zig-zag-polyline/m-p/11190033#M45205</guid>
      <dc:creator>kwatanabeM7CVP</dc:creator>
      <dc:date>2022-05-24T16:27:46Z</dc:date>
    </item>
    <item>
      <title>Re: Help with LISP - convert diagonal polyline to zig-zag polyline</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/help-with-lisp-convert-diagonal-polyline-to-zig-zag-polyline/m-p/12316550#M45206</link>
      <description>&lt;P&gt;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/1779365"&gt;@ВeekeeCZ&lt;/a&gt;&amp;nbsp; this is perfect lisp for using in electrical drawing for draw a fire alarm loop. Is there a possibility to edit this script to draw only "L" shape, not the zigzag ? For simplicity, it would be enough if the first polyline always starts sideways (left or right) or, if possible, with the option to choose if sideways or up/down&lt;/P&gt;</description>
      <pubDate>Thu, 19 Oct 2023 10:11:52 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/help-with-lisp-convert-diagonal-polyline-to-zig-zag-polyline/m-p/12316550#M45206</guid>
      <dc:creator>Gobel_A</dc:creator>
      <dc:date>2023-10-19T10:11:52Z</dc:date>
    </item>
    <item>
      <title>Re: Help with LISP - convert diagonal polyline to zig-zag polyline</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/help-with-lisp-convert-diagonal-polyline-to-zig-zag-polyline/m-p/12316735#M45207</link>
      <description>&lt;P&gt;My routine actually CONVERTS lines to polylines. You say to want to DRAW a polyline... So what is it? Convert?&lt;/P&gt;</description>
      <pubDate>Thu, 19 Oct 2023 11:56:08 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/help-with-lisp-convert-diagonal-polyline-to-zig-zag-polyline/m-p/12316735#M45207</guid>
      <dc:creator>ВeekeeCZ</dc:creator>
      <dc:date>2023-10-19T11:56:08Z</dc:date>
    </item>
    <item>
      <title>Re: Help with LISP - convert diagonal polyline to zig-zag polyline</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/help-with-lisp-convert-diagonal-polyline-to-zig-zag-polyline/m-p/12316781#M45208</link>
      <description>&lt;P&gt;I meant the original purpose of this topic, i.e. to convert a diagonal polyline into an "ortho Z" but with modification to "ortho L".&lt;BR /&gt;I have a LISP that connects all selected blocks by the shortest path. The result is a continuous polyline connecting the blocks. If they are exactly side by side, it will connect them straight, if they are skewed in the X or Y axis, it will connect them diagonally with the shortest path. Your "ortoline" script nicely converts this diagonally connecting polyline with vertices in each block to an "ortho Z" shape. Perfectly. And my question was if there is a possibility to modify it to an "ortho L" shape with a choice of one of two possible interconnection options.&lt;/P&gt;</description>
      <pubDate>Thu, 19 Oct 2023 12:14:47 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/help-with-lisp-convert-diagonal-polyline-to-zig-zag-polyline/m-p/12316781#M45208</guid>
      <dc:creator>Gobel_A</dc:creator>
      <dc:date>2023-10-19T12:14:47Z</dc:date>
    </item>
    <item>
      <title>Re: Help with LISP - convert diagonal polyline to zig-zag polyline</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/help-with-lisp-convert-diagonal-polyline-to-zig-zag-polyline/m-p/12316844#M45209</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/3324185"&gt;@Gobel_A&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;.... "L" shape.... it would be enough if the first polyline always starts sideways (left or right) or, if possible, with the option to choose if sideways or up/down&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;That would be affected by the direction in which the source object is drawn.&amp;nbsp; If the dotted green is the original, with the arrow showing its drawn direction, then if you choose to &lt;EM&gt;start with the horizontal leg&lt;/EM&gt;, and that is from the start point of the source, you would get different white results:&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Kent1Cooper_0-1697718913689.png" style="width: 600px;"&gt;&lt;img src="https://forums.autodesk.com/t5/image/serverpage/image-id/1281202i4A1B9D90885F6E2A/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Kent1Cooper_0-1697718913689.png" alt="Kent1Cooper_0-1697718913689.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;Might you want to have the choice be in the starting direction from &lt;EM&gt;whichever end is lower&lt;/EM&gt;?&amp;nbsp; Or &lt;EM&gt;whichever end is farther to the left&lt;/EM&gt;?&amp;nbsp; Some other criterion?&lt;/P&gt;</description>
      <pubDate>Thu, 19 Oct 2023 12:37:23 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/help-with-lisp-convert-diagonal-polyline-to-zig-zag-polyline/m-p/12316844#M45209</guid>
      <dc:creator>Kent1Cooper</dc:creator>
      <dc:date>2023-10-19T12:37:23Z</dc:date>
    </item>
    <item>
      <title>Re: Help with LISP - convert diagonal polyline to zig-zag polyline</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/help-with-lisp-convert-diagonal-polyline-to-zig-zag-polyline/m-p/12316864#M45210</link>
      <description>&lt;P&gt;command 1: always start sideways (right/left) and then connect the second block up or down&lt;BR /&gt;command 2: always start up or down in the direction of the polyline and then connect the second block from the side&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Something similar to teh script on the link bellow,&amp;nbsp; but for the entire path of the original polyline. Something similar to the link, but the skript from the link connects according to its own logic and not the direction of the original polyline.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;A href="https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/connecting-blocks-with-polyline-help/m-p/8744287/highlight/true#M384115" target="_blank" rel="noopener"&gt;https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/connecting-blocks-with-polyline-help/m-p/8744287/highlight/true#M384115&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 19 Oct 2023 12:46:29 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/help-with-lisp-convert-diagonal-polyline-to-zig-zag-polyline/m-p/12316864#M45210</guid>
      <dc:creator>Gobel_A</dc:creator>
      <dc:date>2023-10-19T12:46:29Z</dc:date>
    </item>
    <item>
      <title>Re: Help with LISP - convert diagonal polyline to zig-zag polyline</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/help-with-lisp-convert-diagonal-polyline-to-zig-zag-polyline/m-p/12316992#M45211</link>
      <description>&lt;P&gt;Ok, simple edits... one version is HV, the second VH.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;(vl-load-com)

(defun c:OrtolineHV ( / s i e f d l p q o z px)
  
  (if (setq s (ssget "_:L" '((0 . "LWPOLYLINE,LINE"))))
    (repeat (setq i (sslength s))
      (and (setq e (ssname s (setq i (1- i))))
	   (setq d (entget e))
	   (setq l (mapcar 'cdr (if (= "LINE" (cdr (assoc 0 d)))
				  (list (assoc 10 d) (assoc 11 d))
				  (vl-remove-if '(lambda (x) (/= (car x) 10)) d))))
	   (setq f (vlax-ename-&amp;gt;vla-object e))
	   (setq z (apply 'append (mapcar '(lambda (x) (if (vlax-property-available-p f x)
							 (list (list x (vlax-get f x)))))
					  '("Color" "Layer" "LineType" "LinetypeScale" "Lineweight"))))
	   (setq l (apply 'append (mapcar '(lambda (p q) (list p
							       (list (car q) (cadr p))
							       q))
					  l (cdr l))))
	   (setq l (vl-remove 'nil (mapcar '(lambda (x) (if (not (equal x px 1e-6)) (setq px x))) l))) ; remove p if is same as previous one
	   (setq o (entmakex (append (list '(0 . "LWPOLYLINE") '(100 . "AcDbEntity") '(100 . "AcDbPolyline") (cons 90 (length l)) '(70 . 0))
				     (mapcar '(lambda (x) (cons 10 x)) l))))
	   (setq o (vlax-ename-&amp;gt;vla-object o))
	   (vlax-write-enabled-p o)
	   (mapcar '(lambda (x) (vl-catch-all-apply 'vlax-put (list o (car x) (cadr x)))) z)
	   (entdel e) ; remove this line to keep the originals
	   )))
  (princ)
  )


(defun c:OrtolineVH ( / s i e f d l p q o z px)
  
  (if (setq s (ssget "_:L" '((0 . "LWPOLYLINE,LINE"))))
    (repeat (setq i (sslength s))
      (and (setq e (ssname s (setq i (1- i))))
	   (setq d (entget e))
	   (setq l (mapcar 'cdr (if (= "LINE" (cdr (assoc 0 d)))
				  (list (assoc 10 d) (assoc 11 d))
				  (vl-remove-if '(lambda (x) (/= (car x) 10)) d))))
	   (setq f (vlax-ename-&amp;gt;vla-object e))
	   (setq z (apply 'append (mapcar '(lambda (x) (if (vlax-property-available-p f x)
							 (list (list x (vlax-get f x)))))
					  '("Color" "Layer" "LineType" "LinetypeScale" "Lineweight"))))
	   (setq l (apply 'append (mapcar '(lambda (p q) (list p
							       (list (car p) (cadr q))
							       q))
					  l (cdr l))))
	   (setq l (vl-remove 'nil (mapcar '(lambda (x) (if (not (equal x px 1e-6)) (setq px x))) l))) ; remove p if is same as previous one
	   (setq o (entmakex (append (list '(0 . "LWPOLYLINE") '(100 . "AcDbEntity") '(100 . "AcDbPolyline") (cons 90 (length l)) '(70 . 0))
				     (mapcar '(lambda (x) (cons 10 x)) l))))
	   (setq o (vlax-ename-&amp;gt;vla-object o))
	   (vlax-write-enabled-p o)
	   (mapcar '(lambda (x) (vl-catch-all-apply 'vlax-put (list o (car x) (cadr x)))) z)
	   (entdel e) ; remove this line to keep the originals
	   )))
  (princ)
  )
&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 19 Oct 2023 15:33:00 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/help-with-lisp-convert-diagonal-polyline-to-zig-zag-polyline/m-p/12316992#M45211</guid>
      <dc:creator>ВeekeeCZ</dc:creator>
      <dc:date>2023-10-19T15:33:00Z</dc:date>
    </item>
    <item>
      <title>Re: Help with LISP - convert diagonal polyline to zig-zag polyline</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/help-with-lisp-convert-diagonal-polyline-to-zig-zag-polyline/m-p/12318224#M45212</link>
      <description>&lt;P&gt;Regards&amp;nbsp;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/3324185"&gt;@Gobel_A&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;try this code, it gives you the option to choose, up or down.&lt;/P&gt;
&lt;LI-CODE lang="general"&gt;(defun c:PL_TB(/ p1 p2 p3 opc lst)
  (princ "\nSelect Start Block: ")
  (setq
    p1 (cdr
         (assoc 10 (entget (ssname (ssget "_+.:E:S" '((0 . "insert"))) 0)))  
       )
  )
  (while
    (princ "\nSelect Next Block/Right Click for End: ")
    (setq
      p2 (cdr
           (assoc 10 (entget (ssname (ssget "_+.:E:S" '((0 . "insert"))) 0)))
         )
    )
     (if (&amp;lt; (cadr p1) (cadr p2))
       (progn
         (setq pn1 p1
               pn2 p2
         )
       )
       (progn
         (setq pn1 p2
               pn2 p1
         )
       )
     )
    
     (initget "Tp Bt")
     (setq opc    (if
                    (setq opc (getkword "\n Select Top/Botton [Top / Botton]: &amp;lt;Tp&amp;gt;"))
                     opc
                     "Tp"
                  )
           *oopc* opc
     )
     (if (= opc "Tp")
       (setq p3t (list (car pn1) (cadr pn2) 0.)
       )
     )
     (if (= opc "Bt")
       (setq p3t (list (car pn2) (cadr pn1) 0.)
       )
     )
     (setq lst (list pn1 p3t pn2))
     (entmake (append (list
                        (cons 0 "lwpolyline")
                        (cons 100 "AcDbEntity")
                        (cons 100 "AcDbPolyline")
                        (cons 90 4)
                        (cons 70 0)
                      )
                      (mapcar '(lambda (x) (cons 10 x)) lst)
              )
     )
     (setq p1 p2)
  )
)&lt;/LI-CODE&gt;
&lt;P&gt;,&amp;nbsp;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 19 Oct 2023 23:15:20 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/help-with-lisp-convert-diagonal-polyline-to-zig-zag-polyline/m-p/12318224#M45212</guid>
      <dc:creator>calderg1000</dc:creator>
      <dc:date>2023-10-19T23:15:20Z</dc:date>
    </item>
    <item>
      <title>Re: Help with LISP - convert diagonal polyline to zig-zag polyline</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/help-with-lisp-convert-diagonal-polyline-to-zig-zag-polyline/m-p/12320615#M45213</link>
      <description>many thanks, this is something what i was asking for and gives more flexibility in choosing the "direction"</description>
      <pubDate>Fri, 20 Oct 2023 20:33:24 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/help-with-lisp-convert-diagonal-polyline-to-zig-zag-polyline/m-p/12320615#M45213</guid>
      <dc:creator>Gobel_A</dc:creator>
      <dc:date>2023-10-20T20:33:24Z</dc:date>
    </item>
  </channel>
</rss>

