Message 1 of 5
Draw grid line specified intervals and coordinate text place all of side

Not applicable
01-21-2016
04:17 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Help please Draw grid with given grid interval with coordinate text place all of side
Thank you
(defun dtr (a) (* pi (/ a 180.00)) ) (defun gr:err (s) (if (/= s "Function cancelled") (princ (strcat "\nError: " s)) ) (setq *error* olderr) (setvar "cmdecho" cmd) (setvar "blipmode" blip) (setvar "osmode" osm) (setvar "gridmode" g_ant) (setvar "snapmode" s_ant) (princ) ) (defun gr_dat () (cond ((/= (getvar "userr1") 0) (initget (+ 2 4)) (if (setq esc (getreal (strcat "\nHorizontal Scale <" (rtos (getvar "userr1") 2) ">: " ) ) ) (setvar "userr1" esc) (setq esc (getvar "userr1")) ) ) ((= (getvar "userr1") 0) (initget (+ 1 2 4)) (setq esc (getreal "\nHorizontal Scale: ")) (setvar "userr1" esc) ) ) (if esc:v (progn (setq esc:va esc:v) (initget (+ 2 4)) (if (setq esc:v (getreal (strcat "\nVertical Scale <" (rtos esc:v 2) ">: " ) ) ) () (setq esc:v esc:va) ) ) (progn (initget (+ 2 4)) (if (setq esc:v (getreal (strcat "\nVertical Scale <" ;(rtos (/ esc 10.00) 2) (rtos esc 2) ">: " ) ) ) () (setq esc:v esc) ) ) ) (if e:hor (progn (setq e:hora e:hor) (initget (+ 2 4)) (if (setq e:hor (getint (strcat "\nHorizontal Spacing <" (rtos e:hor 2) ">: " ) ) ) () (setq e:hor e:hora) ) ) (progn (initget (+ 1 2 4)) (setq e:hor (getint "\nHorizontal Spacing: ")) ) ) (if e:coord (progn (setq e:coorda e:coord) (initget (+ 2 4)) (if (setq e:coord (getint (strcat "\nVertical Spacing <" (rtos e:coord 2) ">: " ) ) ) () (setq e:coord e:coorda) ) ) (progn (initget (+ 2 4)) (if (setq e:coord (getint (strcat "\nVertical Spacing <" (rtos e:hor 2) ">: " ) ) ) () (setq e:coord e:hor) ) ) ) (setq s_ant (getvar "snapmode")) (setq g_ant (getvar "gridmode")) (command "snap" "a" e:hor e:coord "grid" "a" e:hor e:coord ) (setvar "blipmode" 1) (initget 1) (setq pt1 (getpoint "\nLower left corner: ")) (initget 1) (setq pt3 (getcorner pt1 "\nTop right corner: ")) (setvar "blipmode" 0) (setvar "gridmode" g_ant) (setvar "snapmode" s_ant) (initget (+ 1 2 4)) (if a:txt (progn (setq a:txta a:txt) (initget (+ 2 4)) (if (setq a:txt (getreal (strcat "\nText Height (mm) <" (rtos a:txt 2) ">: " ) ) ) () (setq a:txt a:txta) ) ) (progn (initget (+ 1 2 4)) (setq a:txt (getreal "\nText Height (mm): ")) ) ) ;;Verification height of text and existing Style ;;existing : (if (tblsearch "style" "ROMANS") (progn (setq a:act (cdr (assoc 40 (tblsearch "style" "ROMANS")))) (if (/= a:act 0) (progn (setq rgm (getvar "regenmode")) (command "style" "ROMANS" "romans" "0.0" "1" "0.0" "n" "n" "n") (prompt "\n*** Text style redefined ROMANS. ***") (setvar "regenmode" rgm) ) ) ) (progn (setq rgm (getvar "regenmode")) (command "style" "ROMANS" "romans" "0.0" "1" "0.0" "n" "n" "n") (prompt "\n*** The text style was created ROMANS. ***") (setvar "regenmode" rgm) ) ) ;; Missing obtaining coordinates for the other points ;; the rectangle: (setq pt2 (list (car pt3) (cadr pt1))) (setq pt4 (list (car pt1) (cadr pt3))) ;;Preparation of layers: (command "layer" "m" "GRID-LINE" "c" "253" "GRID-LINE" "" "layer" "m" "GRID-TEXT" "c" "7" "GRID-TEXT" "" ) ) ;;Function gr_dib to draw the grid and texts : (defun gr_dib () (command "layer" "m" "GRID-LINE" "" "line" pt1 (polar pt1 (dtr 0.00) (* (fix (/ (distance pt1 pt2) e:hor)) e:hor)) "" "array" "l" "" "r" (setq txt:h (+ (fix (/ (distance pt1 pt4) e:coord)) 1)) "1" e:coord "line" pt1 (polar pt1 (dtr 90.00) (* (fix (/ (distance pt1 pt4) e:coord)) e:coord)) "" "array" "l" "" "r" "1" (setq txt:v (+ (fix (/ (distance pt1 pt2) e:hor)) 1)) e:hor ) ;;Drawing indications Support (Axis y): (setq c:y (cadr pt1)) (setq c:x (- (car pt1) (* 0.01 esc))) (command "layer" "m" "GRID-TEXT" "") (repeat txt:h ;; txt:h is the number of rows for the rectangular array. (setq p:ins (list c:x c:y)) (command "textstyle" "ROMANS" "text" "BL" p:ins (* esc (/ a:txt 1000.00)) "0" (strcat "N" (itoa (fix (/ c:y (/ esc esc:v))))) ) (setq c:y (+ c:y e:coord)) ) ;;Drawing indications Support (Axis x): ;;(setq c:y (- (cadr pt1) (* 0.0125 esc))) (setq c:y (- (cadr pt1) (* 0.01 esc))) (setq c:x (car pt1)) (command "layer" "m" "GRID-TEXT" "") (repeat txt:v (setq p:ins (list c:x c:y)) (command "textstyle" "ROMANS" "text" "BL" p:ins (* esc (/ a:txt 1000.00)) "90" (strcat "E" (itoa (fix c:x) ) ) ) (setq c:x (+ c:x e:hor)) ) ) ;;Funcion principal: (defun c:DRAW_GRID (/ cmd rgm blip pt1 pt2 pt3 pt4 a:text e:act a:act esc txt:h txt:v c:x c:y p:ins s_ant g_ant esc:va e:hora e:coorda a:txta ) ;(setq olderr *error* ; *error* gr:err ; ) (setq cmd (getvar "cmdecho")) (setq blip (getvar "blipmode")) (setvar "cmdecho" 0) (setvar "blipmode" 0) (gr_dat) (gr_dib) (setvar "cmdecho" cmd) (setvar "blipmode" blip) (princ) ) ;;=================================================================== (prompt "\nType Command DRAW_GRID ") (princ)