Im pretty green at lisp and I am trying to do something I have never done and have wasted 2 days trying to figure it out.
the routine I am putting together should label the x axis along the bottom of a rectangle and label the y axis along the left side (eventually around the whole rectanagle). I got it to place the the text and tick at the first locations but am unable to figure out how to get it to count and continue to label.
I need to create a loop that will add a users entered value "gs" and repeat the code as long as "resultx" is less then p2x and "resulty" is less than "p2y" but controlled separately, so it will run the x direction until condition is met then run in the y direction.
here is the code I have so far.
thanks for any help.
Code:
(defun C:STPLN (/ p1 p2); [localize more variables?]
;establish the start points for grid
(setq
p1 (getpoint "\nPick bottom left corner:...") ;First point
p1x (car p1) ;X value of bottom left corner
p1y (cadr p1) ;Y value of bottom left corner
p2 (getpoint "\nPick top right corner:...") ;Second point
p2x (car p1) ;X value of top right corner
p2y (cadr p1) ;Y value of top right corner
gs (getint "\nWhat is the grid spacing? ") ;user enters grid spacing
remainderx (rem p1x gs) ; remainder of dividing value by roundfactor
multiplierx
(if (zerop remainderx) ;if it divides exactly
(fix (/ p1x gs)) ;then; keep that quotient
(1+ (fix (/ p1x gs))) ;else, add 1 to rounded-down quotient
) ;end if & multiplier
resultx (* gs multiplierx)
xx (list resultx p1y) ;create coord for start point of grid in the x
remaindery (rem p1y gs) ;remainder of dividing value by roundfactor
multipliery
(if (zerop remaindery) ;if it divides exactly
(fix (/ p1y gs)) ;then; keep that quotient
(1+ (fix (/ p1y gs))) ;else, add 1 to rounded-down quotient
) ;end if & multiplier
resulty (* gs multipliery)
yy (list p1x resulty) ;create coord for start point of grid in the y
) ;end setq
;;;;begin text and tick location.
(setq t1 "Text Height: <default = ")
(setq t2 " >: ")
(setq t3 (getvar "textsize"))
(setq ht (getreal (strcat t1 (rtos t3 2 2) t2)))
(if (= ht nil)
(setq ht t3)
)
(setvar "textsize" ht)
(setq a "N. ")
(setq b "E. ")
(setq n (rtos (cadr yy) 2 0))
(setq e (rtos (car xx) 2 0))
(setq coord (strcat a n))
(setq coord2 (strcat b e))
(setq
x1 (car xx) ;gets x coord of starting location in the x
y1 (cadr xx) ;gets y coord of starting location in the x
xx1 (car yy) ;gets x coord of starting location in the y
yy1 (cadr yy) ;gets y coord of starting location in the y
ht (getvar "TEXTSIZE")
x2 (- x1 (* ht 0.0)) ;offset in the x
xx2 (+ xx1 (* ht 1.75)) ;offset in the y
y2 (- y1 (* ht -1.75)) ;offset in the x
yy2 (- yy1 (* ht 0.00)) ;offset in the y
pt2 (list x2 y2) ;placemnet location for text in the x
ppt2 (list xx2 yy2) ;placemnet location for text in the y
x2 (- x1 (* ht -0.00)) ;starting location of tick in the x
xx2 (+ xx1 (* ht 1.00)) ;starting location of tick in the y
y2 (+ y1 (* ht 1.00)) ;ending location of tick in the x
yy2 (+ yy1 (* ht 0.00)) ;ending location of tick in the x
p2 (list x2 y2) ;placemnet location for tick in the x
pp2 (list xx2 yy2) ;placemnet location for tick in the y
)
;;;end text and tick location
;;;begin plan tick location
(setq
tickx1 (- resulty (/ t3 2)) ;start verticle tick line x
tickx2 (+ resulty (/ t3 2)) ;end verticle tick line in the x
tickbase1 (list resultx tickx1)
tickbase2 (list resultx tickx2)
ticky1 (- resultx (/ t3 2)) ;start horizontal tick line y
ticky2 (+ resultx (/ t3 2)) ;end horizontal tick line in the y
tickbase3 (list ticky1 resulty)
tickbase4 (list ticky2 resulty)
)
;;;end plan tick location
(command "text" "mC" pt2 "" "0" coord2 ) ;place starting text in the x
(command "pline" xx p2 "") ;place starting tick in the x
(command "text" "mC" ppt2 "" "90" coord ) ;place starting text in the y
(command "pline" yy pp2 "") ;place starting tick in the y
(command "pline" tickbase1 tickbase2 "") ;draw starting verticle tick line
(command "pline" tickbase3 tickbase4 "") ;draw starting horizontal tick line
;(while
; (or
; (< reslutx p2x)
; (< resluty p2y)
; )
(if (< reslutx p2x)
(progn
(setq resultx (list (+ gs (car xx) p1y)))
(command "text" "mC" pt2 "" "0" coord2 ) ;place starting text in the x
(command "pline" xx p2 "") ;place starting tick in the x
(command "pline" tickbase1 tickbase2 "") ;draw starting verticle tick line
)
)
; (if (< resluty p2y)
; (progn
; (setq resulty (list p1x (+ gs resulty))
; (command "pline" yy pp2 "") ;place starting tick in the y
; (command "pline" tickbase1 tickbase2 "") ;draw starting verticle tick line
; (command "pline" tickbase3 tickbase4 "") ;draw starting horizontal tick line
; )
; )
;)
)
(princ)