@ishaq03 wrote:
yes my target is draw from the center horizontally to extend the one meter from closed polyline
Try this:
(defun C:HL+1 (/ esel ent etype xl ins int)
(if
(and
(setq esel (entsel "\nObject to draw extended horizontal Line through: "))
(setq ent (car esel))
(wcmatch (setq etype (cdr (assoc 0 (entget ent)))) "*POLYLINE,CIRCLE,ELLIPSE,SPLINE")
(vlax-curve-isClosed ent)
); and
(progn ; then
(command "_.xline" "_hor" (if (wcmatch etype "CIRCLE,ELLIPSE") "_cen" "_gcen") (cadr esel) "")
(setq
xl (entlast)
ins (getvar 'lastpoint)
int (vlax-invoke (vlax-ename->vla-object ent) 'IntersectWith (vlax-ename->vla-object xl) acExtendNone)
); setq
(entdel xl)
(command
"_.line"
"_non" (list (nth 0 int) (nth 1 int) (nth 2 int))
"_non" (list (nth 3 int) (nth 4 int) (nth 5 int))
""
"_.lengthen" "_delta" 1 ins ins ""
); command
); progn
); if
(princ)
)
It works on closed shapes including Polylines but also Circles, Ellipses and Splines. It assumes a horizontal Xline through the center of the shape will intersect it twice and only twice, but if a shape might be such that it intersects more than twice, I can imagine how to account for that.
It doesn't account for other Coordinate Systems, or have the usual enhancements, yet, but all that can be added if it does what you want.
And if you really want a Polyline, rather than a Line, as the result, just change "_.line" to "_.pline" . And consider whether to force zero width on it if that's what you want, in case the current Polyline width might be something else.
Kent Cooper, AIA