;;;Note: This program is freeware. (Free to everyone at no cost) The code is open AutoLisp. ;;;If you would like to improve or add additional functions, you are free to do so as ;;;long as the modified code is made available to the world through the internet ;;;and by keeping this note in the code. ;;;Steve J. Lindsay www.LindsayEngraving.com www.AirGraver.com www.engravingschool.com www.engravingforum.com (defun DPRMPT (msg def / inp) (if def (setq msg (strcat "\n" msg "<" (rtos def) ">: ")) ;prompt string ;with default (setq msg (strcat "\n" msg ": ")) ;prompt string ;without default ) (setq inp (getreal msg)) ;prompt for user entry (if inp inp def) ;return default if no user ;response ) ;EOFunc dprmpt (defun c:WAVE ( / bfac bulge1 bulge2 ename edata vtx) (setq ename (car (entsel "\nPick a pline:" ))) (if (null ename) (setq ename (entlast))) ;get first bulge factor, default = 1 (setq bfac (dprmpt "\nEnter 1st bulge factor: " 1)) ;get second bulge factor, default = -1 bfac (setq bfac1 (dprmpt "\nEnter 2nd bulge factor: " (* -1 bfac))) ;select last entity in drawing ; (setq ename (entlast)) ;process each vertex, assign alternating bulge factors (progn (setq bulge1 (list (cons 42 bfac))) ;set positive bulge (setq bulge2 (list (cons 42 bfac1))) ;set negative bulge (setq vtx 1) ;start with positive ;bulge (while (and (setq ename (entnext ename)) (setq edata (entget ename)) (/= "SEQEND" (cdr (assoc 0 edata))));and (cond ((= vtx 1) (progn (setq edata (append edata bulge1)) (setq vtx 2)));case 1, add on positive bulge ((= vtx 2) (progn (setq edata (append edata bulge2)) (setq vtx 1)));case 2, add on negative bulge );cond (entmod edata) ;updates entity data description list );while (entupd ename) ;updates screen display );progn. ) (defun cscroll (ntimes bpoint cfac lppass pc zgrowth threeD / ang dist tp ainc dinc circle bs cs z) (setq cs (getvar "cmdecho")) ; save old cmdecho and blipmode (setq bs (getvar "blipmode")) (setvar "blipmode" 0) ; turn blipmode off (setvar "cmdecho" 0) ; turn cmdecho off (setq circle (* 3.141596235 2)) (setq ainc (/ circle lppass)) (setq dinc (/ cfac lppass)) (setq ang 0.0) (setq dist 0.0) (setq pt (/ pc 100.0)) (if (/= threeD "y") (progn ;//if not drawing in 3d do this ;(command "pline" bpoint "arc" "direction" "0") ; start spiral from base point and... (command "pline" bpoint) (repeat ntimes (repeat lppass (setq ang (+ ang ainc)) (setq dist (+ (* pt dist) (+ dist dinc))) (setq tp (polar bpoint ang dist)) (command tp) ; continue to the next point... ) ) (command) ; until done. (setvar "blipmode" bs) ; restore saved blipmode (setvar "cmdecho" cs) ; restore saved cmdecho nil )) ;end of if and progn (if (= threeD "y") (progn ;//if drawing in 3d do this (command "3dpoly" bpoint) ; start spiral from base point and... (setq z 0.0) (setq zgrowth (/ zgrowth lppass)) ;divide the number of points per time around by the growth per time around to find the growth per point (repeat ntimes (repeat lppass (setq tp (polar bpoint (setq ang (+ ang ainc)) (setq dist (+ (* pt dist) (+ dist dinc))))) (setq tp (reverse tp)) ;these two lines take away the 0.0 z cordinate (setq tp (reverse (cdr tp))) (setq z (+ zgrowth z)) ;add zgrowth onto z each time around (setq tp (append tp (list z))) (command tp) ; continue to the next point... ) ) (command) ; until done. (setvar "blipmode" bs) ; restore saved blipmode (setvar "cmdecho" cs) ; restore saved cmdecho nil )) ;end of if and progn ) ; ; Interactive spiral generation ; (defun c:scroll ( / nt bp cf lp pc) (initget 1) ; bp must not be null (setq bp (getpoint "\nCenter point: ")) (initget 7) ; nt must not be zero, neg, or null (setq nt (getint "\nNumber of rotations: ")) (initget 3) ; cf must not be zero, or null (setq cf (getdist "\nGrowth distance per rotation: ")) (initget 6) ; lp must not be zero or neg (setq lp (getint "\nPoints per rotation <30>: ")) (cond ((null lp) (setq lp 30))) (setq pc (getreal "\nLength percent increase per point <0>: ")) (cond ((null pc) (setq pc 0))) (setq threeD (getstring "\nWould you like it to also spiral in the Z for 3D? yn: ")) (if (= threeD "y") (progn (princ "\nGrowth distance per rotation in Z <") (princ cf) (princ ">: ") (setq zgrowth (getdist)) (cond ((null zgrowth) (setq zgrowth cf))) )) (cscroll nt bp cf lp pc zgrowth threeD) ) (princ) ;clean exit, suppress any AutoLISP return messages