;polarxy2c.lsp -- conversion from XY to polar (in prep for Sisyphus) ;Bruce Shapiro 10/1/17 (from polarxy2.lsp) ;L/R mirror correction (defun c:makepolar ( / bm sset i ) (setq bm (getvar "blipmode")) (setvar "blipmode" 0) (setq Pi 3.14159) (setq sset (ssget)) (setq i 0) (while (ssname sset i) (setq ename (ssname sset i)) (setq alist (entget ename)) (do_pline) (setq i (1+ i)) );end while (setvar "blipmode" bm) (command "_regen") );end c:test() ;********************************* (defun do_pline () (setq next (entnext ename)) ;now, deal with vertices (setq alist (entget next)) ;initialize theta_old and theta_accum: (setq vert (cdr (assoc 10 alist))) (setq x (car vert) ;get x,y,z coords y (cadr vert) theta_old (* (atan y x) 1) theta_accum theta_old ) ;(print theta_old) ;(print theta_accum) ;(getstring) (while (/= (cdr (assoc 0 alist)) "SEQEND") (progn (setq vert (cdr (assoc 10 alist))) (setq x (car vert) ;get x,y,z coords y (cadr vert) theta_new (* (atan y x) 1) r (sqrt (+ (* x x)(* y y))) ) (setq d_theta (- theta_old theta_new)) (if ( > d_theta Pi) (setq d_theta (- d_theta (* 2 Pi)))) (if ( < d_theta (- Pi)) (setq d_theta (+ d_theta (* 2 Pi)))) (setq theta_accum (+ theta_accum d_theta)) ;(print theta_new) ;(print d_theta) ;(print theta_accum) ;(getstring) (setq newvert (list theta_accum r 0 )) (setq theta_old theta_new) (setq alist ;change vertex xyz values (subst (cons 10 newvert) (assoc 10 alist) alist ) ) (entmod alist) );end progn (setq next (entnext next)) (setq alist (entget next)) ); end while );end do_pline() ;************************************* (prompt "\nMakepolar to execute")(princ)