Jump to content

Recommended Posts

Posted (edited)

Hi i  am  using this grid lisp. When the  final grid is block. I want before the block create to draw a line in specific layer and this layer be on top of the other layers. I write the code i need but i can not find the  corect spot in main code. All the times draw the line but the line is not in the block.

 

original code

;
;
;     Program written by Robert Livingston
;
;     RFLSTATXT is a utility for converting numbers to station text (i.e 1234.567 => "1+234.567")
;     RFLSTAPOS is the number of digits between the '+' and the '.'
;     RFLSIGN returns -1 for -ve and +1 for +ve
;     MAKEENT subset of MakeEnt.lsp for creating DrawGridDef block
;
;
(setq RFLSTAPOS nil)
(defun RFLSIGN (X)
 (if (< X 0)
  (eval -1)
  (eval 1)
 )
)
(defun RFLSTATXT (STA / C DIMZIN S STAH STAL)
 (if (= nil RFLSTAPOS) (if (= nil (setq RFLSTAPOS (getint "\nStation label '+' location <3> : "))) (setq RFLSTAPOS 3)))
 (setq DIMZIN (getvar "DIMZIN"))
 (setvar "DIMZIN" 8)
 (if (< RFLSTAPOS 1)
  (rtos STA)
  (progn
   (if (< STA 0.0)
    (setq S "-")
    (setq S "")
   )
   (setq STAH (fix (/ (abs STA) (expt 10 RFLSTAPOS))))
   (setq STAL (- (abs STA) (* STAH (expt 10 RFLSTAPOS))))
   (if (= (substr (rtos STAL) 1 (+ RFLSTAPOS 1)) (itoa (expt 10 RFLSTAPOS)))
    (progn
     (setq STAL 0.0)
     (setq STAH (+ STAH (RFLSIGN STAH)))
    )
   )
   (setq STAH (itoa STAH))
   (setq C (- RFLSTAPOS (strlen (itoa (fix STAL)))))
   (setq STAL (rtos STAL 2 (getvar "LUPREC")))
   (while (> C 0)
    (setq STAL (strcat "0" STAL))
    (setq C (- C 1))
   )
   (setvar "DIMZIN" DIMZIN)
   (setq RFLSTAHTXT (strcat S STAH) RFLSTALTXT STAL)
   (strcat S STAH "+" STAL)
  )
 )
)
(defun MAKEENT (BLKNAME / )
 (cond ((= (strcase BLKNAME) "DRAWGRIDDEF")
        (progn
         (entmake)
         (entmake
          (list
           (cons 0 "BLOCK")
           (cons 2 "DrawGridDef")
           (cons 70 2)
           (list 10 0 0 0)
          )
         )
         (entmake
          (list
           (cons 0 "CIRCLE")
           (cons 100 "AcDbEntity")
           (cons 67 0)
           (cons 8 "0")
           (cons 100 "AcDbCircle")
           (list 10 0 0 0)
           (cons 40 1)
          )
         )
         (entmake
          (list
           (cons 0 "TEXT")
           (cons 100 "AcDbEntity")
           (cons 67 0)
           (cons 8 "0")
           (cons 100 "AcDbText")
           (list 10 -1.7271487 -1.5 0)
           (cons 40 0.25)
           (cons 1 "Title Text : ")
           (cons 50 0)
           (cons 41 1)
           (cons 51 0)
           (cons 7 "Standard")
           (cons 71 0)
           (cons 72 2)
           (list 11 0 -1.5 0)
           (cons 100 "AcDbText")
           (cons 73 0)
          )
         )
         (entmake
          (list
           (cons 0 "TEXT")
           (cons 100 "AcDbEntity")
           (cons 67 0)
           (cons 8 "0")
           (cons 100 "AcDbText")
           (list 10 -2.83373124 -1.9047619 0)
           (cons 40 0.25)
           (cons 1 "Title Text Height : ")
           (cons 50 0)
           (cons 41 1)
           (cons 51 0)
           (cons 7 "Standard")
           (cons 71 0)
           (cons 72 2)
           (list 11 0 -1.9047619 0)
           (cons 100 "AcDbText")
           (cons 73 0)
          )
         )
         (entmake
          (list
           (cons 0 "TEXT")
           (cons 100 "AcDbEntity")
           (cons 67 0)
           (cons 8 "0")
           (cons 100 "AcDbText")
           (list 10 -2.75579809 -2.30952381 0)
           (cons 40 0.25)
           (cons 1 "Title Text Offset : ")
           (cons 50 0)
           (cons 41 1)
           (cons 51 0)
           (cons 7 "Standard")
           (cons 71 0)
           (cons 72 2)
           (list 11 0 -2.30952381 0)
           (cons 100 "AcDbText")
           (cons 73 0)
          )
         )
         (entmake
          (list
           (cons 0 "TEXT")
           (cons 100 "AcDbEntity")
           (cons 67 0)
           (cons 8 "0")
           (cons 100 "AcDbText")
           (list 10 -2.44355389 -2.71428571 0)
           (cons 40 0.25)
           (cons 1 "Base Point 'X' : ")
           (cons 50 0)
           (cons 41 1)
           (cons 51 0)
           (cons 7 "Standard")
           (cons 71 0)
           (cons 72 2)
           (list 11 0 -2.71428571 0)
           (cons 100 "AcDbText")
           (cons 73 0)
          )
         )
         (entmake
          (list
           (cons 0 "TEXT")
           (cons 100 "AcDbEntity")
           (cons 67 0)
           (cons 8 "0")
           (cons 100 "AcDbText")
           (list 10 -2.44355389 -3.11904762 0)
           (cons 40 0.25)
           (cons 1 "Base Point 'Y' : ")
           (cons 50 0)
           (cons 41 1)
           (cons 51 0)
           (cons 7 "Standard")
           (cons 71 0)
           (cons 72 2)
           (list 11 0 -3.11904762 0)
           (cons 100 "AcDbText")
           (cons 73 0)
          )
         )
         (entmake
          (list
           (cons 0 "TEXT")
           (cons 100 "AcDbEntity")
           (cons 67 0)
           (cons 8 "0")
           (cons 100 "AcDbText")
           (list 10 -1.94065484 -3.52380952 0)
           (cons 40 0.25)
           (cons 1 "Grid Width : ")
           (cons 50 0)
           (cons 41 1)
           (cons 51 0)
           (cons 7 "Standard")
           (cons 71 0)
           (cons 72 2)
           (list 11 0 -3.52380952 0)
           (cons 100 "AcDbText")
           (cons 73 0)
          )
         )
         (entmake
          (list
           (cons 0 "TEXT")
           (cons 100 "AcDbEntity")
           (cons 67 0)
           (cons 8 "0")
           (cons 100 "AcDbText")
           (list 10 -3.41660982 -3.92857143 0)
           (cons 40 0.25)
           (cons 1 "Grid Height : ")
           (cons 50 0)
           (cons 41 1)
           (cons 51 0)
           (cons 7 "Standard")
           (cons 71 0)
           (cons 72 2)
           (list 11 0 -3.92857143 0)
           (cons 100 "AcDbText")
           (cons 73 0)
          )
         )
         (entmake
          (list
           (cons 0 "TEXT")
           (cons 100 "AcDbEntity")
           (cons 67 0)
           (cons 8 "0")
           (cons 100 "AcDbText")
           (list 10 -3.41660982 -4.33333333 0)
           (cons 40 0.25)
           (cons 1 "Vertical Exageration : ")
           (cons 50 0)
           (cons 41 1)
           (cons 51 0)
           (cons 7 "Standard")
           (cons 71 0)
           (cons 72 2)
           (list 11 0 -4.33333333 0)
           (cons 100 "AcDbText")
           (cons 73 0)
          )
         )
         (entmake
          (list
           (cons 0 "TEXT")
           (cons 100 "AcDbEntity")
           (cons 67 0)
           (cons 8 "0")
           (cons 100 "AcDbText")
           (list 10 -2.07690996 -4.73809524 0)
           (cons 40 0.25)
           (cons 1 "Text Height : ")
           (cons 50 0)
           (cons 41 1)
           (cons 51 0)
           (cons 7 "Standard")
           (cons 71 0)
           (cons 72 2)
           (list 11 0 -4.73809524 0)
           (cons 100 "AcDbText")
           (cons 73 0)
          )
         )
         (entmake
          (list
           (cons 0 "TEXT")
           (cons 100 "AcDbEntity")
           (cons 67 0)
           (cons 8 "0")
           (cons 100 "AcDbText")
           (list 10 -1.99897681 -5.14285714 0)
           (cons 40 0.25)
           (cons 1 "Text Offset : ")
           (cons 50 0)
           (cons 41 1)
           (cons 51 0)
           (cons 7 "Standard")
           (cons 71 0)
           (cons 72 2)
           (list 11 0 -5.14285714 0)
           (cons 100 "AcDbText")
           (cons 73 0)
          )
         )
         (entmake
          (list
           (cons 0 "TEXT")
           (cons 100 "AcDbEntity")
           (cons 67 0)
           (cons 8 "0")
           (cons 100 "AcDbText")
           (list 10 -3.97936562 -5.54761905 0)
           (cons 40 0.25)
           (cons 1 "Horizontal Grid Spacing : ")
           (cons 50 0)
           (cons 41 1)
           (cons 51 0)
           (cons 7 "Standard")
           (cons 71 0)
           (cons 72 2)
           (list 11 0 -5.54761905 0)
           (cons 100 "AcDbText")
           (cons 73 0)
          )
         )
         (entmake
          (list
           (cons 0 "TEXT")
           (cons 100 "AcDbEntity")
           (cons 67 0)
           (cons 8 "0")
           (cons 100 "AcDbText")
           (list 10 -4.75579809 -5.95238095 0)
           (cons 40 0.25)
           (cons 1 "Horizontal Fine Grid Spacing : ")
           (cons 50 0)
           (cons 41 1)
           (cons 51 0)
           (cons 7 "Standard")
           (cons 71 0)
           (cons 72 2)
           (list 11 0 -5.95238095 0)
           (cons 100 "AcDbText")
           (cons 73 0)
          )
         )
         (entmake
          (list
           (cons 0 "TEXT")
           (cons 100 "AcDbEntity")
           (cons 67 0)
           (cons 8 "0")
           (cons 100 "AcDbText")
           (list 10 -4.75562756 -6.35714286 0)
           (cons 40 0.25)
           (cons 1 "Horizontal Grid Text Spacing : ")
           (cons 50 0)
           (cons 41 1)
           (cons 51 0)
           (cons 7 "Standard")
           (cons 71 0)
           (cons 72 2)
           (list 11 0 -6.35714286 0)
           (cons 100 "AcDbText")
           (cons 73 0)
          )
         )
         (entmake
          (list
           (cons 0 "TEXT")
           (cons 100 "AcDbEntity")
           (cons 67 0)
           (cons 8 "0")
           (cons 100 "AcDbText")
           (list 10 -3.57162347 -6.76190476 0)
           (cons 40 0.25)
           (cons 1 "Vertical Grid Spacing : ")
           (cons 50 0)
           (cons 41 1)
           (cons 51 0)
           (cons 7 "Standard")
           (cons 71 0)
           (cons 72 2)
           (list 11 0 -6.76190476 0)
           (cons 100 "AcDbText")
           (cons 73 0)
          )
         )
         (entmake
          (list
           (cons 0 "TEXT")
           (cons 100 "AcDbEntity")
           (cons 67 0)
           (cons 8 "0")
           (cons 100 "AcDbText")
           (list 10 -4.34805593 -7.16666667 0)
           (cons 40 0.25)
           (cons 1 "Vertical Fine Grid Spacing : ")
           (cons 50 0)
           (cons 41 1)
           (cons 51 0)
           (cons 7 "Standard")
           (cons 71 0)
           (cons 72 2)
           (list 11 0 -7.16666667 0)
           (cons 100 "AcDbText")
           (cons 73 0)
          )
         )
         (entmake
          (list
           (cons 0 "TEXT")
           (cons 100 "AcDbEntity")
           (cons 67 0)
           (cons 8 "0")
           (cons 100 "AcDbText")
           (list 10 -4.3478854 -7.57142857 0)
           (cons 40 0.25)
           (cons 1 "Vertical Grid Text Spacing : ")
           (cons 50 0)
           (cons 41 1)
           (cons 51 0)
           (cons 7 "Standard")
           (cons 71 0)
           (cons 72 2)
           (list 11 0 -7.57142857 0)
           (cons 100 "AcDbText")
           (cons 73 0)
          )
         )
         (entmake
          (list
           (cons 0 "TEXT")
           (cons 100 "AcDbEntity")
           (cons 67 0)
           (cons 8 "0")
           (cons 100 "AcDbText")
           (list 10 -1.92155525 -7.97619048 0)
           (cons 40 0.25)
           (cons 1 "Grid Layer : ")
           (cons 50 0)
           (cons 41 1)
           (cons 51 0)
           (cons 7 "Standard")
           (cons 71 0)
           (cons 72 2)
           (list 11 0 -7.97619048 0)
           (cons 100 "AcDbText")
           (cons 73 0)
          )
         )
         (entmake
          (list
           (cons 0 "TEXT")
           (cons 100 "AcDbEntity")
           (cons 67 0)
           (cons 8 "0")
           (cons 100 "AcDbText")
           (list 10 -2.69798772 -8.38095238 0)
           (cons 40 0.25)
           (cons 1 "Fine Grid Layer : ")
           (cons 50 0)
           (cons 41 1)
           (cons 51 0)
           (cons 7 "Standard")
           (cons 71 0)
           (cons 72 2)
           (list 11 0 -8.38095238 0)
           (cons 100 "AcDbText")
           (cons 73 0)
          )
         )
         (entmake
          (list
           (cons 0 "TEXT")
           (cons 100 "AcDbEntity")
           (cons 67 0)
           (cons 8 "0")
           (cons 100 "AcDbText")
           (list 10 -1.94099591 -8.78571429 0)
           (cons 40 0.25)
           (cons 1 "Text Layer : ")
           (cons 50 0)
           (cons 41 1)
           (cons 51 0)
           (cons 7 "Standard")
           (cons 71 0)
           (cons 72 2)
           (list 11 0 -8.78571429 0)
           (cons 100 "AcDbText")
           (cons 73 0)
          )
         )
         (entmake
          (list
           (cons 0 "TEXT")
           (cons 100 "AcDbEntity")
           (cons 67 0)
           (cons 8 "0")
           (cons 100 "AcDbText")
           (list 10 -5.85999318 -9.19047619 0)
           (cons 40 0.25)
           (cons 1 "Station Text Label Flag (1 = Use '+') : ")
           (cons 50 0)
           (cons 41 1)
           (cons 51 0)
           (cons 7 "Standard")
           (cons 71 0)
           (cons 72 2)
           (list 11 0 -9.19047619 0)
           (cons 100 "AcDbText")
           (cons 73 0)
          )
         )
         (entmake
          (list
           (cons 0 "TEXT")
           (cons 100 "AcDbEntity")
           (cons 67 0)
           (cons 8 "0")
           (cons 100 "AcDbText")
           (list 10 -2.32912688 -9.5952381 0)
           (cons 40 0.25)
           (cons 1 "Master Scale : ")
           (cons 50 0)
           (cons 41 1)
           (cons 51 0)
           (cons 7 "Standard")
           (cons 71 0)
           (cons 72 2)
           (list 11 0 -9.5952381 0)
           (cons 100 "AcDbText")
           (cons 73 0)
          )
         )
         (entmake
          (list
           (cons 0 "ATTDEF")
           (cons 100 "AcDbEntity")
           (cons 67 0)
           (cons 8 "0")
           (cons 100 "AcDbText")
           (list 10 0 -1.5 0)
           (cons 40 0.25)
           (cons 1 "Grid Title")
           (cons 50 0)
           (cons 41 1)
           (cons 51 0)
           (cons 7 "Standard")
           (cons 71 0)
           (cons 72 0)
           (list 11 0 0 0)
           (cons 100 "AcDbAttributeDefinition")
           (cons 3 "Title Text")
           (cons 2 "TITLE")
           (cons 70 0)
           (cons 73 0)
           (cons 74 0)
          )
         )
         (entmake
          (list
           (cons 0 "ATTDEF")
           (cons 100 "AcDbEntity")
           (cons 67 0)
           (cons 8 "0")
           (cons 100 "AcDbText")
           (list 10 0 -1.9047619 0)
           (cons 40 0.25)
           (cons 1 "5.0")
           (cons 50 0)
           (cons 41 1)
           (cons 51 0)
           (cons 7 "Standard")
           (cons 71 0)
           (cons 72 0)
           (list 11 0 0 0)
           (cons 100 "AcDbAttributeDefinition")
           (cons 3 "Title Text Height")
           (cons 2 "TITLEHEIGHT")
           (cons 70 0)
           (cons 73 0)
           (cons 74 0)
          )
         )
         (entmake
          (list
           (cons 0 "ATTDEF")
           (cons 100 "AcDbEntity")
           (cons 67 0)
           (cons 8 "0")
           (cons 100 "AcDbText")
           (list 10 0 -2.30952381 0)
           (cons 40 0.25)
           (cons 1 "5.0")
           (cons 50 0)
           (cons 41 1)
           (cons 51 0)
           (cons 7 "Standard")
           (cons 71 0)
           (cons 72 0)
           (list 11 0 0 0)
           (cons 100 "AcDbAttributeDefinition")
           (cons 3 "Title Text Offset")
           (cons 2 "TITLEOFFSET")
           (cons 70 0)
           (cons 73 0)
           (cons 74 0)
          )
         )
         (entmake
          (list
           (cons 0 "ATTDEF")
           (cons 100 "AcDbEntity")
           (cons 67 0)
           (cons 8 "0")
           (cons 100 "AcDbText")
           (list 10 0 -2.71428571 0)
           (cons 40 0.25)
           (cons 1 "0.0")
           (cons 50 0)
           (cons 41 1)
           (cons 51 0)
           (cons 7 "Standard")
           (cons 71 0)
           (cons 72 0)
           (list 11 0 0 0)
           (cons 100 "AcDbAttributeDefinition")
           (cons 3 "Base Point 'X'")
           (cons 2 "BX")
           (cons 70 0)
           (cons 73 0)
           (cons 74 0)
          )
         )
         (entmake
          (list
           (cons 0 "ATTDEF")
           (cons 100 "AcDbEntity")
           (cons 67 0)
           (cons 8 "0")
           (cons 100 "AcDbText")
           (list 10 0 -3.11904762 0)
           (cons 40 0.25)
           (cons 1 "0.0")
           (cons 50 0)
           (cons 41 1)
           (cons 51 0)
           (cons 7 "Standard")
           (cons 71 0)
           (cons 72 0)
           (list 11 0 0 0)
           (cons 100 "AcDbAttributeDefinition")
           (cons 3 "Base Point 'Y'")
           (cons 2 "BY")
           (cons 70 0)
           (cons 73 0)
           (cons 74 0)
          )
         )
         (entmake
          (list
           (cons 0 "ATTDEF")
           (cons 100 "AcDbEntity")
           (cons 67 0)
           (cons 8 "0")
           (cons 100 "AcDbText")
           (list 10 0 -3.52380952 0)
           (cons 40 0.25)
           (cons 1 "500.0")
           (cons 50 0)
           (cons 41 1)
           (cons 51 0)
           (cons 7 "Standard")
           (cons 71 0)
           (cons 72 0)
           (list 11 0 0 0)
           (cons 100 "AcDbAttributeDefinition")
           (cons 3 "Grid Width")
           (cons 2 "W")
           (cons 70 0)
           (cons 73 0)
           (cons 74 0)
          )
         )
         (entmake
          (list
           (cons 0 "ATTDEF")
           (cons 100 "AcDbEntity")
           (cons 67 0)
           (cons 8 "0")
           (cons 100 "AcDbText")
           (list 10 0 -3.92857143 0)
           (cons 40 0.25)
           (cons 1 "200.0")
           (cons 50 0)
           (cons 41 1)
           (cons 51 0)
           (cons 7 "Standard")
           (cons 71 0)
           (cons 72 0)
           (list 11 0 0 0)
           (cons 100 "AcDbAttributeDefinition")
           (cons 3 "Grid Height")
           (cons 2 "H")
           (cons 70 0)
           (cons 73 0)
           (cons 74 0)
          )
         )
         (entmake
          (list
           (cons 0 "ATTDEF")
           (cons 100 "AcDbEntity")
           (cons 67 0)
           (cons 8 "0")
           (cons 100 "AcDbText")
           (list 10 0 -4.33333333 0)
           (cons 40 0.25)
           (cons 1 "10.0")
           (cons 50 0)
           (cons 41 1)
           (cons 51 0)
           (cons 7 "Standard")
           (cons 71 0)
           (cons 72 0)
           (list 11 0 0 0)
           (cons 100 "AcDbAttributeDefinition")
           (cons 3 "Vertical Exageration")
           (cons 2 "VEXAG")
           (cons 70 0)
           (cons 73 0)
           (cons 74 0)
          )
         )
         (entmake
          (list
           (cons 0 "ATTDEF")
           (cons 100 "AcDbEntity")
           (cons 67 0)
           (cons 8 "0")
           (cons 100 "AcDbText")
           (list 10 0 -4.73809524 0)
           (cons 40 0.25)
           (cons 1 "2.5")
           (cons 50 0)
           (cons 41 1)
           (cons 51 0)
           (cons 7 "Standard")
           (cons 71 0)
           (cons 72 0)
           (list 11 0 0 0)
           (cons 100 "AcDbAttributeDefinition")
           (cons 3 "Text Height")
           (cons 2 "THEIGHT")
           (cons 70 0)
           (cons 73 0)
           (cons 74 0)
          )
         )
         (entmake
          (list
           (cons 0 "ATTDEF")
           (cons 100 "AcDbEntity")
           (cons 67 0)
           (cons 8 "0")
           (cons 100 "AcDbText")
           (list 10 0 -5.14285714 0)
           (cons 40 0.25)
           (cons 1 "2.5")
           (cons 50 0)
           (cons 41 1)
           (cons 51 0)
           (cons 7 "Standard")
           (cons 71 0)
           (cons 72 0)
           (list 11 0 0 0)
           (cons 100 "AcDbAttributeDefinition")
           (cons 3 "Text Offset")
           (cons 2 "TOFFSET")
           (cons 70 0)
           (cons 73 0)
           (cons 74 0)
          )
         )
         (entmake
          (list
           (cons 0 "ATTDEF")
           (cons 100 "AcDbEntity")
           (cons 67 0)
           (cons 8 "0")
           (cons 100 "AcDbText")
           (list 10 0 -5.54761905 0)
           (cons 40 0.25)
           (cons 1 "100.0")
           (cons 50 0)
           (cons 41 1)
           (cons 51 0)
           (cons 7 "Standard")
           (cons 71 0)
           (cons 72 0)
           (list 11 0 0 0)
           (cons 100 "AcDbAttributeDefinition")
           (cons 3 "Horizontal Grid Spacing")
           (cons 2 "HINC")
           (cons 70 0)
           (cons 73 0)
           (cons 74 0)
          )
         )
         (entmake
          (list
           (cons 0 "ATTDEF")
           (cons 100 "AcDbEntity")
           (cons 67 0)
           (cons 8 "0")
           (cons 100 "AcDbText")
           (list 10 0 -5.95238095 0)
           (cons 40 0.25)
           (cons 1 "20.0")
           (cons 50 0)
           (cons 41 1)
           (cons 51 0)
           (cons 7 "Standard")
           (cons 71 0)
           (cons 72 0)
           (list 11 0 0 0)
           (cons 100 "AcDbAttributeDefinition")
           (cons 3 "Horizontal Fine Grid Spacing")
           (cons 2 "HINCFINE")
           (cons 70 0)
           (cons 73 0)
           (cons 74 0)
          )
         )
         (entmake
          (list
           (cons 0 "ATTDEF")
           (cons 100 "AcDbEntity")
           (cons 67 0)
           (cons 8 "0")
           (cons 100 "AcDbText")
           (list 10 0 -6.35714286 0)
           (cons 40 0.25)
           (cons 1 "100.0")
           (cons 50 0)
           (cons 41 1)
           (cons 51 0)
           (cons 7 "Standard")
           (cons 71 0)
           (cons 72 0)
           (list 11 0 0 0)
           (cons 100 "AcDbAttributeDefinition")
           (cons 3 "Horizontal Grid Text Spacing")
           (cons 2 "HINCTEXT")
           (cons 70 0)
           (cons 73 0)
           (cons 74 0)
          )
         )
         (entmake
          (list
           (cons 0 "ATTDEF")
           (cons 100 "AcDbEntity")
           (cons 67 0)
           (cons 8 "0")
           (cons 100 "AcDbText")
           (list 10 0 -6.76190476 0)
           (cons 40 0.25)
           (cons 1 "10.0")
           (cons 50 0)
           (cons 41 1)
           (cons 51 0)
           (cons 7 "Standard")
           (cons 71 0)
           (cons 72 0)
           (list 11 0 0 0)
           (cons 100 "AcDbAttributeDefinition")
           (cons 3 "Vertical Grid Spacing")
           (cons 2 "VINC")
           (cons 70 0)
           (cons 73 0)
           (cons 74 0)
          )
         )
         (entmake
          (list
           (cons 0 "ATTDEF")
           (cons 100 "AcDbEntity")
           (cons 67 0)
           (cons 8 "0")
           (cons 100 "AcDbText")
           (list 10 0 -7.16666667 0)
           (cons 40 0.25)
           (cons 1 "1.0")
           (cons 50 0)
           (cons 41 1)
           (cons 51 0)
           (cons 7 "Standard")
           (cons 71 0)
           (cons 72 0)
           (list 11 0 0 0)
           (cons 100 "AcDbAttributeDefinition")
           (cons 3 "Vertical Fine Grid Spacing")
           (cons 2 "VINCFINE")
           (cons 70 0)
           (cons 73 0)
           (cons 74 0)
          )
         )
         (entmake
          (list
           (cons 0 "ATTDEF")
           (cons 100 "AcDbEntity")
           (cons 67 0)
           (cons 8 "0")
           (cons 100 "AcDbText")
           (list 10 0 -7.57142857 0)
           (cons 40 0.25)
           (cons 1 "10.0")
           (cons 50 0)
           (cons 41 1)
           (cons 51 0)
           (cons 7 "Standard")
           (cons 71 0)
           (cons 72 0)
           (list 11 0 0 0)
           (cons 100 "AcDbAttributeDefinition")
           (cons 3 "Vertical Grid Text Spacing")
           (cons 2 "VINCTEXT")
           (cons 70 0)
           (cons 73 0)
           (cons 74 0)
          )
         )
         (entmake
          (list
           (cons 0 "ATTDEF")
           (cons 100 "AcDbEntity")
           (cons 67 0)
           (cons 8 "0")
           (cons 100 "AcDbText")
           (list 10 0 -7.97619048 0)
           (cons 40 0.25)
           (cons 1 "PR-GRID")
           (cons 50 0)
           (cons 41 1)
           (cons 51 0)
           (cons 7 "Standard")
           (cons 71 0)
           (cons 72 0)
           (list 11 0 0 0)
           (cons 100 "AcDbAttributeDefinition")
           (cons 3 "Grid Layer")
           (cons 2 "LAY")
           (cons 70 0)
           (cons 73 0)
           (cons 74 0)
          )
         )
         (entmake
          (list
           (cons 0 "ATTDEF")
           (cons 100 "AcDbEntity")
           (cons 67 0)
           (cons 8 "0")
           (cons 100 "AcDbText")
           (list 10 0 -8.38095238 0)
           (cons 40 0.25)
           (cons 1 "PR-GRID-MIN")
           (cons 50 0)
           (cons 41 1)
           (cons 51 0)
           (cons 7 "Standard")
           (cons 71 0)
           (cons 72 0)
           (list 11 0 0 0)
           (cons 100 "AcDbAttributeDefinition")
           (cons 3 "Fine Grid Layer")
           (cons 2 "LAYFINE")
           (cons 70 0)
           (cons 73 0)
           (cons 74 0)
          )
         )
         (entmake
          (list
           (cons 0 "ATTDEF")
           (cons 100 "AcDbEntity")
           (cons 67 0)
           (cons 8 "0")
           (cons 100 "AcDbText")
           (list 10 0 -8.78571429 0)
           (cons 40 0.25)
           (cons 1 "PR-GRID-TXT")
           (cons 50 0)
           (cons 41 1)
           (cons 51 0)
           (cons 7 "Standard")
           (cons 71 0)
           (cons 72 0)
           (list 11 0 0 0)
           (cons 100 "AcDbAttributeDefinition")
           (cons 3 "Text Layer")
           (cons 2 "LAYTEXT")
           (cons 70 0)
           (cons 73 0)
           (cons 74 0)
          )
         )
         (entmake
          (list
           (cons 0 "ATTDEF")
           (cons 100 "AcDbEntity")
           (cons 67 0)
           (cons 8 "0")
           (cons 100 "AcDbText")
           (list 10 0 -9.19047619 0)
           (cons 40 0.25)
           (cons 1 "0")
           (cons 50 0)
           (cons 41 1)
           (cons 51 0)
           (cons 7 "Standard")
           (cons 71 0)
           (cons 72 0)
           (list 11 0 0 0)
           (cons 100 "AcDbAttributeDefinition")
           (cons 3 "Station Text Label Flag (1 = Use '+')")
           (cons 2 "TFLAG")
           (cons 70 0)
           (cons 73 0)
           (cons 74 0)
          )
         )
         (entmake
          (list
           (cons 0 "ATTDEF")
           (cons 100 "AcDbEntity")
           (cons 67 0)
           (cons 8 "0")
           (cons 100 "AcDbText")
           (list 10 0 -9.5952381 0)
           (cons 40 0.25)
           (cons 1 "1.0")
           (cons 50 0)
           (cons 41 1)
           (cons 51 0)
           (cons 7 "Standard")
           (cons 71 0)
           (cons 72 0)
           (list 11 0 0 0)
           (cons 100 "AcDbAttributeDefinition")
           (cons 3 "Master Scale")
           (cons 2 "MASTER")
           (cons 70 0)
           (cons 73 0)
           (cons 74 0)
          )
         )
         (entmake (list (cons 0 "ENDBLK")))
        )
       )
       (T
        (progn
         (alert (strcat "!!! BLOCK DOES NOT EXIST - " BLKNAME " !!!"))
        )
       )
 )
);
;
;     Program written by Robert Livingston 2016-01-12
;
;     DRAWGRID is a utility for drawing a profile/section grid
;
;
(defun C:DEFGRID (/ ACTIVEDOC ACTIVESPC ENT ENTLIST TITLE TITLEHEIGHT TITLEOFFSET BP BX BY W H VEXAG THEIGHT TOFFSET HINC HINCFINE HINCTEXT VINC VINCFINE VINCTEXT LAY LAYFINE LAYTEXT TFLAG MASTER P CODE)
 (setq ACTIVEDOC (vla-get-activedocument (vlax-get-acad-object)))
 (setq ACTIVESPC
       (vlax-get-property ACTIVEDOC
        (if (or (eq acmodelspace (vla-get-activespace ACTIVEDOC)) (eq :vlax-true (vla-get-mspace ACTIVEDOC)))
         'modelspace
         'paperspace
        )
       )
 )
 (if (/= nil (setq ENT (car (entsel))))
  (if (= "INSERT" (cdr (assoc 0 (setq ENTLIST (entget ENT)))))
   (progn
    (setq BP (cdr (assoc 10 ENTLIST)))
    (if (/= nil (setq ENTLIST (cdadr (assoc -3 (entget ENT (list "RFLTOOLS_XENT"))))))
     (if (= (cdar ENTLIST) "RFLTOOLS_DRAWGRID")
      (progn
       (setq ENTLIST (cdr ENTLIST)
             TITLE (cdar ENTLIST)
             ENTLIST (cdr ENTLIST)
             TITLEHEIGHT (cdar ENTLIST)
             ENTLIST (cdr ENTLIST)
             TITLEOFFSET (cdar ENTLIST)
             ENTLIST (cdr ENTLIST)
             BX (cdar ENTLIST)
             ENTLIST (cdr ENTLIST)
             BY (cdar ENTLIST)
             ENTLIST (cdr ENTLIST)
             W (cdar ENTLIST)
             ENTLIST (cdr ENTLIST)
             H (cdar ENTLIST)
             ENTLIST (cdr ENTLIST)
             VEXAG (cdar ENTLIST)
             ENTLIST (cdr ENTLIST)
             THEIGHT (cdar ENTLIST)
             ENTLIST (cdr ENTLIST)
             TOFFSET (cdar ENTLIST)
             ENTLIST (cdr ENTLIST)
             HINC (cdar ENTLIST)
             ENTLIST (cdr ENTLIST)
             HINCFINE (cdar ENTLIST)
             ENTLIST (cdr ENTLIST)
             HINCTEXT (cdar ENTLIST)
             ENTLIST (cdr ENTLIST)
             VINC (cdar ENTLIST)
             ENTLIST (cdr ENTLIST)
             VINCFINE (cdar ENTLIST)
             ENTLIST (cdr ENTLIST)
             VINCTEXT (cdar ENTLIST)
             ENTLIST (cdr ENTLIST)
             LAY (cdar ENTLIST)
             ENTLIST (cdr ENTLIST)
             LAYFINE (cdar ENTLIST)
             ENTLIST (cdr ENTLIST)
             LAYTEXT (cdar ENTLIST)
             ENTLIST (cdr ENTLIST)
             TFLAG (cdar ENTLIST)
             ENTLIST (cdr ENTLIST)
             MASTER (cdar ENTLIST)
       )
       (if (= nil (tblsearch "block" "DrawGridDef"))
        (MAKEENT "DrawGridDef")
       )
       (vla-insertblock ACTIVESPC
                        (vlax-3D-point BP)
                        "DrawGridDef"
                        1.0
                        1.0
                        1.0
                        0.0
       )
       (setq ENT (entlast))
       (setq ENT (entnext ENT))
       (setq ENTLIST (entget ENT))
       (while (= "ATTRIB" (cdr (assoc 0 ENTLIST)))
        (cond ((= (strcase (cdr (assoc 2 ENTLIST))) "TITLE")
               (setq ENTLIST (subst (cons 1 TITLE) (assoc 1 ENTLIST) ENTLIST))
              )
              ((= (strcase (cdr (assoc 2 ENTLIST))) "TITLEHEIGHT")
               (setq ENTLIST (subst (cons 1 (rtos TITLEHEIGHT 2 8)) (assoc 1 ENTLIST) ENTLIST))
              )
              ((= (strcase (cdr (assoc 2 ENTLIST))) "TITLEOFFSET")
               (setq ENTLIST (subst (cons 1 (rtos TITLEOFFSET 2 8)) (assoc 1 ENTLIST) ENTLIST))
              )
              ((= (strcase (cdr (assoc 2 ENTLIST))) "BX")
               (setq ENTLIST (subst (cons 1 (rtos BX 2 8)) (assoc 1 ENTLIST) ENTLIST))
              )
              ((= (strcase (cdr (assoc 2 ENTLIST))) "BY")
               (setq ENTLIST (subst (cons 1 (rtos BY 2 8)) (assoc 1 ENTLIST) ENTLIST))
              )
              ((= (strcase (cdr (assoc 2 ENTLIST))) "W")
               (setq ENTLIST (subst (cons 1 (rtos W 2 8)) (assoc 1 ENTLIST) ENTLIST))
              )
              ((= (strcase (cdr (assoc 2 ENTLIST))) "H")
               (setq ENTLIST (subst (cons 1 (rtos H 2 8)) (assoc 1 ENTLIST) ENTLIST))
              )
              ((= (strcase (cdr (assoc 2 ENTLIST))) "VEXAG")
               (setq ENTLIST (subst (cons 1 (rtos VEXAG 2 8)) (assoc 1 ENTLIST) ENTLIST))
              )
              ((= (strcase (cdr (assoc 2 ENTLIST))) "THEIGHT")
               (setq ENTLIST (subst (cons 1 (rtos THEIGHT 2 8)) (assoc 1 ENTLIST) ENTLIST))
              )
              ((= (strcase (cdr (assoc 2 ENTLIST))) "TOFFSET")
               (setq ENTLIST (subst (cons 1 (rtos TOFFSET 2 8)) (assoc 1 ENTLIST) ENTLIST))
              )
              ((= (strcase (cdr (assoc 2 ENTLIST))) "HINC")
               (setq ENTLIST (subst (cons 1 (rtos HINC 2 8)) (assoc 1 ENTLIST) ENTLIST))
              )
              ((= (strcase (cdr (assoc 2 ENTLIST))) "HINCFINE")
               (setq ENTLIST (subst (cons 1 (rtos HINCFINE 2 8)) (assoc 1 ENTLIST) ENTLIST))
              )
              ((= (strcase (cdr (assoc 2 ENTLIST))) "HINCTEXT")
               (setq ENTLIST (subst (cons 1 (rtos HINCTEXT 2 8)) (assoc 1 ENTLIST) ENTLIST))
              )
              ((= (strcase (cdr (assoc 2 ENTLIST))) "VINC")
               (setq ENTLIST (subst (cons 1 (rtos VINC 2 8)) (assoc 1 ENTLIST) ENTLIST))
              )
              ((= (strcase (cdr (assoc 2 ENTLIST))) "VINCFINE")
               (setq ENTLIST (subst (cons 1 (rtos VINCFINE 2 8)) (assoc 1 ENTLIST) ENTLIST))
              )
              ((= (strcase (cdr (assoc 2 ENTLIST))) "VINCTEXT")
               (setq ENTLIST (subst (cons 1 (rtos VINCTEXT 2 8)) (assoc 1 ENTLIST) ENTLIST))
              )
              ((= (strcase (cdr (assoc 2 ENTLIST))) "LAY")
               (setq ENTLIST (subst (cons 1 LAY) (assoc 1 ENTLIST) ENTLIST))
              )
              ((= (strcase (cdr (assoc 2 ENTLIST))) "LAYFINE")
               (setq ENTLIST (subst (cons 1 LAYFINE) (assoc 1 ENTLIST) ENTLIST))
              )
              ((= (strcase (cdr (assoc 2 ENTLIST))) "LAYTEXT")
               (setq ENTLIST (subst (cons 1 LAYTEXT) (assoc 1 ENTLIST) ENTLIST))
              )
              ((= (strcase (cdr (assoc 2 ENTLIST))) "TFLAG")
               (setq ENTLIST (subst (cons 1 (itoa TFLAG)) (assoc 1 ENTLIST) ENTLIST))
              )
              ((= (strcase (cdr (assoc 2 ENTLIST))) "MASTER")
               (setq ENTLIST (subst (cons 1 (rtos MASTER 2 8)) (assoc 1 ENTLIST) ENTLIST))
              )
        )
        (entmod ENTLIST)
        (entupd ENT)
        (setq ENT (entnext ENT))
        (setq ENTLIST (entget ENT))
       )
      )
     )
    )
   )
  )
 )
)
(defun C:REVGRID (/ ENT ENTLIST TITLE TITLEHEIGHT TITLEOFFSET BP BX BY W H VEXAG THEIGHT TOFFSET HINC HINCFINE HINCTEXT VINC VINCFINE VINCTEXT LAY LAYFINE LAYTEXT TFLAG MASTER P CODE)
 (if (/= nil (setq ENT (car (entsel))))
  (if (= "INSERT" (cdr (assoc 0 (setq ENTLIST (entget ENT)))))
   (progn
    (setq BP (cdr (assoc 10 ENTLIST)))
    (if (/= nil (setq ENTLIST (cdadr (assoc -3 (entget ENT (list "RFLTOOLS_XENT"))))))
     (if (= (cdar ENTLIST) "RFLTOOLS_DRAWGRID")
      (progn
       (setq ENTLIST (cdr ENTLIST)
             TITLE (cdar ENTLIST)
             ENTLIST (cdr ENTLIST)
             TITLEHEIGHT (cdar ENTLIST)
             ENTLIST (cdr ENTLIST)
             TITLEOFFSET (cdar ENTLIST)
             ENTLIST (cdr ENTLIST)
             BX (cdar ENTLIST)
             ENTLIST (cdr ENTLIST)
             BY (cdar ENTLIST)
             ENTLIST (cdr ENTLIST)
             W (cdar ENTLIST)
             ENTLIST (cdr ENTLIST)
             H (cdar ENTLIST)
             ENTLIST (cdr ENTLIST)
             VEXAG (cdar ENTLIST)
             ENTLIST (cdr ENTLIST)
             THEIGHT (cdar ENTLIST)
             ENTLIST (cdr ENTLIST)
             TOFFSET (cdar ENTLIST)
             ENTLIST (cdr ENTLIST)
             HINC (if (= 0.0 (cdar ENTLIST)) nil (cdar ENTLIST))
             ENTLIST (cdr ENTLIST)
             HINCFINE (if (= 0.0 (cdar ENTLIST)) nil (cdar ENTLIST))
             ENTLIST (cdr ENTLIST)
             HINCTEXT (if (= 0.0 (cdar ENTLIST)) nil (cdar ENTLIST))
             ENTLIST (cdr ENTLIST)
             VINC (if (= 0.0 (cdar ENTLIST)) nil (cdar ENTLIST))
             ENTLIST (cdr ENTLIST)
             VINCFINE (if (= 0.0 (cdar ENTLIST)) nil (cdar ENTLIST))
             ENTLIST (cdr ENTLIST)
             VINCTEXT (if (= 0.0 (cdar ENTLIST)) nil (cdar ENTLIST))
             ENTLIST (cdr ENTLIST)
             LAY (cdar ENTLIST)
             ENTLIST (cdr ENTLIST)
             LAYFINE (cdar ENTLIST)
             ENTLIST (cdr ENTLIST)
             LAYTEXT (cdar ENTLIST)
             ENTLIST (cdr ENTLIST)
             TFLAG (if (= 1 (cdar ENTLIST)) T nil)
             ENTLIST (cdr ENTLIST)
             MASTER (cdar ENTLIST)
       )
       (initget 1 "Left Right Bottom Top")
       (setq CODE (getkword "\nModify Left/Right/Bottom/Top : "))
       (setq P (getpoint "\nRevision point : "))
       (cond ((= CODE "Left")
              (if (< (car P) (+ W (car BP)))
               (progn
                (setq W (+ (- (car BP) (car P)) W))
                (setq BX (- BX (- (car BP) (car P))))
                (setq BP (list (car P) (cadr BP)))
               )
              )
             )
             ((= CODE "Right")
              (if (> (car P) (car BP))
               (progn
                (setq W (- (car P) (car BP)))
               )
              )
             )
             ((= CODE "Bottom")
              (if (< (cadr P) (+ H (cadr BP)))
               (progn
                (setq H (+ (- (cadr BP) (cadr P)) H))
                (setq BY (- BY (/ (- (cadr BP) (cadr P)) VEXAG)))
                (setq BP (list (car BP) (cadr P)))
               )
              )
             )
             ((= CODE "Top")
              (if (> (cadr P) (cadr BP))
               (progn
                (setq H (- (cadr P) (cadr BP)))
               )
              )
             )
       )
       (entdel ENT)
       (DRAWGRID TITLE                                                       ; Title Text
                 TITLEHEIGHT                                                 ; Title Height
                 TITLEOFFSET                                                 ; Title OFFSET
                 BP                                                          ; Basepoint
                 BX                                                          ; Base Station
                 BY                                                          ; Base Elevation
                 W                                                           ; Grid Width
                 H                                                           ; Grid Height
                 VEXAG                                                       ; Vertical Exageration
                 THEIGHT                                                     ; Text Height
                 TOFFSET                                                     ; Text OFFSET
                 HINC                                                        ; Horizontal Grid
                 HINCFINE                                                    ; Horizontal Fine Grid
                 HINCTEXT                                                    ; Horizontal Text
                 VINC                                                        ; Vertical Grid
                 VINCFINE                                                    ; Vertical Fine Grid
                 VINCTEXT                                                    ; Vertical Text
                 LAY                                                         ; Grid Layer
                 LAYFINE                                                     ; Fine Grid Layer
                 LAYTEXT                                                     ; Text Layer
                 TFLAG                                                       ; Label as Station
                 MASTER                                                      ; Master Scale
       )
      )
     )
    )
   )
  )
 )
)
(defun C:DRAWGRID (/ ACTIVEDOC ACTIVESPC ENT0 ENT ENTLIST TITLE TITLEHEIGHT TITLEOFFSET BP BX BY W H VEXAG THEIGHT TOFFSET HINC HINCFINE HINCTEXT VINC VINCFINE VINCTEXT LAY LAYFINE LAYTEXT TFLAG MASTER)
 (setq ACTIVEDOC (vla-get-activedocument (vlax-get-acad-object)))
 (setq ACTIVESPC
       (vlax-get-property ACTIVEDOC
        (if (or (eq acmodelspace (vla-get-activespace ACTIVEDOC)) (eq :vlax-true (vla-get-mspace ACTIVEDOC)))
         'modelspace
         'paperspace
        )
       )
 )
 (if (/= nil (setq ENT0 (car (entsel "\nSelect ProfGridDef block (<return> to insert>) : "))))
  (if (and (= "INSERT" (cdr (assoc 0 (setq ENTLIST (entget ENT0)))))
           (= 1 (cdr (assoc 66 ENTLIST)))
      )
   (progn
    (setq BP (cdr (assoc 10 ENTLIST)))
    (setq TITLE nil
          TITLEHEIGHT nil
          TITLEOFFSET nil
          BX nil
          BY nil
          W nil
          H nil
          VEXAG nil
          THEIGHT nil
          TOFFSET nil
          HINC nil
          HINCFINE nil
          HINCTEXT nil
          VINC nil
          VINCFINE nil
          VINCTEXT nil
          LAY nil
          LAYFINE nil
          LAYTEXT nil
          TFLAG nil
          MASTER 1.0
    )
    (setq ENT (entnext ENT0))
    (setq ENTLIST (entget ENT))
    (while (= (cdr (assoc 0 ENTLIST)) "ATTRIB")
     (cond ((= (strcase (cdr (assoc 2 ENTLIST))) "MASTER")
            (setq MASTER (atof (cdr (assoc 1 ENTLIST))))
           )
     )
     (setq ENT (entnext ENT))
     (setq ENTLIST (entget ENT))
    )
    (setq ENT (entnext ENT0))
    (setq ENTLIST (entget ENT))
    (while (= (cdr (assoc 0 ENTLIST)) "ATTRIB")
     (cond ((= (strcase (cdr (assoc 2 ENTLIST))) "TITLE")
            (setq TITLE (cdr (assoc 1 ENTLIST)))
           )
           ((= (strcase (cdr (assoc 2 ENTLIST))) "TITLEHEIGHT")
            (setq TITLEHEIGHT (* MASTER (atof (cdr (assoc 1 ENTLIST)))))
           )
           ((= (strcase (cdr (assoc 2 ENTLIST))) "TITLEOFFSET")
            (setq TITLEOFFSET (* MASTER (atof (cdr (assoc 1 ENTLIST)))))
           )
           ((= (strcase (cdr (assoc 2 ENTLIST))) "BX")
            (setq BX (atof (cdr (assoc 1 ENTLIST))))
           )
           ((= (strcase (cdr (assoc 2 ENTLIST))) "BY")
            (setq BY (atof (cdr (assoc 1 ENTLIST))))
           )
           ((= (strcase (cdr (assoc 2 ENTLIST))) "W")
            (setq W (atof (cdr (assoc 1 ENTLIST))))
           )
           ((= (strcase (cdr (assoc 2 ENTLIST))) "H")
            (setq H (atof (cdr (assoc 1 ENTLIST))))
           )
           ((= (strcase (cdr (assoc 2 ENTLIST))) "VEXAG")
            (setq VEXAG (atof (cdr (assoc 1 ENTLIST))))
           )
           ((= (strcase (cdr (assoc 2 ENTLIST))) "THEIGHT")
            (setq THEIGHT (* MASTER (atof (cdr (assoc 1 ENTLIST)))))
           )
           ((= (strcase (cdr (assoc 2 ENTLIST))) "TOFFSET")
            (setq TOFFSET (* MASTER (atof (cdr (assoc 1 ENTLIST)))))
           )
           ((= (strcase (cdr (assoc 2 ENTLIST))) "HINC")
            (setq HINC (* MASTER (atof (cdr (assoc 1 ENTLIST)))))
           )
           ((= (strcase (cdr (assoc 2 ENTLIST))) "HINCFINE")
            (setq HINCFINE (* MASTER (atof (cdr (assoc 1 ENTLIST)))))
           )
           ((= (strcase (cdr (assoc 2 ENTLIST))) "HINCTEXT")
            (setq HINCTEXT (* MASTER (atof (cdr (assoc 1 ENTLIST)))))
           )
           ((= (strcase (cdr (assoc 2 ENTLIST))) "VINC")
            (setq VINC (* MASTER (atof (cdr (assoc 1 ENTLIST)))))
           )
           ((= (strcase (cdr (assoc 2 ENTLIST))) "VINCFINE")
            (setq VINCFINE (* MASTER (atof (cdr (assoc 1 ENTLIST)))))
           )
           ((= (strcase (cdr (assoc 2 ENTLIST))) "VINCTEXT")
            (setq VINCTEXT (* MASTER (atof (cdr (assoc 1 ENTLIST)))))
           )
           ((= (strcase (cdr (assoc 2 ENTLIST))) "LAY")
            (setq LAY (cdr (assoc 1 ENTLIST)))
           )
           ((= (strcase (cdr (assoc 2 ENTLIST))) "LAYFINE")
            (setq LAYFINE (cdr (assoc 1 ENTLIST)))
           )
           ((= (strcase (cdr (assoc 2 ENTLIST))) "LAYTEXT")
            (setq LAYTEXT (cdr (assoc 1 ENTLIST)))
           )
           ((= (strcase (cdr (assoc 2 ENTLIST))) "TFLAG")
            (setq TFLAG (if (= (cdr (assoc 1 ENTLIST)) "1") T nil))
           )
     )
     (setq ENT (entnext ENT))
     (setq ENTLIST (entget ENT))
    )
    (if (= VINC 0.0) (setq VINC nil))
    (if (= VINCFINE 0.0) (setq VINCFINE nil))
    (if (= VINCTEXT 0.0) (setq VINCTEXT nil))
    (if (= HINC 0.0) (setq HINC nil))
    (if (= HINCFINE 0.0) (setq HINCFINE nil))
    (if (= HINCTEXT 0.0) (setq HINCTEXT nil))
    (if (= LAY "") (setq LAY (getvar "CLAYER")))
    (if (= LAYFINE "") (setq LAYFINE (getvar "CLAYER")))
    (if (= LAYTEXT "") (setq LAYTEXT (getvar "CLAYER")))
    (DRAWGRID TITLE                                                       ; Title Text
              TITLEHEIGHT                                                 ; Title Height
              TITLEOFFSET                                                 ; Title OFFSET
              BP                                                          ; Basepoint
              BX                                                          ; Base Station
              BY                                                          ; Base Elevation
              W                                                           ; Grid Width
              H                                                           ; Grid Height
              VEXAG                                                       ; Vertical Exageration
              THEIGHT                                                     ; Text Height
              TOFFSET                                                     ; Text OFFSET
              HINC                                                        ; Horizontal Grid
              HINCFINE                                                    ; Horizontal Fine Grid
              HINCTEXT                                                    ; Horizontal Text
              VINC                                                        ; Vertical Grid
              VINCFINE                                                    ; Vertical Fine Grid
              VINCTEXT                                                    ; Vertical Text
              LAY                                                         ; Grid Layer
              LAYFINE                                                     ; Fine Grid Layer
              LAYTEXT                                                     ; Text Layer
              TFLAG                                                       ; Label as Station
              MASTER                                                      ; Master Scale
    )
   )
  )
  (progn
   (if (= nil (tblsearch "block" "DrawGridDef"))
    (MAKEENT "DrawGridDef")
   )
   (setq P (getpoint "\nInsertion point for DrawGridDef block : "))
   (vla-insertblock ACTIVESPC
                    (vlax-3D-point P)
                    "DrawGridDef"
                    1.0
                    1.0
                    1.0
                    0.0
   )
  )
 )
)
(defun DRAWGRID (TITLE TITLEHEIGHT TITLEOFFSET BP BX BY W H VEXAG THEIGHT TOFFSET HINC HINCFINE HINCTEXT VINC VINCFINE VINCTEXT LAY LAYFINE LAYTEXT TFLAG MASTER
                 /
                 BPX BPY CFIX+ DIMZIN ENTLIST ENTLISTALL MOD NODE STA TMP TOL X X1 X2 Y Y1 Y2 Z
                )
 (vl-load-com)
 (regapp "RFLTOOLS_XENT")
 (defun MOD (A B)
  (rem (+ (rem A B) B) B)
 )
 (defun CFIX+ (ENTLIST / CODE P P0 STR TB TB1 TB2 W WL WR)
  (if (= "TEXT" (cdr (assoc 0 ENTLIST)))
   (if (/= nil (vl-string-search "+" (setq STR (cdr (assoc 1 ENTLIST)))))
    (progn
     (if (or (/= 0 (cdr (assoc 72 ENTLIST))) (/= 0 (cdr (assoc 73 ENTLIST))))
      (setq CODE 11)
      (setq CODE 10)
     )
     (setq P (cdr (assoc CODE ENTLIST)))
     (setq P0 (cdr (assoc 10 ENTLIST)))
     (setq TB (textbox ENTLIST))
     (setq W (- (caadr TB) (caar TB)))
     (setq TBL (textbox (subst (cons 1 (substr STR 1 (+ (vl-string-search "+" STR) 1))) (assoc 1 ENTLIST) ENTLIST)))
     (setq WL (- (caadr TBL) (caar TBL)))
     (setq TBR (textbox (subst (cons 1 (substr STR (+ (vl-string-search "+" STR) 1))) (assoc 1 ENTLIST) ENTLIST)))
     (setq WR (- (caadr TBR) (caar TBR)))
     (setq W+ (- (+ WR WL) W))
     (setq ENTLIST (subst (list CODE
                                (- (+ (car P) (- (car P) (car P0))) (- WL (/ W+ 2.0)) (caar TBL))
                                (cadr P)
                                (caddr P)
                          )
                          (assoc CODE ENTLIST)
                          ENTLIST
                   )
     )
    )
   )
  )
  ENTLIST
 )
 (setq TOL 0.000001)
 (setq DIMZIN (getvar "DIMZIN"))
 (setvar "DIMZIN" 8)
 (setq BPX (car BP))
 (setq BPY (cadr BP))
 
 (setq ENTLISTALL (list (list (cons 0 "BLOCK")
                              (cons 2 "*U")
                              (cons 8 "0")
                              (cons 70 1)
                              (list 10 0.0 0.0 0.0)
                        )
                  )
 )
 ; Horizontal Lines - Fine
 (if (/= nil VINCFINE)
  (progn
   (setq X1 0.0 X2 W)
   (setq Y (* (- VINCFINE (MOD BY VINCFINE)) VEXAG))
   (if (= Y (* VINCFINE VEXAG)) (setq Y 0.0))
   (while (<= Y H)
    (setq ENTLIST (list (cons 0 "LINE")
                        (cons 8 LAYFINE)
                        (list 10 X1 Y 0.0)
                        (list 11 X2 Y 0.0)
                  )
    )
    (setq ENTLISTALL (append ENTLISTALL (list ENTLIST)))
    (setq Y (+ Y (* VINCFINE VEXAG)))
   )
  )
 )
 ; Horizontal Lines
 (if (/= nil VINC)
  (progn
   (setq X1 0.0 X2 W)
   (setq Y (* (- VINC (MOD BY VINC)) VEXAG))
   (if (= Y (* VINC VEXAG)) (setq Y 0.0))
   (while (<= Y H)
    (setq ENTLIST (list (cons 0 "LINE")
                        (cons 8 LAY)
                        (list 10 X1 Y 0.0)
                        (list 11 X2 Y 0.0)
                  )
    )
    (setq ENTLISTALL (append ENTLISTALL (list ENTLIST)))
    (setq Y (+ Y (* VINC VEXAG)))
   )
  )
 )
 ; Vertical Lines - Fine
 (if (/= nil HINCFINE)
  (progn
   (setq Y1 0.0 Y2 H)
   (setq X (- HINCFINE (MOD BX HINCFINE)))
   (if (= X HINCFINE) (setq X 0.0))
   (while (<= X W)
    (setq ENTLIST (list (cons 0 "LINE")
                        (cons 8 LAYFINE)
                        (list 10 X Y1 0.0)
                        (list 11 X Y2 0.0)
                  )
    )
    (setq ENTLISTALL (append ENTLISTALL (list ENTLIST)))
    (setq X (+ X HINCFINE))
   )
  )
 )
 ; Vertical Lines
 (if (/= nil HINC)
  (progn
   (setq Y1 0.0 Y2 H)
   (setq X (- HINC (MOD BX HINC)))
   (if (= X HINC) (setq X 0.0))
   (while (<= X W)
    (setq ENTLIST (list (cons 0 "LINE")
                        (cons 8 LAY)
                        (list 10 X Y1 0.0)
                        (list 11 X Y2 0.0)
                  )
    )
    (setq ENTLISTALL (append ENTLISTALL (list ENTLIST)))
    (setq X (+ X HINC))
   )
  )
 )
 ; Horizontal Text
 (if (/= nil HINCTEXT)
  (progn
   (setq Y 0.0)
   (setq X (- HINCTEXT (MOD BX HINCTEXT)))
   (if (= X HINCTEXT) (setq X 0.0))
   (while (<= X W)
    (setq STA (+ X BX))
    (if TFLAG
     (progn
      (setq ENTLIST (list (cons 0 "TEXT")
                          (cons 1 (RFLSTATXT STA))
                          (cons 7 "STANDARD")
                          (cons 8 LAYTEXT)
                          (list 10 X (- Y TOFFSET THEIGHT) 0.0)
                          (cons 40 THEIGHT)
                          (cons 50 0.0)
                          (cons 71 0)
                          (cons 72 0)
                          (cons 73 0)
                    )
      )
      (setq ENTLIST (CFIX+ ENTLIST))
     )
     (progn
      (setq ENTLIST (list (cons 0 "TEXT")
                          (cons 1 (rtos STA))
                          (cons 7 "STANDARD")
                          (cons 8 LAYTEXT)
                          (list 10 X (- Y TOFFSET THEIGHT) 0.0)
                          (list 11 X (- Y TOFFSET THEIGHT) 0.0)
                          (cons 40 THEIGHT)
                          (cons 50 0.0)
                          (cons 71 0)
                          (cons 72 1)
                          (cons 73 0)
                    )
      )
     )
    )
    (setq ENTLISTALL (append ENTLISTALL (list ENTLIST)))
    (setq X (+ X HINCTEXT))
   )
  )
 )
 ; Vertical Text
 (if (/= nil VINCTEXT)
  (progn
   (setq X1 0.0 X2 W)
   (setq Y (* (- VINCTEXT (MOD BY VINCTEXT)) VEXAG))
   (if (= Y (* VINCTEXT VEXAG)) (setq Y 0.0))
   (while (<= Y H)
    (setq Z (+ (/ Y VEXAG) BY))
    (setq ENTLIST (list (cons 0 "TEXT")
                        (cons 1 (rtos Z))
                        (cons 7 "STANDARD")
                        (cons 8 LAYTEXT)
                        (list 10 (- X1 TOFFSET) Y 0.0)
                        (list 11 (- X1 TOFFSET) Y 0.0)
                        (cons 40 THEIGHT)
                        (cons 50 0.0)
                        (cons 71 0)
                        (cons 72 2)
                        (cons 73 2)
                  )
    )
    (setq ENTLISTALL (append ENTLISTALL (list ENTLIST)))
    (setq ENTLIST (list (cons 0 "TEXT")
                        (cons 1 (rtos Z))
                        (cons 7 "STANDARD")
                        (cons 8 LAYTEXT)
                        (list 10 (+ X2 TOFFSET) Y 0.0)
                        (list 11 (+ X2 TOFFSET) Y 0.0)
                        (cons 40 THEIGHT)
                        (cons 50 0.0)
                        (cons 71 0)
                        (cons 72 0)
                        (cons 73 2)
                  )
    )
    (setq ENTLISTALL (append ENTLISTALL (list ENTLIST)))
    (setq Y (+ Y (* VINCTEXT VEXAG)))
   )
  )
 )
 ; Title Text
 (if (/= "" TITLE)
  (progn
   (setq X (/ W 2.0))
   (setq Y (+ H TITLEOFFSET))
   (setq ENTLIST (list (cons 0 "TEXT")
                       (cons 1 TITLE)
                       (cons 7 "STANDARD")
                       (cons 8 LAYTEXT)
                       (list 10 X Y 0.0)
                       (list 11 X Y 0.0)
                       (cons 40 TITLEHEIGHT)
                       (cons 50 0.0)
                       (cons 71 0)
                       (cons 72 1)
                       (cons 73 0)
                 )
   )
   (setq ENTLISTALL (append ENTLISTALL (list ENTLIST)))
  )
 )
 (setq ENTLISTALL (append ENTLISTALL (list (list (cons 0 "ENDBLK")))))
 (foreach NODE ENTLISTALL
  (progn
   (setq TMP (entmake NODE))
  )
 )
 (entmake (list (cons 0 "INSERT")
                (cons 2 TMP)
                (list 10 BPX BPY 0.0)
                (cons 41 1.0)
                (cons 42 1.0)
                (cons 43 1.0)
                (cons 50 0.0)
          )
 )
 (setvar "DIMZIN" DIMZIN)
 (setq ENT (entlast))
 (setq ENTLIST (append (entget ENT)
                       (list
                             (list -3 
                                   (list "RFLTOOLS_XENT"
                                         (cons 1000 "RFLTOOLS_DRAWGRID")
                                         (cons 1000 TITLE)
                                         (cons 1040 TITLEHEIGHT)
                                         (cons 1040 TITLEOFFSET)
                                         (cons 1040 BX)
                                         (cons 1040 BY)
                                         (cons 1040 W)
                                         (cons 1040 H)
                                         (cons 1040 VEXAG)
                                         (cons 1040 THEIGHT)
                                         (cons 1040 TOFFSET)
                                         (cons 1040 (if HINC HINC 0.0))
                                         (cons 1040 (if HINCFINE HINCFINE 0.0))
                                         (cons 1040 (if HINCTEXT HINCTEXT 0.0))
                                         (cons 1040 (if VINC VINC 0.0))
                                         (cons 1040 (if VINCFINE VINCFINE 0.0))
                                         (cons 1040 (if VINCTEXT VINCTEXT 0.0))
                                         (cons 1000 LAY)
                                         (cons 1000 LAYFINE)
                                         (cons 1000 LAYTEXT)
                                         (cons 1070 (if TFLAG 1 0))
                                         (cons 1040 MASTER)
                                   )
                             )
                       )
               )
 )
 (entmod ENTLIST)
 (entlast)
)

 

Extra code (What i want to do)

 

  (command "_layer" "_m" "CL" "_c" "240" "" "") ; new layer for the drawing line
; position of the new line
  (setq BYH (+ BY H))
  (setq point1 (list 0 BY 0)) 
  (setq point2 (list 0 BYH 0)) 
  (command "line" point1 point2 "") ; Draw the new line  
; Layer CL on top
  (if (setq ss (ssget "_x" '((8 . "CL"))))
  (command "._draworder" ss "" "_f")  

 

I dont know if is any better way to do this ?

 

Thanks

 

 

Edited by prodromosm
Posted

Probably the easiest thing to do is to refedit the block after its made and add the line to it.

Posted

The problem is when i select the grid block and then Block edit.......... this block is not in the list. I have to explode it .Thats why i want to add this line in to  the block from the begining

Posted

This is do grid in a layout based on a twisted view.ucs handy for roads that curve. Cost is beer money.

 

 

Draw gid in layout.gif

Posted

Hi Bigal. I have grid for Layouts. This Grid is  ask for modification is for cross sections

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.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...