<?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 CONVERT LINE TO PLINE without joining lines in Visual LISP, AutoLISP and General Customization Forum</title>
    <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/lisp-to-convert-line-to-pline-without-joining-lines/m-p/12663369#M15954</link>
    <description>&lt;P&gt;What a lot of complications....&amp;nbsp; I repeat [and now include in a command definition], this is all you need, to do what Message 1 requests:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="general"&gt;(defun C:L2PLI ; = Line[s] {to} PolyLine[s] Independently
  (/ ss)
  (if (setq ss (ssget "_:L" '((0 . "LINE"))))
    (command "_.PEDIT" "_multiple" SS "" ""); then
    (prompt "\nNo Line(s) on unlocked Layer(s) selected."); else
  ); if
  (prin1)
)&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you don't normally have PEDITACCEPT set to &lt;STRONG&gt;1&lt;/STRONG&gt;, that can be built into it, or the answer to the conversion question can be built into it, or it could even check that setting and proceed accordingly.&lt;/P&gt;
&lt;P&gt;I assume you want to &lt;EM&gt;select&lt;/EM&gt; the Lines to be converted, not do &lt;EM&gt;all&lt;/EM&gt; Lines in the drawing.&amp;nbsp; But if the latter, and if some may be in different Layouts, this approach would need to move to each one's Layout to convert it.&lt;/P&gt;</description>
    <pubDate>Mon, 25 Mar 2024 10:35:50 GMT</pubDate>
    <dc:creator>Kent1Cooper</dc:creator>
    <dc:date>2024-03-25T10:35:50Z</dc:date>
    <item>
      <title>LISP TO CONVERT LINE TO PLINE without joining lines</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/lisp-to-convert-line-to-pline-without-joining-lines/m-p/12661941#M15948</link>
      <description>&lt;P&gt;i know we can cover the line to PL by join cmd. but it's making all lines to one single pline. any method to convert just to each segment only?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT face="arial black,avant garde"&gt;&lt;EM&gt;&lt;STRONG&gt;or any alternative just separate all segments into individual polilines, just line explode pline to individual lines instead of simple lines.&amp;nbsp;&lt;/STRONG&gt;&lt;/EM&gt;&lt;/FONT&gt;&lt;/P&gt;</description>
      <pubDate>Sun, 24 Mar 2024 13:04:11 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/lisp-to-convert-line-to-pline-without-joining-lines/m-p/12661941#M15948</guid>
      <dc:creator>Sunny2006</dc:creator>
      <dc:date>2024-03-24T13:04:11Z</dc:date>
    </item>
    <item>
      <title>Re: LISP TO CONVERT LINE TO PLINE without joining lines</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/lisp-to-convert-line-to-pline-without-joining-lines/m-p/12661997#M15949</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/14780964"&gt;@Sunny2006&lt;/a&gt;&amp;nbsp; a écrit&amp;nbsp;:&lt;BR /&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT face="arial black,avant garde"&gt;&lt;EM&gt;&lt;STRONG&gt;or any alternative just separate all segments into individual polilines, just line explode pline to individual lines instead of simple lines.&amp;nbsp;&lt;/STRONG&gt;&lt;/EM&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;This&lt;/P&gt;&lt;LI-CODE lang="general"&gt;(defun c:break_lw ( / js i ent dxf_obj dxf_43 dxf_38 dxf_39 dxf_10 dxf_40 dxf_41 dxf_42 dxf_39 dxf_210 n)
  (initget "All Select")
  (if (eq (getkword "\nLWPolylines to cut at each vertex? [All/Select] &amp;lt;Select&amp;gt;: ") "All")
    (setq
      js
        (ssget "_X" 
          (list
            (cons 0 "LWPOLYLINE")
            (cons 67 (if (eq (getvar "CVPORT") 2) 0 1))
            (cons 410 (if (eq (getvar "CVPORT") 2) "Model" (getvar "CTAB")))
          )
        )
      i -1
    )
    (setq
      js
        (ssget
          (list
            (cons 0 "LWPOLYLINE")
            (cons 67 (if (eq (getvar "CVPORT") 2) 0 1))
            (cons 410 (if (eq (getvar "CVPORT") 2) "Model" (getvar "CTAB")))
          )
        )
      i -1
    )
  )
  (cond
    (js
      (repeat (sslength js)
        (setq dxf_obj (entget (setq ent (ssname js (setq i (1+ i))))))
        (if (cdr (assoc 43 dxf_obj))
          (setq dxf_43 (cdr (assoc 43 dxf_obj)))
          (setq dxf_43 0.0)
        )
        (if (cdr (assoc 38 dxf_obj))
          (setq dxf_38 (cdr (assoc 38 dxf_obj)))
          (setq dxf_38 0.0)
        )
        (if (cdr (assoc 39 dxf_obj))
          (setq dxf_39 (cdr (assoc 39 dxf_obj)))
          (setq dxf_39 0.0)
        )
        (setq
          dxf_10 (mapcar 'cdr (vl-remove-if-not '(lambda (x) (= (car x) 10)) dxf_obj))
          dxf_40 (mapcar 'cdr (vl-remove-if-not '(lambda (x) (= (car x) 40)) dxf_obj))
          dxf_41 (mapcar 'cdr (vl-remove-if-not '(lambda (x) (= (car x) 41)) dxf_obj))
          dxf_42 (mapcar 'cdr (vl-remove-if-not '(lambda (x) (= (car x) 42)) dxf_obj))
          dxf_210 (cdr (assoc 210 dxf_obj))
        )
        (if (not (zerop (boole 1 (cdr (assoc 70 dxf_obj)) 1)))
          (setq
            dxf_10 (append dxf_10 (list (car dxf_10)))
            dxf_40 (append dxf_40 (list (car dxf_40)))
            dxf_41 (append dxf_41 (list (car dxf_41)))
            dxf_42 (append dxf_42 (list (car dxf_42)))
            n (cdr (assoc 90 dxf_obj))
          )
          (setq n (1- (cdr (assoc 90 dxf_obj))))
        )
        (repeat n
          (entmake
            (list
              (cons 0 "LWPOLYLINE")
              (cons 100 "AcDbEntity")
              (assoc 67 dxf_obj)
              (assoc 410 dxf_obj)
              (assoc 8 dxf_obj)
              (if (assoc 62 dxf_obj) (assoc 62 dxf_obj) (cons 62 256))
              (if (assoc 6 dxf_obj) (assoc 6 dxf_obj) (cons 6 "BYLAYER"))
              (if (assoc 370 dxf_obj) (assoc 370 dxf_obj) (cons 370 -1))
              (cons 100 "AcDbPolyline")
              (cons 90 2)
              (cons 70 (boole 1 (cdr (assoc 70 dxf_obj)) 128))
              (cons 38 dxf_38)
              (cons 39 dxf_39)
              (cons 10 (car dxf_10))
              (cons 40 (car dxf_40))
              (cons 41 (car dxf_41))
              (cons 42 (car dxf_42))
              (cons 10 (cadr dxf_10))
              (cons 40 (cadr dxf_40))
              (cons 41 (cadr dxf_41))
              (cons 42 (cadr dxf_42))
              (assoc 210 dxf_obj)
            )
          )
          (setq dxf_10 (cdr dxf_10) dxf_40 (cdr dxf_40) dxf_41 (cdr dxf_41) dxf_42 (cdr dxf_42))
        )
        (entdel ent)
      )
      (print (sslength js)) (princ " LWpolyline(s) cut at its vertices.")
    )
  )
  (prin1)
)&lt;/LI-CODE&gt;</description>
      <pubDate>Sun, 24 Mar 2024 13:57:28 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/lisp-to-convert-line-to-pline-without-joining-lines/m-p/12661997#M15949</guid>
      <dc:creator>CADaSchtroumpf</dc:creator>
      <dc:date>2024-03-24T13:57:28Z</dc:date>
    </item>
    <item>
      <title>Re: LISP TO CONVERT LINE TO PLINE without joining lines</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/lisp-to-convert-line-to-pline-without-joining-lines/m-p/12662007#M15950</link>
      <description>&lt;P&gt;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/14780964"&gt;@Sunny2006&lt;/a&gt;&amp;nbsp;,&lt;/P&gt;&lt;P&gt;The 1st part is easy, especially if you setvar "PEDITACCEPT" to 1.&lt;/P&gt;&lt;P&gt;Let's say we assign the symbol name E to the line.&lt;/P&gt;&lt;P&gt;(command "_.PEDIT" e "")&amp;nbsp; ;; that's all.&lt;/P&gt;&lt;P&gt;The second part is a little tougher.&amp;nbsp; We'll use the BREAK command.&lt;/P&gt;&lt;P&gt;The good news is that it will retain arced segments and widths.&lt;/P&gt;&lt;P&gt;The bad news is that it will not work on closed polylines.&lt;/P&gt;&lt;LI-CODE lang="general"&gt;(defun c:DIVIDEPOLY ( / *error* var vals e etype done elast)
  (vl-load-com)
  (setq *acad* (vlax-get-acad-object))
  (vla-StartUndoMark (vla-get-activedocument *acad*))
  ;; Internal error handler and to reset upon exit
  (defun *error* (err)
    (mapcar 'setvar vars vals)
    (vla-EndUndoMark (vla-get-activedocument *acad*))
    (cond
      ((not err))
      ((not (wcmatch (strcase err) "*QUIT*,*CANCEL*"))
        (princ (strcat "\nERROR: " err "\n"))
      )
    )
    (princ)
  )
  (setq vars '("cmdecho"))
  (setq vals (mapcar 'getvar vars))
  (mapcar 'setvar vars '(0))
  (and
    (setq e (car (entsel "\nSelect a polyline to divide: ")))
    (setq etype (cdr (assoc 0 (entget e))))
    (setq elast (entlast))
    (or (= etype "LWPOLYLINE")
      (prompt (strcat "\nObject selected is a(n) " etype "."))
    )
    (or (= (vlax-get (vlax-ename-&amp;gt;vla-object e) 'closed) 0)
      (prompt "\nCannot break a closed polyline at one point.")
    )
    (while (not done)
      (setq p (vlax-curve-getpointatparam e 1))
      (vl-cmdf "_.BREAK" e "_non" p "_non" p)
      (if (not (equal elast (entlast)))
        (setq e (entlast) elast e)
      )
      (if (= (vlax-curve-getendparam e) 1)
        (setq done 1)
      )
    )
  )
  (*error* nil)
)
(defun c:DP ()(c:DIVIDEPOLY))&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 24 Mar 2024 14:12:39 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/lisp-to-convert-line-to-pline-without-joining-lines/m-p/12662007#M15950</guid>
      <dc:creator>john.uhden</dc:creator>
      <dc:date>2024-03-24T14:12:39Z</dc:date>
    </item>
    <item>
      <title>Re: LISP TO CONVERT LINE TO PLINE without joining lines</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/lisp-to-convert-line-to-pline-without-joining-lines/m-p/12662062#M15951</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/3930636"&gt;@john.uhden&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;....&lt;/P&gt;
&lt;P&gt;The 1st part is easy, especially if you setvar "PEDITACCEPT" to 1.&lt;/P&gt;
&lt;P&gt;Let's say we assign the symbol name E to the line.&lt;/P&gt;
&lt;P&gt;(command "_.PEDIT" e "")&amp;nbsp; ;; that's all.&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;....&lt;/SPAN&gt;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;It can be even easier than that.&amp;nbsp; You don't need to do them individually, but can convert &lt;EM&gt;any number&lt;/EM&gt; of Lines to single-line-segment Polylines, all at once, &lt;EM&gt;without&lt;/EM&gt; joining together any that meet at their ends.&amp;nbsp; Let's say we assign the symbol &lt;STRONG&gt;SS&lt;/STRONG&gt; to a selection set of Lines [and/or Arcs if you like]:&lt;/P&gt;
&lt;P&gt;&lt;FONT face="courier new,courier"&gt;&lt;STRONG&gt;&lt;FONT color="#000000"&gt;(command "_.PEDIT" "_multiple" SS "" "")&amp;nbsp;&lt;/FONT&gt; &lt;/STRONG&gt;&lt;/FONT&gt;;; that's all.&amp;nbsp; They all get converted to Polylines, and then if you &lt;EM&gt;don't do anything further with them&lt;/EM&gt;&amp;nbsp;[such as Joining], but simply conclude the command, they remain independent.&lt;/P&gt;</description>
      <pubDate>Sun, 24 Mar 2024 14:57:27 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/lisp-to-convert-line-to-pline-without-joining-lines/m-p/12662062#M15951</guid>
      <dc:creator>Kent1Cooper</dc:creator>
      <dc:date>2024-03-24T14:57:27Z</dc:date>
    </item>
    <item>
      <title>Re: LISP TO CONVERT LINE TO PLINE without joining lines</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/lisp-to-convert-line-to-pline-without-joining-lines/m-p/12662173#M15952</link>
      <description>&lt;P&gt;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/14780964"&gt;@Sunny2006&lt;/a&gt;&amp;nbsp; Please test it&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="general"&gt;(defun c:line-2-plines ( /
CECOLOR LINE-ENT-LIST LINE-ENT-SS OSMODE P10 P11
			)
  (VL-LOAD-COM)
  (setq line-ent-ss (ssget "_x" '((0 . "line"))))
  (Setq	line-ent-list
	 (vl-remove-if
	   'listp
	   (mapcar 'cadr (ssnamex line-ent-ss))
	 ) ;_ end of vl-remove-if
  ) ;_ end of Setq
  (setq osmode (getvar 'osmode))
  (setvar 'osmode 0)
  (vl-cmdf "layer" "M" "poly")
  (setq CECOLOR (getvar 'cecolor))
  (setvar 'cecolor "1")
  (FOREACH line-ent line-ent-list
    (setq p10 (reverse (CDR (REVERSE (cdr (assoc 10 (entget line-ent))))))
    ) ;_ end of setq
    (setq p11 (reverse (CDR (REVERSE (cdr (assoc 11 (entget line-ent))))))
    ) ;_ end of setq
    (vl-cmdf "pline" p10 p11 "")
    (vl-cmdf "erase" line-ent "")
  ) ;_ end of FOREACH
)&lt;/LI-CODE&gt;</description>
      <pubDate>Sun, 24 Mar 2024 16:26:42 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/lisp-to-convert-line-to-pline-without-joining-lines/m-p/12662173#M15952</guid>
      <dc:creator>devitg</dc:creator>
      <dc:date>2024-03-24T16:26:42Z</dc:date>
    </item>
    <item>
      <title>Re: LISP TO CONVERT LINE TO PLINE without joining lines</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/lisp-to-convert-line-to-pline-without-joining-lines/m-p/12663282#M15953</link>
      <description>&lt;P&gt;aio, converts lines/arcs into lw-pline segments and splits lw-plines to each segment.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="lisp"&gt;;**************************************************************************************************************************************************************************

(defun make_vertex_bulge (pline / indices point_bulge_list)
	(setq indices '(0))
	(repeat (fix (vlax-curve-getendparam pline)) (setq indices (append indices (list (1+ (last indices))))))
	(if (minusp (vlax-get pline 'closed)) (setq indices (subst 0 (last indices) indices)))
	(mapcar '(lambda (index) (list (vlax-safearray-&amp;gt;list (vlax-variant-value (vla-get-coordinate pline index))) 
								   (vla-getbulge pline index)
							 )
			 )
			 indices
	)
)

;**************************************************************************************************************************************************************************

(defun c:line_arc_pline_to_segments ()
	(vla-startundomark (vla-get-activedocument (vlax-get-acad-object)))
	(if (setq la_sset (ssget '((0 . "arc,line,lwpolyline"))))
		(foreach object (mapcar 'vlax-ename-&amp;gt;vla-object (vl-remove-if 'listp (mapcar 'cadr (ssnamex la_sset))))
			(cond
				((= "AcDbLine" (vla-get-objectname object))
					(setq segment_list (list (vla-addlightweightpolyline (vla-objectidtoobject (vla-get-activedocument (vlax-get-acad-object)) (vla-get-ownerid object))
															  			 (vlax-safearray-fill (vlax-make-safearray vlax-vbdouble (cons 0 3))
															  								  (apply 'append (list (mapcar '+ '(0 0) (vlax-get object 'startpoint)) 
															  									  				   (mapcar '+ '(0 0) (vlax-get object 'endpoint))
															  												 )
															  								  )
															  			 )
											 )
							      		)
					)
				)
				((= "AcDbArc" (vla-get-objectname object))
					(setq segment_list (list (vla-addlightweightpolyline (vla-objectidtoobject (vla-get-activedocument (vlax-get-acad-object)) (vla-get-ownerid object))
															  			 (vlax-safearray-fill (vlax-make-safearray vlax-vbdouble (cons 0 3))
															  								  (apply 'append (list (mapcar '+ '(0 0) (vlax-get object 'startpoint)) 
															  								  					   (mapcar '+ '(0 0) (vlax-get object 'endpoint))
															  												 )
															  								  )
															  			 )
											 )
							      	   )
					)
					(vla-setbulge (car segment_list) 0 (/ (sin (* 0.25 (vla-get-totalangle object))) (cos (* 0.25 (vla-get-totalangle object)))))
				)
				(t
					(setq vertex_list (make_vertex_bulge object)
						  segments (mapcar 'list vertex_list (cdr vertex_list))
						  segment_list (mapcar '(lambda (segment) (progn (setq segment_object (vla-addlightweightpolyline (vla-objectidtoobject (vla-get-activedocument (vlax-get-acad-object)) (vla-get-ownerid object))
															  			 					  					  		  (vlax-safearray-fill (vlax-make-safearray vlax-vbdouble (cons 0 3))
															  			 					  					  							   (apply 'append (list (caar segment) (caadr segment)))
															  			 					  					  		  )
																					  		  ) 
																		 )
																		 (vla-setbulge segment_object 0 (cadar segment)) 
																		 segment_object
											 					  )
												)
												segments
									   )
					)
				)
			)
			(foreach segment segment_list 
				(foreach property '(layer linetype lineweight linetypescale truecolor)
		   			(vl-catch-all-apply (read (strcat "vla-put-" (vl-princ-to-string property)))
		   								(list segment (eval (list (read (strcat "vla-get-" (vl-princ-to-string property))) object)))
		   			)
		   		)
			)
			(vla-erase object)
		)
	)
	(vla-endundomark (vla-get-activedocument (vlax-get-acad-object)))
	(princ)
)

;**************************************************************************************************************************************************************************&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 25 Mar 2024 09:49:30 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/lisp-to-convert-line-to-pline-without-joining-lines/m-p/12663282#M15953</guid>
      <dc:creator>komondormrex</dc:creator>
      <dc:date>2024-03-25T09:49:30Z</dc:date>
    </item>
    <item>
      <title>Re: LISP TO CONVERT LINE TO PLINE without joining lines</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/lisp-to-convert-line-to-pline-without-joining-lines/m-p/12663369#M15954</link>
      <description>&lt;P&gt;What a lot of complications....&amp;nbsp; I repeat [and now include in a command definition], this is all you need, to do what Message 1 requests:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="general"&gt;(defun C:L2PLI ; = Line[s] {to} PolyLine[s] Independently
  (/ ss)
  (if (setq ss (ssget "_:L" '((0 . "LINE"))))
    (command "_.PEDIT" "_multiple" SS "" ""); then
    (prompt "\nNo Line(s) on unlocked Layer(s) selected."); else
  ); if
  (prin1)
)&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you don't normally have PEDITACCEPT set to &lt;STRONG&gt;1&lt;/STRONG&gt;, that can be built into it, or the answer to the conversion question can be built into it, or it could even check that setting and proceed accordingly.&lt;/P&gt;
&lt;P&gt;I assume you want to &lt;EM&gt;select&lt;/EM&gt; the Lines to be converted, not do &lt;EM&gt;all&lt;/EM&gt; Lines in the drawing.&amp;nbsp; But if the latter, and if some may be in different Layouts, this approach would need to move to each one's Layout to convert it.&lt;/P&gt;</description>
      <pubDate>Mon, 25 Mar 2024 10:35:50 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/lisp-to-convert-line-to-pline-without-joining-lines/m-p/12663369#M15954</guid>
      <dc:creator>Kent1Cooper</dc:creator>
      <dc:date>2024-03-25T10:35:50Z</dc:date>
    </item>
  </channel>
</rss>

