Small Segmented Polyline to One Arc

Small Segmented Polyline to One Arc

shil143
Advocate Advocate
2,462 Views
5 Replies
Message 1 of 6

Small Segmented Polyline to One Arc

shil143
Advocate
Advocate

Hi All,

 

 How can convert segmented polyline to polyline Arc..

 

Please check below image

 

Untitled.png

 

 

0 Likes
Accepted solutions (1)
2,463 Views
5 Replies
Replies (5)
Message 2 of 6

imadHabash
Mentor
Mentor

Hi,

Usually you can just select the given polyline (to show grips) and in the given segment hover over its middle grip. After a while AutoCAD displays a context menu with the command "Convert to arc" (or vice-versa "Convert to line") . But for your case we need to see ( CAD dwg file ) your segmented polyline for testing ?

 

 

 

Imad Habash

EESignature

Message 3 of 6

shil143
Advocate
Advocate

Sample Drawing

0 Likes
Message 4 of 6

ВeekeeCZ
Consultant
Consultant
Accepted solution

This LISP will convert segmented ARCs or CIRCLEs to their respective original. 

BUT NOT polylines that are a combination of arcs and straight lines. You'll need to explode them and rejoin just arc portions.

 

(vl-load-com)

(defun c:PLS2Arc ( / s i e d) ; Polyline Segmented To Arc or Circle

  (if (setq s (ssget "_:L" '((0 . "LWPOLYLINE") (-4 . ">") (90 . 2))))
    (repeat (setq i (sslength s))
      (setq e (ssname s (setq i (1- i)))
	    d (entget e))
      (if (or (= 1 (logand (cdr (assoc 70 d)) 1))
	      (equal (vlax-curve-getstartpoint e) (vlax-curve-getendpoint e) 1e-14))
	(command "_.circle" "_3p"
		 "_none" (vlax-curve-getstartpoint e)
		 "_none" (vlax-curve-getpointatparam e 1)
		 "_none" (vlax-curve-getpointatparam e 2))
	(command "_.arc"
		 "_non" (trans (vlax-curve-getstartpoint e) 0 1)
		 "_non" (trans (vlax-curve-getpointatparam e 1) 0 1)
		 "_non" (trans (vlax-curve-getendpoint e) 0 1)))
      (entmod (append (entget (entlast)) (list (assoc 8 d))))
      (entdel e)))
  (princ)
  )

 

Message 5 of 6

Kent1Cooper
Consultant
Consultant

If there might be small inaccuracies in the original Polyline, I would suggest an adjustment.  Here, the white is a regular 36-gon, except that I moved the start/end point [where the red dot is] only 1/2 of 1% of the diameter inboard:

Kent1Cooper_0-1615893827521.png

On the left, the yellow Circle is the result of using the first three vertices for a 3-point Circle.  My suggestion is to instead use the starting vertex, one about 1/3 of the way around, and one about 2/3 of the way around.  That gives the blue Circle on the right, which is much closer to the polygon original that you can sort of see under it.

 

For a closed polygon that you want to change to a Circle, that approach is used in the Pg2C command, >here<.  [That allows multiple-polygon selection; see Message 3 there for a single-polygon-selection version.]

 

Similarly, for the Arc conversion I would recommend, for the second point, a vertex that is not the second one, but one about halfway along:

....

  "_non" (trans (vlax-curve-getpointatparam e (/ (cdr (assoc 90 d)) 2)) 0 1)

....

Kent Cooper, AIA
0 Likes
Message 6 of 6

Mahdigoli2021
Community Visitor
Community Visitor

Your Lisp solved many big problems that I had.
Thank you very much.
I hope you the best.

0 Likes