;;; Convert PL to SPline. 



(defun C:PL2SPL ( / ss i acc)
  (vl-load-com)
  (initget (+ 1 2 4))
  (setq acc (getint "\nPrecision: "))
  (if
    (setq ss (ssget '((0 . "*POLYLINE"))))
    (repeat (setq i (sslength ss))
      (make_spline
        (pl_list (ssname ss (setq i (1- i))))
      )
    )
  )
  (princ)
)

(defun pl_list (e / r i j lg)
 (setq lg (* 0.05 (vlax-curve-getdistatparam e (vlax-curve-getendparam e))))  
  
  (repeat (setq i (1+ (fix (vlax-curve-getEndParam e))))
    (setq r (cons (cons 11 (vlax-curve-GetPointAtParam e (setq i (1- i)))) r))
    (if
      (and
        (> i 0)
        (> (- (vlax-curve-getdistatparam e i) (vlax-curve-getdistatparam e (1- i))) lg)
        )
      (repeat (setq j (1- acc))
        (setq r (cons (cons 11 (vlax-curve-GetPointAtParam e (+ (1- i) (* (/ 1.0 acc) j)))) r)
              j (1- j)
              )
        )
      )
    )
  r
)

(defun make_spline (l)
  (entmake
    (append
      (list
        '(0 . "SPLINE")
        '(100 . "AcDbEntity")
        '(100 . "AcDbSpline")
        '(70 . 1)
        '(71 . 3)
        (cons 74 (length l))
        '(44 . 1.0e-005)
      )
      l
    )
  )
)