Message 1 of 6
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hi All,
How can convert segmented polyline to polyline Arc..
Please check below image
Solved! Go to Solution.
Hi All,
How can convert segmented polyline to polyline Arc..
Please check below image
Solved! Go to Solution.
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
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)
)
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:
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)
....
Your Lisp solved many big problems that I had.
Thank you very much.
I hope you the best.