@Kent1Cooper wrote:
@ВeekeeCZ wrote:
.. you should make sure that the middle point is AT A VERTEX. ....
If there won't be other stuff drawn in the immediate area of the middle of the "arc," you could explicitly add "_end" Osnap ....
Incorporating that, and some other simplifications:
(defun c:test (/ s i e)
(if (setq s (ssget '((0 . "*polyline"))))
(repeat (setq i (sslength s))
(setq e (ssname s (setq i (1- i))))
(command "_.arc"
"_end" (vlax-curve-getStartPoint e)
"_end" (vlax-curve-getPointAtParam e (/ (vlax-curve-getEndParam e) 2))
"_end" (vlax-curve-getEndPoint e)
)
)
)
(princ)
)
The other simplifications:
The (command) function, without the -s, will do fine.
The (vlax-curve-...) functions don't need conversion to a VLA object, but can also work with the entity name.
The Start Point and End Point can be found directly -- they don't need to be calculated as being at 0 and end-length distances along the Polyline.
Also, @Automohan, the Subject of the thread is really not what you're asking about. Your image is not a Polyline with a lot of vertices and another Polyline with a reduced number of vertices, but rather a Polyline and an Arc [I can tell because the grips are different]. It could be as in the Subject line, if that's what you really need:
(defun c:testP (/ s i e)
(if (setq s (ssget '((0 . "*polyline"))))
(repeat (setq i (sslength s))
(setq e (ssname s (setq i (1- i))))
(command "_.pline"
"_end" (vlax-curve-getStartPoint e)
"_arc" "_second"
"_end" (vlax-curve-getPointAtParam e (/ (vlax-curve-getEndParam e) 2))
"_end" (vlax-curve-getEndPoint e)
""
)
)
)
(princ)
)
In either case, the possibility of other stuff drawn in the vicinity of the middle having some ENDpoint closer than one of the vertices can be prevented from causing an incorrect result by changing this line:
"_end" (vlax-curve-getPointAtParam e (/ (vlax-curve-getEndParam e) 2))
to this:
"_end" (vlax-curve-getPointAtParam e (fix (/ (vlax-curve-getEndParam e) 2)))
[assuming the original Polyline always has at least 3 vertices].
Kent Cooper, AIA