
Originally Posted by
tflaherty
I'm almost certain I've seen this here recently, but can't find it. Is there a LISP out there that will convert an spline to a polyline.
Thanks
Hi
I not sure but maybe there is what you need
Thank you
f.
Code:
(defun sp2p (num / acsp adoc delta diff
lengt mea_point pline pt_list pt_safe
spline sp_ent
)
(vl-load-com)
(setq adoc (vla-get-activedocument
(vlax-get-acad-object)
)
acsp (vla-get-block
(vla-get-activelayout adoc)
)
)
(vla-endundomark adoc)
(vla-startundomark adoc)
(if (setq sp_ent (car (entsel "\t\n***\tSELECT SPLINE\t***\n")))
(progn
(setq spline (vlax-ename->vla-object sp_ent))
(setq lengt (vlax-curve-getdistatpoint
spline
(vlax-curve-getendpoint spline)
)
delta (/ lengt num)
diff delta
)
(while (/= (length pt_list) num)
(setq mea_point (vlax-curve-getpointatdist spline delta))
(setq pt_list (cons mea_point pt_list))
(setq delta (+ delta diff))
)
(setq pt_list (append pt_list
(list (vlax-curve-getstartpoint spline))
)
pt_list (append (list (vlax-curve-getendpoint spline)) pt_list)
pt_list (apply 'append pt_list)
)
(setq pt_safe
(vlax-safearray-fill
(vlax-make-safearray
vlax-vbdouble
(cons 0 (1- (length pt_list)))
)
pt_list
)
)
(setq pline (vla-addpolyline acsp pt_safe))
;;; (vla-put-type pline acfitcurvepoly);for smoothing polyline
(vla-update pline)
(vlax-release-object pline)
(vla-delete spline)
(vlax-release-object spline)
)
(princ "Nothing selected. Try again...")
)
(vla-endundomark adoc)
(princ)
)
;;CaLL:
;(sp2p 100);100 - number of vertices
;(princ)