;;----------- convert spline(13 or 12) ------------;; ;;--------- to polyline with lines/arcs -----------;; ;;by Vladimir Nesterovsky ;; ;;helper functions (defun dxf(a b)(cdr(assoc a b))) (defun sstol ( sel / l n ) (if (= 'PICKSET (type sel)) (repeat (setq n (sslength sel)) (setq n (1- n) l (cons (ssname sel n) l)) ))) ;; convert spline13 to s-pline12 by control points ;; (w/out user fit points, so it's not good) (defun spl13-12(e / d a p p1) ;; keep original entity (setq d (entget e)) (setvar"cmdecho"0)(command"_pline") (foreach a d (if(= 10(car a)) ;;control points (command (if (null p1) (setq p1 (cdr a))(setq p (cdr a)))))) (if (equal p p1) (command "c") (command "")) (command"_pedit""_l""_s""") ) ;; command version (defun c:spl13-12(/ el e) (if (if (setq el (ssget "I" '((0 . "SPLINE")) )) (setq el (sstol el)) (setq el (sstol (ssget '((0 . "SPLINE")) )))) (foreach e el (spl13-12 e))) ) ;; convert splined 12'pline into regular Polyline. ;; by Tony Tanzillo's Advise: explode splined polyline ;; when SPLINESEGS is negative, and them rejoin ;; the arcs into new polyline (defun despline12--(e) ;; BAD! Join not always succeeds! (setvar"cmdecho"0)(command "_explode" e) (command "_pedit" "_l" "_y" "_j" "_p" "" "") ) ;; The same - by Lisp. ;; Use spline and curve fit points with their bulges. ;; If SPLINESEGS was negative when the pline was built, ;; you'll get Arc segments, tangential to each other. ;; I guess this is how ACAD itself displays splined ;; polylines. (defun despline12(e / e0 d) ;; erase original entity (setq d (entget (setq e0 e))) (if (and (= "POLYLINE" (dxf 0 d)) (= 4 (logand 4 (dxf 70 d)))) ;;splined (progn (entmake (list '(0 . "POLYLINE") (cons 70 (logand 1(cdr(assoc 70 d)))))) (WHILE (/= "SEQEND" (dxf 0 (SETQ D (ENTGET (SETQ E (ENTNEXT E)))))) ;; spline and curve fit points (if (member (dxf 70 d) (list 8 1)) (entmake ;; use point and bulge data (list (assoc 0 d)(assoc 10 d)(assoc 42 d))) )) (entdel e0) (entmake '((0 . "SEQEND"))) )) (princ) ) ;;command version (defun c:despl12() (foreach e (sstol (ssget '( (0 . "POLYLINE") ))) (despline12 e)) ) ;; FINALLY, ;; convert R13's SPLINE into arcs & lines' POLYLINE (defun c:despl13(/ el) (if (if (setq el (ssget "I" '((0 . "SPLINE")) )) (setq el (sstol el)) (setq el (sstol (ssget '((0 . "SPLINE")) )))) (foreach e el (spl13-12 e) (despline12 (entlast)) )) ) ;;-----------------10-19-96 04:24am---------------;;