ramimann Posted May 28, 2018 Share Posted May 28, 2018 (edited) Hello Everyone I need a help with this routine please: 1-I would like to put a default value for the Grid Spacing 2-I would like to put comma for thousands in grid labeling Thanks a lot (defun c:hgg () (command "undo" "m") (setq *osnap (getvar "osmode")) ;(command "osnap" "endp") (setq p1 (getpoint "\nLower Left Corner: ") p2 (getcorner p1 "\nUpper Right Corner: ") p100(list (car p1) (cadr p2)) p200 (list (car p2) (cadr p1)) ) (command "osnap" "none") (command "-layer" "m" "Grid" "color" "255" "" "") (command "-layer" "m" "Label" "color" "7" "" "") (command "-style" "tahoma" "tahoma" ss "1" "0" "n" "n" "n") (command "layer" "s" "Grid" "" "linetype" "s" "bylayer" "" "color" "5") (command "_.PLINE" p1 p100 p2 p200 p1 "") (setq d (getdist "\nENTER GRID SPACING:")) (setq ss (getdist "\nENTER HEIGHT OF TEXT:")) (setq v (/ 0 d));To set the label at the same horizontal level of the line (setq qq (/ ss 4)) (setq x1 (car p1)) (setq y1 (cadr p1)) (setq x2 (car p2)) (setq y2 (cadr p2)) (setq x100 (car p100)) (setq y100 (cadr p100)) (setq x200 (car p200)) (setq y200 (cadr p200)) (setq f1 (/ x100 d)) (setq f2 (fix f1)) (setq f2 (float f2)) (if (< x100 0) (setq f3 f2)) (if (>= x100 0) (setq f3 (+ f2 1))) (setq f4 (* d f3)) (setq x3 f4) (setq n1 (/ y1 d)) (setq n2 (fix n1)) (setq n2 (float n2)) (if (< y1 0) (setq n3 n2)) (if (>= y1 0) (setq n3 (+ n2 1))) (setq n4 (* d n3)) (setq y3 n4) (setq y y1) (if (> y100 y1) (setq y y100)) (if (> y200 y100) (setq y y200)) (if (> y2 y200) (setq y y2)) (ngridy) ) ;---------------- (defun ngridy () (setq h1 (list x1 y3)) (setq h11 (list x2 y3)) (setq t1 (list (- (+ x100 v) qq) (+ y3 v))) (setq t2 (list (+ x200 v) (+ y3 v))) (setq xrr (+ x2 (* 2 qq))) (setq prr (list xrr y2)) (setq s1 (rtos y3 2 0)) (command "layer" "s" "Grid" "" "linetype" "s" "bylayer" "" "color" "bylayer" "line" h1 h11 "") (command "layer" "s" "Label" "" "color" "bylayer" "text" "s" "tahoma" "j" "mr" t1 0 s1) (command "mirror" "l" "" p100 p1 "" "move" "l" "" p100 p2 "justifytext" "l" "" "ml") (setq y3 (+ y3 d)) (if (< y3 y) (ngridy)) (setq x x1) (if (> x100 x1) (setq x x100)) (if (> x200 x100) (setq x x200)) (if (> x2 x200) (setq x x2)) (ngridx) ) ;---------------- (defun ngridx () (setq v1 (list x3 y1)) (setq v11 (list x3 y2)) (setq r1 (list (- x3 v) (+(+ y2 v) qq))) (setq r2 (list (- x3 v) (+ (+ 1 y2) v))) (setq ydd (- y1 (+ (* qq 2) ss))) (setq pdd (list x1 ydd)) (setq w1 (rtos x3 2 0)) (command "layer" "s" "Grid" "" "linetype" "s" "bylayer" "" "color" "bylayer" "line" v1 v11 "") (command "layer" "s" "Label" "" "color" "bylayer" "text" "s" "tahoma" "j" "bc" r1 0 w1 ) (command "mirror" "l" "" p100 p2 "" "move" "l" "" p100 p1 "justifytext" "l" "" "tc") ;(command "copy" "l" "" p100 pdd "justifytext" "l" "" "tc") (setq x3 (+ x3 d)) (if (< x3 x) (ngridx)) (Setvar "osmode" *osnap)(command "offset") (H-GRID) ) (princ "To undo all,type the command Undo and select B") (princ) (princ "\nTHIS LSP IS ONLY TO DRAW GRID FOR ORTHO FRAME, Type (hgg) to start") Edited August 3, 2018 by SLW210 Code Tags. Quote Link to comment Share on other sites More sharing options...
hanhphuc Posted June 6, 2018 Share Posted June 6, 2018 please include code tags [NOPARSE] your code here [/NOPARSE] your code here make sure you localize variables excepts *gridspacing* (defun c:hgg ( / [color="red"]p1 p2 p100 p200 ..... etc.. [/color]) ... ... Default value? (setq *gridspacing* nil) (initget 6) (setq *gridspacing* (cond ((getdist (strcat"\nENTER GRID SPACING < " (if (numberp *gridspacing*)(rtos *gridspacing* 2 ) "" ) " > : ")) ) (*gridspacing*) (t 50.0) ; ) ) (setq d *gridspacing*) thousand commas Quote Link to comment Share on other sites More sharing options...
ramimann Posted August 1, 2018 Author Share Posted August 1, 2018 Hello Sorry,I was unavailable these days...I appreciate your help,I'll give it a try...Thanks a lot:) Quote Link to comment Share on other sites More sharing options...
satishrajdev Posted August 3, 2018 Share Posted August 3, 2018 You'll find same program here : https://www.autocadproblems.com/2015/11/lisp-to-draw-grid-lines-with-northing.html 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.