Demesne Posted May 14, 2010 Share Posted May 14, 2010 Hi I have an old lisp that inserts a 'tadpole' block between two picked points (top of slope and bottom of slope). I have edited the code to work only with horizontal distances and not slope distances to ensure that the scale factor is calculated correctly when working in 3D. My question is how do I have the block automatically inserted at a height of zero? My knowledge of LISP is not great - I can sometimes see what it's doing and might me able to cut and paste code from one file to another, but as of yet, can't write the code myself. (defun c:tadpole () ;(while (= 1 1) (setq oldsnap (getvar "osmode")) (setvar "osmode" 512) (setvar "cmdecho" 0) (setq pt1 (getpoint "\nIndicate top of slope: ") pt2 (getpoint "\nIndicate bottom of slope: " pt1) x1 (car pt1) ;x-coord of point one x2 (car pt2) ;x-coord of point two y1 (cadr pt1) ;y-coord of point one y2 (cadr pt2) ;y-coord of point two xdis (- x2 x1) ;distance in x direction between points ydis (- y2 y1) ;distance in y direction between points hzdis (sqrt(+ (expt xdis 2.0)(expt ydis 2.0))) ;A sq + B sq = C sq sf (* hzdis 0.9) ) (tadpole pt1 pt2) (setvar "osmode" oldsnap) (setvar "cmdecho" 1) (princ) ) (defun tadpole (pt1 pt2) (setq la (getvar "CLAYER")) (command "LAYER" "M" "ES_Tadpoles" "" "INSERT" "TADPOLE" pt1 sf sf pt2 "LAYER" "S" la "" ) ) TADPOLE.DWG Quote Link to comment Share on other sites More sharing options...
alanjt Posted May 14, 2010 Share Posted May 14, 2010 From a first glance (too early): For this portion of the code... "INSERT" "TADPOLE" pt1 sf sf pt2 replace pt1 with (list (car pt1) (cadr pt1) 0.) Quote Link to comment Share on other sites More sharing options...
Demesne Posted May 14, 2010 Author Share Posted May 14, 2010 alanjt - Thanks for the quiqk reply but I couldn't seem to get that to work. Block still comes in at pt1 z value. Quote Link to comment Share on other sites More sharing options...
alanjt Posted May 14, 2010 Share Posted May 14, 2010 (defun c:tadpole () ;(while (= 1 1) (setq oldsnap (getvar "osmode")) (setvar "osmode" 512) (setvar "cmdecho" 0) (setq pt1 (getpoint "\nIndicate top of slope: ") pt2 (getpoint "\nIndicate bottom of slope: " pt1) x1 (car pt1) ;x-coord of point one x2 (car pt2) ;x-coord of point two y1 (cadr pt1) ;y-coord of point one y2 (cadr pt2) ;y-coord of point two xdis (- x2 x1) ;distance in x direction between points ydis (- y2 y1) ;distance in y direction between points hzdis (sqrt(+ (expt xdis 2.0)(expt ydis 2.0))) ;A sq + B sq = C sq sf (* hzdis 0.9) ) (tadpole pt1 pt2) (setvar "osmode" oldsnap) (setvar "cmdecho" 1) (princ) ) (defun tadpole (pt1 pt2) (setq la (getvar "CLAYER")) (command "LAYER" "M" "ES_Tadpoles" "" [color=Red]"INSERT" "TADPOLE" "_non" (list (car pt1) (cadr pt1) 0.) sf sf pt2[/color] "LAYER" "S" la "" ) ) Quote Link to comment Share on other sites More sharing options...
Demesne Posted May 14, 2010 Author Share Posted May 14, 2010 Thanks. That works great. I understand that that (car pt1) is the easting and (cadr pt1) is the northing - the first and second list items, but what relevance has "_non"? Quote Link to comment Share on other sites More sharing options...
alanjt Posted May 14, 2010 Share Posted May 14, 2010 Thanks. That works great. I understand that that (car pt1) is the easting and (cadr pt1) is the northing - the first and second list items, but what relevance has "_non"? It ignores any running OSnaps. Quote Link to comment Share on other sites More sharing options...
Demesne Posted May 14, 2010 Author Share Posted May 14, 2010 Ah, and I had OSMODE set to nearest. Quote Link to comment Share on other sites More sharing options...
alanjt Posted May 14, 2010 Share Posted May 14, 2010 ........... Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.