Results 1 to 8 of 8

Thread: Grid

  1. #1
    Member
    Join Date
    2017-10
    Posts
    10
    Login to Give a bone
    0

    Default Grid

    Hello everyone
    Please I need a help with this lisp routine
    1-I like to put a default value for "Grid Spacing" user input
    2-I like to put thousands commas in grid labeling
    Thanks a lot
    Code:
    (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")
    Last edited by Wanderer; 2018-05-28 at 03:50 PM. Reason: added code tags

  2. #2
    I could stop if I wanted to
    Join Date
    2003-07
    Posts
    326
    Login to Give a bone
    0

    Default Re: Grid

    A very simple default answer

    Code:
    (setq askw 100)
    (princ "\nWidth of window :<")(princ width)
    (setq askw (getint "> : "))
    (if (/= askw nil)(setq width askw))

  3. #3
    Certifiable AUGI Addict
    Join Date
    2001-03
    Location
    Tallahassee, FL
    Posts
    3,114
    Login to Give a bone
    0

    Default Re: Grid

    You need to localize all the variables other than GridSpacing and TextHeigth then making the rest more descriptive would make it easier to follow.
    For #1 use GridSpacing instead of d and TextHeigth instead of ss:
    Code:
    (if (= GridSpacing nil)(setq GridSpacing 100))
    (setq GridSpacing (getint (strcat "\nWidth of window :<" (itoa GridSpacing) ">")))
    (if (= TextHeigth nil)(setq TextHeigth 1.0))
    (setq TextHeigth (getint (strcat "\nHeigth of Text :<" (atof TextHeigth) ">")))
    Tom Beauford P.S.M. - Civil 2019 on Windows 10 Enterprise
    Design Analysis - Leon County Public Works/Engineering Wrap [CODE] tags around selected text
    2280 Miccosukee Rd. Tallahassee, FL 32308-5310
    Ph# (850)606-1516 Home Page

  4. #4
    Member
    Join Date
    2017-10
    Posts
    10
    Login to Give a bone
    0

    Default Re: Grid

    Hi
    Thanks a lot,I'l give it a try...

    - - - Updated - - -

    Hi
    Thanks a lot,I'l give it a try...

    - - - Updated - - -

    Hi
    Thanks a lot,I'l give it a try...

  5. #5
    Member
    Join Date
    2017-10
    Posts
    10
    Login to Give a bone
    0

    Default Re: Grid

    Hello
    I've tried your code.I replaced my two lines beginning with "(setq d...",with your code and I received the error :bad argument type:stringp 75...(75 is my TextHeight) What's wrong please...Thanks again

    - - - Updated - - -

    Hello
    I've tried your code.I replaced my two lines beginning with "(setq d...",with your code and I received the error :bad argument type:numberp : nil.What's wrong please...Thanks again

  6. #6
    Certifiable AUGI Addict
    Join Date
    2001-03
    Location
    Tallahassee, FL
    Posts
    3,114
    Login to Give a bone
    0

    Default Re: Grid

    Quote Originally Posted by RamiMann View Post
    Hello
    I've tried your code.I replaced my two lines beginning with "(setq d...",with your code and I received the error :bad argument type:stringp 75...(75 is my TextHeight) What's wrong please...Thanks again

    - - - Updated - - -

    Hello
    I've tried your code.I replaced my two lines beginning with "(setq d...",with your code and I received the error :bad argument type:numberp : nil.What's wrong please...Thanks again
    From your code:
    Code:
     (setq d (getdist "\nENTER GRID SPACING:"))
     (setq ss (getdist "\nENTER HEIGHT OF TEXT:"))
    I guessed d GRID SPACING to be an integer and ss (generally used for a Selection Set) HEIGHT OF TEXT to be a real.

    Hard to follow what you're trying to do here. Especially since GRID is built into AutoCAD and can easily be set up as either lines with/without Major grid lines or dots.
    Tom Beauford P.S.M. - Civil 2019 on Windows 10 Enterprise
    Design Analysis - Leon County Public Works/Engineering Wrap [CODE] tags around selected text
    2280 Miccosukee Rd. Tallahassee, FL 32308-5310
    Ph# (850)606-1516 Home Page

  7. #7
    Member
    Join Date
    2017-10
    Posts
    10
    Login to Give a bone
    0

    Default Re: Grid

    Hi
    Thanks for your concern.You're right I had to use more meaningful variables.This lisp is to draw a grid with Coordinates all around,for maps production.If you try it you'll know what I need :A default value for grid spacing (e.g. often 1000) instead of entering it every time...and the commas between thousands for facilitating reading coordinates...Gracias

  8. #8
    I could stop if I wanted to
    Join Date
    2003-07
    Posts
    326
    Login to Give a bone
    0

    Default Re: Grid

    Do some searching there are numerous grid lisp programs out there and have different ways of labeling I know have posted a couple.

Similar Threads

  1. 2014: Ceiling Grid without tiles, just the grid
    By Spark Yunker in forum Revit Architecture - General
    Replies: 5
    Last Post: 2013-11-26, 03:04 PM
  2. Gap Between Grid Head and Grid Line
    By brent.130528 in forum Revit Architecture - General
    Replies: 3
    Last Post: 2009-08-21, 02:24 PM
  3. Construction Grid Lines and Grid Dimensions..angles columns
    By persianize in forum Revit - Student Support
    Replies: 0
    Last Post: 2009-01-02, 10:52 AM
  4. Hide Grid Bubbles, but not Grid Lines
    By brethomp in forum Revit Architecture - General
    Replies: 5
    Last Post: 2007-05-08, 07:46 PM
  5. Grid Head / Grid lines on separate export layer
    By Griff in forum Revit Architecture - General
    Replies: 1
    Last Post: 2004-02-10, 10:02 PM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •