<?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: cashing pipe [polygon] in Visual LISP, AutoLISP and General Customization Forum</title>
    <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/cashing-pipe-polygon/m-p/9915938#M66803</link>
    <description>&lt;P&gt;I hope this is it&lt;/P&gt;&lt;LI-CODE lang="general"&gt;(defun c:cov2pipe ( / e eo  a b c d pt n vlapt e1 e2 coords ptlist adoc take plusp width ext np)
; Select lwpolyline entity that is a centerline of pipe object
; and convert it to pipe
; hak_vz 04.12.2020
(defun take (amount lst / ret) (cond ((and (plusp amount) (and (&amp;gt; amount 0) (&amp;lt;= amount (length lst))) (listp lst))(repeat amount (setq ret (cons (car lst) (take (1- amount) (cdr lst))))))))
(defun plusp (num) (cond ((numberp num) (&amp;gt;= num 0.0))))
(setq adoc (vla-get-activedocument (vlax-get-acad-object))) 
(cond 
((and (setq e (car(entsel "\nSelect pipe &amp;gt;"))))
(vla-endundomark adoc)
(vla-startundomark adoc)
(setvar 'cmdecho 0)
(setq width (* 0.5 (getreal "\nPipe diameter &amp;gt;")))
(setq ext (getreal "\nPipe extension length &amp;gt;"))
(setq pd (* 0.5 (getreal "\nPoint diameter &amp;gt;")))
(setq np (- (cdr (assoc 90 (entget e))) 1))
(setq eo (vlax-ename-&amp;gt;vla-object e))
(setq coords (vlax-get eo 'Coordinates))
(setq ptlist (reverse ptlist))
(setq n (length coords))
(setq a (list (car coords)(cadr coords)))
(setq b (list (caddr coords)(cadddr coords)))
(setq c (list (nth (- n 4) coords)(nth (- n 3) coords)))
(setq d (list (nth (- n 2) coords)(last coords)))
(setq pt (polar a (angle b a) ext))
(setq vlapt (vlax-make-safearray vlax-vbdouble '(0 . 1)))
(vlax-safearray-fill vlapt pt)
(vla-put-Coordinate eo 0  vlapt)
(setq pt (polar d (angle c d) ext))
(setq vlapt (vlax-make-safearray vlax-vbdouble '(0 . 1)))
(vlax-safearray-fill vlapt pt)
(vla-put-Coordinate eo np  vlapt)
(vla-Offset eo width)
(setq e1 (entlast))
(vla-Offset eo (* -1 width))
(setq e2 (entlast))
(command "_.pedit" "m" e1 e2 "" "J" "J" "A" (* 4 width) "")
(entdel e)
(while coords (setq ptlist (cons (take 2 coords) ptlist) coords (cddr coords)))
(while ptlist (command "_.donut" 0 pd "_non" (car ptlist) "") (command "chprop" (entlast) "" "C" 1 "" )(setq ptlist (cdr ptlist)))
(setvar 'cmdecho 1)
(vla-endundomark adoc)
)
)
(princ)
)&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-center" image-alt="Untitled.png" style="width: 400px;"&gt;&lt;img src="https://forums.autodesk.com/t5/image/serverpage/image-id/852263i03F09654B8065DB2/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Untitled.png" alt="Untitled.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Fri, 04 Dec 2020 17:33:08 GMT</pubDate>
    <dc:creator>hak_vz</dc:creator>
    <dc:date>2020-12-04T17:33:08Z</dc:date>
    <item>
      <title>cashing pipe [polygon]</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/cashing-pipe-polygon/m-p/9914667#M66795</link>
      <description>&lt;P&gt;Good day.&lt;/P&gt;&lt;P&gt;I am very grateful for any help.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I was faced with another tedious task that I have to do for several projects on our team.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Can you support me with the code that the "casing pipe" will draw? In the attached sketch "cashing_pipe" the yellow dashed line is this item. Ultimately, the element may be a polygon, as in the example "cashing_pipe_collapse".&lt;BR /&gt;Using a multiline might be one solution, but I'd like to explore other possibilities.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Problem: Draw a 1m wide polygon from to an indicated point.&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;Best regards and thank you for your help and directions to solve the problem.&lt;/P&gt;&lt;P&gt;Thanks for any help.&lt;/P&gt;</description>
      <pubDate>Fri, 04 Dec 2020 07:53:42 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/cashing-pipe-polygon/m-p/9914667#M66795</guid>
      <dc:creator>JN05</dc:creator>
      <dc:date>2020-12-04T07:53:42Z</dc:date>
    </item>
    <item>
      <title>Re: cashing pipe [polygon]</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/cashing-pipe-polygon/m-p/9915113#M66796</link>
      <description>&lt;P&gt;Try this&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="general"&gt;(defun c:cov2pipe ( / e eo coords a b c d pt vlapt e1 e2)
; Select lwpolyline entity that is a centerline of pipe object
; and convert it to pipe
; hak_vz 04.12.2020
(cond 
((and (setq e (car(entsel "\nSelect pipe &amp;gt;"))))
(setq np (- (cdr (assoc 90 (entget e))) 1))
(setq eo (vlax-ename-&amp;gt;vla-object e))
(setq coords (vlax-get eo 'Coordinates))
(setq n (length coords))
(setq a (list (car coords)(cadr coords)))
(setq b (list (caddr coords)(cadddr coords)))
(setq c (list (nth (- n 4) coords)(nth (- n 3) coords)))
(setq d (list (nth (- n 2) coords)(last coords)))
(setq pt (polar a (angle b a) 0.5))
(setq vlapt (vlax-make-safearray vlax-vbdouble '(0 . 1)))
(vlax-safearray-fill vlapt pt)
(vla-put-Coordinate eo 0  vlapt)
(setq pt (polar d (angle c d) 0.5))
(setq vlapt (vlax-make-safearray vlax-vbdouble '(0 . 1)))
(vlax-safearray-fill vlapt pt)
(vla-put-Coordinate eo np  vlapt)
(vla-Offset eo 0.5)
(setq e1 (entlast))
(vla-Offset eo -0.5)
(setq e2 (entlast))
(setvar 'cmdecho 0)
(command "_.pedit" "m" e1 e2 "" "J" 50)
(setvar 'cmdecho 1)
(entdel e) ; put a comment infront this line if you want to retain centerline 
)
)
(princ)
)&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Create a lwpolyline that represents a centerline of polyline i.e. connect points 1 to n, then use cov2pipe to convert&lt;/P&gt;&lt;P&gt;to shape you want. Place it to layer wit predefined linetype and that's it.&amp;nbsp; At the end select all object in that layer and&lt;/P&gt;&lt;P&gt;select option "enable linetype generation".&lt;/P&gt;</description>
      <pubDate>Fri, 04 Dec 2020 12:17:34 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/cashing-pipe-polygon/m-p/9915113#M66796</guid>
      <dc:creator>hak_vz</dc:creator>
      <dc:date>2020-12-04T12:17:34Z</dc:date>
    </item>
    <item>
      <title>Re: cashing pipe [polygon]</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/cashing-pipe-polygon/m-p/9915219#M66797</link>
      <description>&lt;P&gt;Thanks for the tip. cov2pipe works fine. However, there is an additional step to be performed. You need to delete the polyline on which the pipes are drawn. Additionally, the tips (yellow) do not close. It would be most convenient to indicate points (dots) marked in red.&lt;/P&gt;&lt;P&gt;Beloved, look, maybe it is possible to modify the &lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/5530556"&gt;@hak_vz&lt;/a&gt; code so that there is no line in the middle and it is closed.&lt;/P&gt;&lt;P&gt;Thank you very much for all your help.&lt;/P&gt;</description>
      <pubDate>Fri, 04 Dec 2020 13:07:56 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/cashing-pipe-polygon/m-p/9915219#M66797</guid>
      <dc:creator>JN05</dc:creator>
      <dc:date>2020-12-04T13:07:56Z</dc:date>
    </item>
    <item>
      <title>Re: cashing pipe [polygon]</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/cashing-pipe-polygon/m-p/9915239#M66798</link>
      <description>&lt;P&gt;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/3704272"&gt;@JN05&lt;/a&gt;Attach sample drawing so I can test it.&amp;nbsp; I will add a code to create donuts at point location.&lt;/P&gt;</description>
      <pubDate>Fri, 04 Dec 2020 13:17:25 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/cashing-pipe-polygon/m-p/9915239#M66798</guid>
      <dc:creator>hak_vz</dc:creator>
      <dc:date>2020-12-04T13:17:25Z</dc:date>
    </item>
    <item>
      <title>Re: cashing pipe [polygon]</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/cashing-pipe-polygon/m-p/9915267#M66799</link>
      <description>&lt;P&gt;Here, try this... You must specify linetype and linetype scale prior running routine...&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;(defun c:extopenlinearpolygon ( / *error* LM:PolyOutline unit plw plg lw lwx lp lpx sp ssp ep eep pl spl epl spln epln )

  (defun *error* ( m )
    (if plw
      (setvar 'plinewid plw)
    )
    (if plg
      (setvar 'plinegen plg)
    )
    (if m
      (prompt m)
    )
    (princ)
  )

  ;;------------------=={ LWPolyline Outline }==----------------;;
  ;;                                                            ;;
  ;;  Creates an LWPolyline surrounding the boundary of an      ;;
  ;;  LWPolyline with varying widths. Currently restricted to   ;;
  ;;  LWPolyline vertices with zero bulge.                      ;;
  ;;------------------------------------------------------------;;
  ;;  Author: Lee Mac, Copyright   2011 - www.lee-mac.com       ;;
  ;;------------------------------------------------------------;;
  ;;  Arguments:                                                ;;
  ;;  ent - Entity name of LWPolyline                           ;;
  ;;------------------------------------------------------------;;
  ;;  Returns:  List of Entity name(s) of outline LWPolyline(s) ;;
  ;;------------------------------------------------------------;;

  (defun LM:PolyOutline ( ent / _vertices lst )

    (defun _vertices ( e )
      (if (setq e (member (assoc 10 e) e))
        (cons
          (list
            (cdr (assoc 10 e))
            (cdr (assoc 40 e))
            (cdr (assoc 41 e))
          )
          (_vertices (cdr e))
        )
      )
    )

    (setq
      ent (entget ent)
      lst (_vertices ent)
      lst (apply 'mapcar
            (cons
              (function
                (lambda ( a b )
                  (
                    (lambda ( c )
                      (mapcar
                        (function
                          (lambda ( d )
                            (mapcar
                              (function
                                (lambda ( e f )
                                  (mapcar 'd (car e)
                                    (mapcar
                                      (function
                                        (lambda ( g ) (* g (/ f 2.0)))
                                      )
                                      c
                                    )
                                  )
                                )
                              )
                              (list a b) (cdr a)
                            )
                          )
                        )
                        (list + -)
                      )
                    )
                    (
                      (lambda ( v / n )
                        (setq v (list (- (cadr v)) (car v) 0.0)
                              n (distance '(0. 0.) v)
                        )
                        (if (equal 0.0 n 1e-14)
                          (list  0.0 0.0 0.0)
                          (mapcar '/ v (list n n n))
                        )
                      )
                      (mapcar '- (car a) (car b))
                    )
                  )
                )
              )
              (if (= 1 (logand 1 (cdr (assoc 70 ent))))
                (list
                  (cons (last lst) lst)
                  (append lst (list (car lst)))
                )
                (list lst (cdr lst))
              )
            )
          )
      lst (
            (lambda ( a )
              (if (zerop (logand 1 (cdr (assoc 70 ent))))
                (append
                  (list (mapcar 'car  (car  lst)))
                  a
                  (list (mapcar 'cadr (last lst)))
                )
                a
              )
            )
            (apply 'append
              (mapcar
                (function
                  (lambda ( a b / c )
                    (if
                      (setq c
                        (apply 'append
                          (mapcar
                            (function
                              (lambda ( d e / f )
                                (if (setq f (inters (car d) (cadr d) (car e) (cadr e) nil))
                                  (list f)
                                )
                              )
                            )
                            a b
                          )
                        )
                      )
                      (list c)
                    )
                  )
                )
                lst (cdr lst)
              )
            )
          )
    )
    (mapcar
      (function
        (lambda ( a )
          (entmakex
            (append
              (subst (cons 43 0.0) (assoc 43 ent)
                (subst (cons 70 (logior 1 (cdr (assoc 70 ent)))) (assoc 70 ent)
                  (subst (cons 90 (length a)) (assoc 90 ent)
                    (reverse (member (assoc 39 ent) (reverse ent)))
                  )
                )
              )
              (mapcar '(lambda ( p ) (cons 10 p)) a) (list (assoc 210 ent))
            )
          )
        )
      )
      (
        (lambda ( a b )
          (if (zerop (logand 1 (cdr (assoc 70 ent))))
            (list
              (append
                (if (equal (car a) (last b) 1e-8)
                  (setq a (cdr a))
                  a
                )
                (if (equal (car b) (last a) 1e-8)
                  (setq b (cdr b))
                  b
                )
              )
            )
            (list a b)
          )
        )
        (mapcar 'car lst) (reverse (mapcar 'cadr lst))
      )
    )
  )

  (defun unit ( v / d )
    (if (not (equal (setq d (distance '(0.0 0.0 0.0) v)) 0.0 1e-8))
      (mapcar '(lambda ( x ) (/ x d)) v)
    )
  )

  (if (null w)
    (setq w 1.0)
  )
  (initget 6)
  (setq w (cond ( (getdist (strcat "\nPick or specify width of linear polygon &amp;lt;" (rtos w) "&amp;gt; : ")) ) ( w )))
  (if (null d)
    (setq d 0.5)
  )
  (initget 6)
  (setq d (cond ( (getdist (strcat "\nPick or specify extension of linear polygon &amp;lt;" (rtos d) "&amp;gt; : ")) ) ( d )))
  (setq plw (getvar 'plinewid))
  (setvar 'plinewid w)
  (setq plg (getvar 'plinegen))
  (setvar 'plinegen 1)
  (prompt "\nPick or specify starting point : ")
  (vl-cmdf "_.PLINE")
  (while (&amp;lt; 0 (getvar 'cmdactive))
    (vl-cmdf "\\")
  )
  (setq lw (entlast))
  (setq lp (car (LM:PolyOutline lw)))
  (setq sp (cdr (assoc 10 (setq lwx (entget lw)))))
  (setq ssp (cdr (assoc 10 (cdr (member (assoc 10 lwx) lwx)))))
  (setq ep (cdr (assoc 10 (reverse lwx))))
  (setq eep (cdr (assoc 10 (cdr (member (assoc 10 (reverse lwx)) (reverse lwx))))))
  (setq pl (mapcar 'cdr (vl-remove-if '(lambda ( x ) (/= (car x) 10)) (setq lpx (entget lp)))))
  (setq spl (vl-sort pl '(lambda ( a b ) (&amp;lt; (distance a sp) (distance b sp)))))
  (setq spl (list (car spl) (cadr spl)))
  (setq epl (vl-sort pl '(lambda ( a b ) (&amp;lt; (distance a ep) (distance b ep)))))
  (setq epl (list (car epl) (cadr epl)))
  (setq spln (mapcar '(lambda ( x ) (mapcar '+ x (mapcar '* (unit (mapcar '- sp ssp)) (list d d d)))) spl))
  (setq epln (mapcar '(lambda ( x ) (mapcar '+ x (mapcar '* (unit (mapcar '- ep eep)) (list d d d)))) epl))
  (setq lpx (subst (cons 10 (car spln)) (cons 10 (car spl)) lpx))
  (setq lpx (subst (cons 10 (cadr spln)) (cons 10 (cadr spl)) lpx))
  (setq lpx (subst (cons 10 (car epln)) (cons 10 (car epl)) lpx))
  (setq lpx (subst (cons 10 (cadr epln)) (cons 10 (cadr epl)) lpx))
  (entupd (cdr (assoc -1 (entmod lpx))))
  (entdel lw)
  (*error* nil)
)&lt;/PRE&gt;</description>
      <pubDate>Fri, 04 Dec 2020 13:27:28 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/cashing-pipe-polygon/m-p/9915267#M66799</guid>
      <dc:creator>marko_ribar</dc:creator>
      <dc:date>2020-12-04T13:27:28Z</dc:date>
    </item>
    <item>
      <title>Re: cashing pipe [polygon]</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/cashing-pipe-polygon/m-p/9915382#M66800</link>
      <description>&lt;LI-CODE lang="general"&gt;(defun c:cov2pipe ( / e eo coords a b c d pt vlapt e1 e2)
; Select lwpolyline entity that is a centerline of pipe object
; and convert it to pipe
; hak_vz 04.12.2020
(cond 
((and (setq e (car(entsel "\nSelect pipe &amp;gt;"))))
(setq np (- (cdr (assoc 90 (entget e))) 1))
(setq eo (vlax-ename-&amp;gt;vla-object e))
(setq coords (vlax-get eo 'Coordinates))
(setq n (length coords))
(setq a (list (car coords)(cadr coords)))
(setq b (list (caddr coords)(cadddr coords)))
(setq c (list (nth (- n 4) coords)(nth (- n 3) coords)))
(setq d (list (nth (- n 2) coords)(last coords)))
(setq pt (polar a (angle b a) 0.5))
(setq vlapt (vlax-make-safearray vlax-vbdouble '(0 . 1)))
(vlax-safearray-fill vlapt pt)
(vla-put-Coordinate eo 0  vlapt)
(setq pt (polar d (angle c d) 0.5))
(setq vlapt (vlax-make-safearray vlax-vbdouble '(0 . 1)))
(vlax-safearray-fill vlapt pt)
(vla-put-Coordinate eo np  vlapt)
(vla-Offset eo 0.5)
(setq e1 (entlast))
(vla-Offset eo -0.5)
(setq e2 (entlast))
(setvar 'cmdecho 0)
(command "_.pedit" "m" e1 e2 "" "J" "J" "A" 50 "")
(setvar 'cmdecho 1)
(entdel e)
)
)
(princ)
)&lt;/LI-CODE&gt;</description>
      <pubDate>Fri, 04 Dec 2020 14:06:14 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/cashing-pipe-polygon/m-p/9915382#M66800</guid>
      <dc:creator>hak_vz</dc:creator>
      <dc:date>2020-12-04T14:06:14Z</dc:date>
    </item>
    <item>
      <title>Re: cashing pipe [polygon]</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/cashing-pipe-polygon/m-p/9915462#M66801</link>
      <description>&lt;P&gt;Now I coded when in routine, CAD don't add linetype to previewing drawing polyline - only to add linetype to finished resulting outlinear polygonal lwpolyline... If you are satisfied, you can reply (I don't quite know how to make it better...)...&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;(defun c:extopenlinearpolygon ( / *error* LM:PolyOutline unit plw plg clt lw lwx lp lpx sp ssp ep eep pl spl epl spln epln )

  (defun *error* ( m )
    (if plw
      (setvar 'plinewid plw)
    )
    (if plg
      (setvar 'plinegen plg)
    )
    (if clt
      (setvar 'celtype clt)
    )
    (if m
      (prompt m)
    )
    (princ)
  )

  ;;------------------=={ LWPolyline Outline }==----------------;;
  ;;                                                            ;;
  ;;  Creates an LWPolyline surrounding the boundary of an      ;;
  ;;  LWPolyline with varying widths. Currently restricted to   ;;
  ;;  LWPolyline vertices with zero bulge.                      ;;
  ;;------------------------------------------------------------;;
  ;;  Author: Lee Mac, Copyright   2011 - www.lee-mac.com       ;;
  ;;------------------------------------------------------------;;
  ;;  Arguments:                                                ;;
  ;;  ent - Entity name of LWPolyline                           ;;
  ;;------------------------------------------------------------;;
  ;;  Returns:  List of Entity name(s) of outline LWPolyline(s) ;;
  ;;------------------------------------------------------------;;

  (defun LM:PolyOutline ( ent / _vertices lst )

    (defun _vertices ( e )
      (if (setq e (member (assoc 10 e) e))
        (cons
          (list
            (cdr (assoc 10 e))
            (cdr (assoc 40 e))
            (cdr (assoc 41 e))
          )
          (_vertices (cdr e))
        )
      )
    )

    (setq
      ent (entget ent)
      lst (_vertices ent)
      lst (apply 'mapcar
            (cons
              (function
                (lambda ( a b )
                  (
                    (lambda ( c )
                      (mapcar
                        (function
                          (lambda ( d )
                            (mapcar
                              (function
                                (lambda ( e f )
                                  (mapcar 'd (car e)
                                    (mapcar
                                      (function
                                        (lambda ( g ) (* g (/ f 2.0)))
                                      )
                                      c
                                    )
                                  )
                                )
                              )
                              (list a b) (cdr a)
                            )
                          )
                        )
                        (list + -)
                      )
                    )
                    (
                      (lambda ( v / n )
                        (setq v (list (- (cadr v)) (car v) 0.0)
                              n (distance '(0. 0.) v)
                        )
                        (if (equal 0.0 n 1e-14)
                          (list  0.0 0.0 0.0)
                          (mapcar '/ v (list n n n))
                        )
                      )
                      (mapcar '- (car a) (car b))
                    )
                  )
                )
              )
              (if (= 1 (logand 1 (cdr (assoc 70 ent))))
                (list
                  (cons (last lst) lst)
                  (append lst (list (car lst)))
                )
                (list lst (cdr lst))
              )
            )
          )
      lst (
            (lambda ( a )
              (if (zerop (logand 1 (cdr (assoc 70 ent))))
                (append
                  (list (mapcar 'car  (car  lst)))
                  a
                  (list (mapcar 'cadr (last lst)))
                )
                a
              )
            )
            (apply 'append
              (mapcar
                (function
                  (lambda ( a b / c )
                    (if
                      (setq c
                        (apply 'append
                          (mapcar
                            (function
                              (lambda ( d e / f )
                                (if (setq f (inters (car d) (cadr d) (car e) (cadr e) nil))
                                  (list f)
                                )
                              )
                            )
                            a b
                          )
                        )
                      )
                      (list c)
                    )
                  )
                )
                lst (cdr lst)
              )
            )
          )
    )
    (mapcar
      (function
        (lambda ( a )
          (entmakex
            (append
              (subst (cons 43 0.0) (assoc 43 ent)
                (subst (cons 70 (logior 1 (cdr (assoc 70 ent)))) (assoc 70 ent)
                  (subst (cons 90 (length a)) (assoc 90 ent)
                    (reverse (member (assoc 39 ent) (reverse ent)))
                  )
                )
              )
              (mapcar '(lambda ( p ) (cons 10 p)) a) (list (assoc 210 ent))
            )
          )
        )
      )
      (
        (lambda ( a b )
          (if (zerop (logand 1 (cdr (assoc 70 ent))))
            (list
              (append
                (if (equal (car a) (last b) 1e-8)
                  (setq a (cdr a))
                  a
                )
                (if (equal (car b) (last a) 1e-8)
                  (setq b (cdr b))
                  b
                )
              )
            )
            (list a b)
          )
        )
        (mapcar 'car lst) (reverse (mapcar 'cadr lst))
      )
    )
  )

  (defun unit ( v / d )
    (if (not (equal (setq d (distance '(0.0 0.0 0.0) v)) 0.0 1e-8))
      (mapcar '(lambda ( x ) (/ x d)) v)
    )
  )

  (if (null w)
    (setq w 1.0)
  )
  (initget 6)
  (setq w (cond ( (getdist (strcat "\nPick or specify width of linear polygon &amp;lt;" (rtos w) "&amp;gt; : ")) ) ( w )))
  (if (null d)
    (setq d 0.5)
  )
  (initget 6)
  (setq d (cond ( (getdist (strcat "\nPick or specify extension of linear polygon &amp;lt;" (rtos d) "&amp;gt; : ")) ) ( d )))
  (setq plw (getvar 'plinewid))
  (setvar 'plinewid w)
  (setq plg (getvar 'plinegen))
  (setvar 'plinegen 0)
  (setq clt (getvar 'celtype))
  (setvar 'celtype "Continuous")
  (prompt "\nPick or specify starting point : ")
  (vl-cmdf "_.PLINE")
  (while (&amp;lt; 0 (getvar 'cmdactive))
    (vl-cmdf "\\")
  )
  (setq lw (entlast))
  (setq lp (car (LM:PolyOutline lw)))
  (setq sp (cdr (assoc 10 (setq lwx (entget lw)))))
  (setq ssp (cdr (assoc 10 (cdr (member (assoc 10 lwx) lwx)))))
  (setq ep (cdr (assoc 10 (reverse lwx))))
  (setq eep (cdr (assoc 10 (cdr (member (assoc 10 (reverse lwx)) (reverse lwx))))))
  (setq pl (mapcar 'cdr (vl-remove-if '(lambda ( x ) (/= (car x) 10)) (setq lpx (entget lp)))))
  (setq spl (vl-sort pl '(lambda ( a b ) (&amp;lt; (distance a sp) (distance b sp)))))
  (setq spl (list (car spl) (cadr spl)))
  (setq epl (vl-sort pl '(lambda ( a b ) (&amp;lt; (distance a ep) (distance b ep)))))
  (setq epl (list (car epl) (cadr epl)))
  (setq spln (mapcar '(lambda ( x ) (mapcar '+ x (mapcar '* (unit (mapcar '- sp ssp)) (list d d d)))) spl))
  (setq epln (mapcar '(lambda ( x ) (mapcar '+ x (mapcar '* (unit (mapcar '- ep eep)) (list d d d)))) epl))
  (setq lpx (subst (cons 10 (car spln)) (cons 10 (car spl)) lpx))
  (setq lpx (subst (cons 10 (cadr spln)) (cons 10 (cadr spl)) lpx))
  (setq lpx (subst (cons 10 (car epln)) (cons 10 (car epl)) lpx))
  (setq lpx (subst (cons 10 (cadr epln)) (cons 10 (cadr epl)) lpx))
  (setq lpx (subst (cons 70 (+ 128 (cdr (assoc 70 lpx)))) (assoc 70 lpx) lpx))
  (setq lpx (subst (cons 6 clt) (assoc 6 lpx) lpx))
  (entupd (cdr (assoc -1 (entmod lpx))))
  (entdel lw)
  (*error* nil)
)&lt;/PRE&gt;</description>
      <pubDate>Fri, 04 Dec 2020 14:36:14 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/cashing-pipe-polygon/m-p/9915462#M66801</guid>
      <dc:creator>marko_ribar</dc:creator>
      <dc:date>2020-12-04T14:36:14Z</dc:date>
    </item>
    <item>
      <title>Re: cashing pipe [polygon]</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/cashing-pipe-polygon/m-p/9915925#M66802</link>
      <description>&lt;P&gt;ep&lt;/P&gt;</description>
      <pubDate>Fri, 04 Dec 2020 17:30:21 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/cashing-pipe-polygon/m-p/9915925#M66802</guid>
      <dc:creator>hak_vz</dc:creator>
      <dc:date>2020-12-04T17:30:21Z</dc:date>
    </item>
    <item>
      <title>Re: cashing pipe [polygon]</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/cashing-pipe-polygon/m-p/9915938#M66803</link>
      <description>&lt;P&gt;I hope this is it&lt;/P&gt;&lt;LI-CODE lang="general"&gt;(defun c:cov2pipe ( / e eo  a b c d pt n vlapt e1 e2 coords ptlist adoc take plusp width ext np)
; Select lwpolyline entity that is a centerline of pipe object
; and convert it to pipe
; hak_vz 04.12.2020
(defun take (amount lst / ret) (cond ((and (plusp amount) (and (&amp;gt; amount 0) (&amp;lt;= amount (length lst))) (listp lst))(repeat amount (setq ret (cons (car lst) (take (1- amount) (cdr lst))))))))
(defun plusp (num) (cond ((numberp num) (&amp;gt;= num 0.0))))
(setq adoc (vla-get-activedocument (vlax-get-acad-object))) 
(cond 
((and (setq e (car(entsel "\nSelect pipe &amp;gt;"))))
(vla-endundomark adoc)
(vla-startundomark adoc)
(setvar 'cmdecho 0)
(setq width (* 0.5 (getreal "\nPipe diameter &amp;gt;")))
(setq ext (getreal "\nPipe extension length &amp;gt;"))
(setq pd (* 0.5 (getreal "\nPoint diameter &amp;gt;")))
(setq np (- (cdr (assoc 90 (entget e))) 1))
(setq eo (vlax-ename-&amp;gt;vla-object e))
(setq coords (vlax-get eo 'Coordinates))
(setq ptlist (reverse ptlist))
(setq n (length coords))
(setq a (list (car coords)(cadr coords)))
(setq b (list (caddr coords)(cadddr coords)))
(setq c (list (nth (- n 4) coords)(nth (- n 3) coords)))
(setq d (list (nth (- n 2) coords)(last coords)))
(setq pt (polar a (angle b a) ext))
(setq vlapt (vlax-make-safearray vlax-vbdouble '(0 . 1)))
(vlax-safearray-fill vlapt pt)
(vla-put-Coordinate eo 0  vlapt)
(setq pt (polar d (angle c d) ext))
(setq vlapt (vlax-make-safearray vlax-vbdouble '(0 . 1)))
(vlax-safearray-fill vlapt pt)
(vla-put-Coordinate eo np  vlapt)
(vla-Offset eo width)
(setq e1 (entlast))
(vla-Offset eo (* -1 width))
(setq e2 (entlast))
(command "_.pedit" "m" e1 e2 "" "J" "J" "A" (* 4 width) "")
(entdel e)
(while coords (setq ptlist (cons (take 2 coords) ptlist) coords (cddr coords)))
(while ptlist (command "_.donut" 0 pd "_non" (car ptlist) "") (command "chprop" (entlast) "" "C" 1 "" )(setq ptlist (cdr ptlist)))
(setvar 'cmdecho 1)
(vla-endundomark adoc)
)
)
(princ)
)&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-center" image-alt="Untitled.png" style="width: 400px;"&gt;&lt;img src="https://forums.autodesk.com/t5/image/serverpage/image-id/852263i03F09654B8065DB2/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Untitled.png" alt="Untitled.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 04 Dec 2020 17:33:08 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/cashing-pipe-polygon/m-p/9915938#M66803</guid>
      <dc:creator>hak_vz</dc:creator>
      <dc:date>2020-12-04T17:33:08Z</dc:date>
    </item>
    <item>
      <title>Re: cashing pipe [polygon]</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/cashing-pipe-polygon/m-p/9916062#M66804</link>
      <description>&lt;P&gt;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/5530556"&gt;@hak_vz&lt;/a&gt;&amp;nbsp;Thank you for your time. I test, but it does not work out like in your screenshot. There are still no line endings and the centerline does not disappear.&lt;BR /&gt;I mean, you just type&amp;gt; pipe diameter 1 and the lisp does the same for me as yours. It doesn't work for me. Take a look ...&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Polecenie: COV2PIPE&lt;/P&gt;&lt;P&gt;Select pipe &amp;gt;&lt;BR /&gt;Pipe diameter &amp;gt;1&lt;/P&gt;&lt;P&gt;Pipe extension length &amp;gt;1&lt;/P&gt;&lt;P&gt;Point diameter &amp;gt;1&lt;/P&gt;</description>
      <pubDate>Fri, 04 Dec 2020 18:07:10 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/cashing-pipe-polygon/m-p/9916062#M66804</guid>
      <dc:creator>JN05</dc:creator>
      <dc:date>2020-12-04T18:07:10Z</dc:date>
    </item>
    <item>
      <title>Re: cashing pipe [polygon]</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/cashing-pipe-polygon/m-p/9916109#M66805</link>
      <description>&lt;P&gt;please add sample drawing.&lt;/P&gt;&lt;P&gt;which version of acad you use. In acad 2018 everything works ok&lt;/P&gt;</description>
      <pubDate>Fri, 04 Dec 2020 18:20:39 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/cashing-pipe-polygon/m-p/9916109#M66805</guid>
      <dc:creator>hak_vz</dc:creator>
      <dc:date>2020-12-04T18:20:39Z</dc:date>
    </item>
    <item>
      <title>Re: cashing pipe [polygon]</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/cashing-pipe-polygon/m-p/9916185#M66806</link>
      <description>&lt;P&gt;Eventually try this. In your screenshot UCS was not set to World&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:cov2pipe ( / e eo  a b c d pt n vlapt e1 e2 coords ptlist adoc take plusp width ext np)
; Select lwpolyline entity that is a centerline of pipe object
; and convert it to pipe
; hak_vz 04.12.2020
(defun take (amount lst / ret) (cond ((and (plusp amount) (and (&amp;gt; amount 0) (&amp;lt;= amount (length lst))) (listp lst))(repeat amount (setq ret (cons (car lst) (take (1- amount) (cdr lst))))))))
(defun plusp (num) (cond ((numberp num) (&amp;gt;= num 0.0))))
(setq adoc (vla-get-activedocument (vlax-get-acad-object))) 
(cond 
((and (setq e (car(entsel "\nSelect pipe &amp;gt;"))))
(vla-endundomark adoc)
(vla-startundomark adoc)

(setvar 'cmdecho 0)
(command "_.UCS" "W")
(setq width (* 0.5 (getreal "\nPipe diameter &amp;gt;")))
(setq ext (getreal "\nPipe extension length &amp;gt;"))
(setq pd (* 0.5 (getreal "\nPoint diameter &amp;gt;")))
(setq np (- (cdr (assoc 90 (entget e))) 1))
(setq eo (vlax-ename-&amp;gt;vla-object e))
(setq coords (vlax-get eo 'Coordinates))
(setq ptlist (reverse ptlist))
(setq n (length coords))
(setq a (list (car coords)(cadr coords)))
(setq b (list (caddr coords)(cadddr coords)))
(setq c (list (nth (- n 4) coords)(nth (- n 3) coords)))
(setq d (list (nth (- n 2) coords)(last coords)))
(setq pt (polar a (angle b a) ext))
(setq vlapt (vlax-make-safearray vlax-vbdouble '(0 . 1)))
(vlax-safearray-fill vlapt pt)
(vla-put-Coordinate eo 0  vlapt)
(setq pt (polar d (angle c d) ext))
(setq vlapt (vlax-make-safearray vlax-vbdouble '(0 . 1)))
(vlax-safearray-fill vlapt pt)
(vla-put-Coordinate eo np  vlapt)
(vla-Offset eo width)
(setq e1 (entlast))
(vla-Offset eo (* -1 width))
(setq e2 (entlast))
(initcommandversion) 
(command "_.pedit" "m" e1 e2 "" "J" "J" "A" (* 4 width) "")
(entdel e)
(while coords (setq ptlist (cons (take 2 coords) ptlist) coords (cddr coords)))
(while ptlist (command "_.donut" 0 pd "_non" (car ptlist) "") (initcommandversion) (command "chprop" (entlast) "" "C" 1 "" )(setq ptlist (cdr ptlist)))
(command "_.UCS" "P")
(setvar 'cmdecho 1)
(vla-endundomark adoc)
)
)
(princ)
)&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 04 Dec 2020 18:58:48 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/cashing-pipe-polygon/m-p/9916185#M66806</guid>
      <dc:creator>hak_vz</dc:creator>
      <dc:date>2020-12-04T18:58:48Z</dc:date>
    </item>
    <item>
      <title>Re: cashing pipe [polygon]</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/cashing-pipe-polygon/m-p/9916191#M66807</link>
      <description>&lt;P&gt;You may be able to use&amp;nbsp;&lt;FONT color="#000000"&gt;&lt;STRONG&gt;OffsetBothSidesClose.lsp&lt;/STRONG&gt;&lt;/FONT&gt;&lt;SPAN&gt;&amp;nbsp;with its&amp;nbsp;&lt;/SPAN&gt;&lt;STRONG&gt;&lt;FONT color="#000000"&gt;OBSC&lt;/FONT&gt;&lt;/STRONG&gt;&lt;SPAN&gt;&amp;nbsp;command,&lt;/SPAN&gt; &lt;A href="https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/offset-both-sides-and-close/m-p/9443496/highlight/true#M398535" target="_blank" rel="noopener"&gt;&amp;gt;here&amp;lt;&lt;/A&gt;.&lt;/P&gt;</description>
      <pubDate>Fri, 04 Dec 2020 18:58:34 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/cashing-pipe-polygon/m-p/9916191#M66807</guid>
      <dc:creator>Kent1Cooper</dc:creator>
      <dc:date>2020-12-04T18:58:34Z</dc:date>
    </item>
    <item>
      <title>Re: cashing pipe [polygon]</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/cashing-pipe-polygon/m-p/9917642#M66808</link>
      <description>&lt;P&gt;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/5530556"&gt;@hak_vz&lt;/a&gt;&amp;nbsp;thank you for your time. It's better now. The lines are drawing. They don't just close at the ends. Will you see why this is happening? Help please.&lt;BR /&gt;Best regards.&lt;/P&gt;</description>
      <pubDate>Sat, 05 Dec 2020 14:53:34 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/cashing-pipe-polygon/m-p/9917642#M66808</guid>
      <dc:creator>JN05</dc:creator>
      <dc:date>2020-12-05T14:53:34Z</dc:date>
    </item>
    <item>
      <title>Re: cashing pipe [polygon]</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/cashing-pipe-polygon/m-p/9917664#M66809</link>
      <description>&lt;P&gt;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/3704272"&gt;@JN05&lt;/a&gt;&lt;/P&gt;&lt;P&gt;Is your drawing lines in yellow on picture?&lt;/P&gt;&lt;P&gt;If yes, then I suggest that check routine for calculating additional points - maybe you turned OSNAP on and CAD therefore can't aquire correct locations... If you though also set linetype and linetype scale to unappropriate values, you may get dashes and closing line as smaller may be invisible (gap between dashes)... I don't know why are you ignoring my postings... It should work well for your cases (linear paths)... Also note that your drawn paths shouldn't self intersect as this will bring errors with (vla-offset) - curves breaks into 2 or more solutions... Please, do check my versions... If you want no extensions, just change (initget 6) to (initget 4) and line : (if (null d) (setq d 0.0)) at the beggining of code...&lt;/P&gt;&lt;P&gt;Regards, M.R.&lt;/P&gt;</description>
      <pubDate>Sat, 05 Dec 2020 15:07:30 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/cashing-pipe-polygon/m-p/9917664#M66809</guid>
      <dc:creator>marko_ribar</dc:creator>
      <dc:date>2020-12-05T15:07:30Z</dc:date>
    </item>
    <item>
      <title>Re: cashing pipe [polygon]</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/cashing-pipe-polygon/m-p/9917698#M66810</link>
      <description>&lt;P&gt;Thank you very much. This is what I was looking for. Drawing pipes by pointing with points. Would you have any more time for me? Could the ends of the tube be ellipses like in my screenshot? Thanks again for your time. I'm sorry I didn't check your code right away. Best wishes.&lt;/P&gt;</description>
      <pubDate>Sat, 05 Dec 2020 15:33:32 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/cashing-pipe-polygon/m-p/9917698#M66810</guid>
      <dc:creator>JN05</dc:creator>
      <dc:date>2020-12-05T15:33:32Z</dc:date>
    </item>
    <item>
      <title>Re: cashing pipe [polygon]</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/cashing-pipe-polygon/m-p/9917828#M66811</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/3704272"&gt;@JN05&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;&lt;P&gt;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/5530556"&gt;@hak_vz&lt;/a&gt;&amp;nbsp;thank you for your time. It's better now. The lines are drawing. They don't just close at the ends. Will you see why this is happening? Help please.&lt;BR /&gt;Best regards.&lt;/P&gt;&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;Sorry &lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/3704272"&gt;@JN05&lt;/a&gt; but I will not. Script is working almost perfectly at my side and I can't find an error as long as you don't answer previous request. Sample file, what version of Acad (or any other cad) you use.&lt;/P&gt;</description>
      <pubDate>Sat, 05 Dec 2020 17:19:33 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/cashing-pipe-polygon/m-p/9917828#M66811</guid>
      <dc:creator>hak_vz</dc:creator>
      <dc:date>2020-12-05T17:19:33Z</dc:date>
    </item>
    <item>
      <title>Re: cashing pipe [polygon]</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/cashing-pipe-polygon/m-p/9917843#M66812</link>
      <description>Polecenie: COV2PIPE&lt;BR /&gt;Select pipe &amp;gt;1&lt;BR /&gt;Pipe diameter &amp;gt;1&lt;BR /&gt;Pipe extension length &amp;gt;1&lt;BR /&gt;Point diameter &amp;gt;1&lt;BR /&gt;&lt;BR /&gt;*Niewłaściwy wybór*&lt;BR /&gt;Oczekiwany punkt lub&lt;BR /&gt;okNo/oStatni/prZetnij/KOSTKA/WSzystko/krawęDź/OWbok/ZWbok/Wiele]:&lt;BR /&gt;; błąd: Funkcję anulowano&lt;BR /&gt;&lt;BR /&gt;Wybierz polilinię lub [Wiele]:&lt;BR /&gt;Podaj opcję&lt;BR /&gt;[Zamknij/Dołącz/Szerokość/Edwierzch/Wstaw/splaJn/Polilinia/rodzajLinii/ODwróć/Cofaj]:&lt;BR /&gt;</description>
      <pubDate>Sat, 05 Dec 2020 17:26:55 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/cashing-pipe-polygon/m-p/9917843#M66812</guid>
      <dc:creator>JN05</dc:creator>
      <dc:date>2020-12-05T17:26:55Z</dc:date>
    </item>
    <item>
      <title>Re: cashing pipe [polygon]</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/cashing-pipe-polygon/m-p/9917869#M66813</link>
      <description>&lt;P&gt;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/3704272"&gt;@JN05&lt;/a&gt;Problem is probably with function pedit&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="general"&gt;(command "_.pedit" "m" e1 e2 "" "J" "J" "A" (* 4 width) "")&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Offset a polyline and use command pedit at your side to find proper option to join.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;To test what is your pipe center line (lwpoly or 3dpoly) run following function and copy function result&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="general"&gt;(defun c:aa nil (cdr (assoc 0 (entget(car(entsel "\nSelect polyline &amp;gt;"))))))&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;For my code to run properly we need an lwpolyline&lt;/P&gt;</description>
      <pubDate>Sat, 05 Dec 2020 17:39:52 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/cashing-pipe-polygon/m-p/9917869#M66813</guid>
      <dc:creator>hak_vz</dc:creator>
      <dc:date>2020-12-05T17:39:52Z</dc:date>
    </item>
    <item>
      <title>Re: cashing pipe [polygon]</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/cashing-pipe-polygon/m-p/9917978#M66814</link>
      <description>&lt;P&gt;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/3704272"&gt;@JN05&lt;/a&gt;Here you have a version that creates ellipse end at both sides and marks points&lt;/P&gt;&lt;P&gt;If you find it works, select it as a solution.&lt;/P&gt;&lt;P&gt;Since &lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/940934"&gt;@marko_ribar&lt;/a&gt; and &lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/69526"&gt;@Kent1Cooper&lt;/a&gt; also provided their solutions that answer your original request, select them as solution too.&lt;/P&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;&lt;LI-CODE lang="markup"&gt;(defun c:cov2pipeEllipse ( / );e eo  a b c d pt n vlapt e1 e2 coords ptlist adoc take plusp width ext np
; Select lwpolyline entity that is a centerline of pipe object
; and convert it to pipe
; hak_vz 04.12.2020
(defun take (amount lst / ret) (cond ((and (plusp amount) (and (&amp;gt; amount 0) (&amp;lt;= amount (length lst))) (listp lst))(repeat amount (setq ret (cons (car lst) (take (1- amount) (cdr lst))))))))
(defun plusp (num) (cond ((numberp num) (&amp;gt;= num 0.0))))
(setq adoc (vla-get-activedocument (vlax-get-acad-object))) 
(cond 
((and (setq e (car(entsel "\nSelect pipe &amp;gt;"))))
(vla-endundomark adoc)
(vla-startundomark adoc)

(setvar 'cmdecho 0)
(command "_.UCS" "W")
(setq width (* 0.5 (getreal "\nPipe diameter &amp;gt;")))
(setq ext (getreal "\nPipe extension length &amp;gt;"))
(setq pd (* 0.5 (getreal "\nPoint diameter &amp;gt;")))
(setq np (- (cdr (assoc 90 (entget e))) 1))
(setq eo (vlax-ename-&amp;gt;vla-object e))
(setq coords (vlax-get eo 'Coordinates))
(setq ptlist (reverse ptlist))
(setq n (length coords))
(setq a (list (car coords)(cadr coords)))
(setq b (list (caddr coords)(cadddr coords)))
(setq c (list (nth (- n 4) coords)(nth (- n 3) coords)))
(setq d (list (nth (- n 2) coords)(last coords)))
(setq pt (polar a (angle b a) ext))
(setq vlapt (vlax-make-safearray vlax-vbdouble '(0 . 1)))
(vlax-safearray-fill vlapt pt)
(vla-put-Coordinate eo 0  vlapt)
(setq pt (polar d (angle c d) ext))
(setq vlapt (vlax-make-safearray vlax-vbdouble '(0 . 1)))
(vlax-safearray-fill vlapt pt)
(vla-put-Coordinate eo np  vlapt)
(vla-Offset eo width)
(setq e1 (entlast))
(vla-Offset eo (* -1 width))
(setq e2 (entlast))
(setq eo1 (vlax-ename-&amp;gt;vla-object e1))
(setq eo2 (vlax-ename-&amp;gt;vla-object e2))
(setq a (vlax-curve-getstartpoint eo1) b (vlax-curve-getendpoint eo1)) 
(setq c (vlax-curve-getstartpoint eo2) d (vlax-curve-getendpoint eo2))
(command "_.ellipse" "non" a "non" c (* 0.25 (distance a c)))
(command "_.ellipse" "non" b "non" d (* 0.25 (distance b d))) 
(while coords (setq ptlist (cons (take 2 coords) ptlist) coords (cddr coords)))
(while ptlist (command "_.donut" 0 pd "_non" (car ptlist) "") (initcommandversion) (command "chprop" (entlast) "" "C" 1 "" )(setq ptlist (cdr ptlist)))
(command "_.UCS" "P")
(setvar 'cmdecho 1)
(vla-endundomark adoc)
)
)
(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>Sat, 05 Dec 2020 18:35:54 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/cashing-pipe-polygon/m-p/9917978#M66814</guid>
      <dc:creator>hak_vz</dc:creator>
      <dc:date>2020-12-05T18:35:54Z</dc:date>
    </item>
  </channel>
</rss>

