My comments with three ;'s
(defun GETVALUE (VAL SIDE / PRMPT INIT INQUIRY)
(if (and (numberp VAL) (> VAL 0.0)) ;<- If 'val' is a real number and greater than 0, continue
;;; ^correct in your comment
(setq PRMPT
(strcat "Specify " SIDE " yard setback <" (rtos VAL) ">: ")
;<- Prompts for 'side' setbacks, and shows the current setbacks
;;; ^correct in your comment
INIT 6
)
(setq PRMPT (strcat "Specify " SIDE " yard setback: ")
; <- same as above i believe, but I dont really understand this
;;; Remember that VAL comes directly from an attempt to retrieve a value
;;; from the configuration. Therefore VAL will be an empty string ("") if
;;; no such value is found - meaning that IF will go here. Not having a
;;; default value to offer, you would like to NOT have the brackets in the
;;; prompt and you would like the user to input a value (hence INITGET of
;;; 7 that will prohibit a null response).
INIT 7
)
)
(initget INIT) ; gets the number supllied above
;;; ^correct in your comment
(if (setq INQUIRY (getdist PRMPT)) ; sets 'inquiry' to the distance from 'prmpt'
;;; ^correct in your comment
(setq VAL INQUIRY) ; sets val to distance recieved from last line
;;; ^correct in your comment - if INQUIRY returns a number,
;;; otherwise VAL is still equal to VAL, i.e. the default value
)
VAL ; returns val?
;;; ^correct in your comment
)
(defun OFFSETOBJECT (OFFDIST OFFPT SIDE SS / ENT LASTENT)
(if (not SS)
(setq SS (ssadd))
) ; if selection set is not named 'ss' then add items to 'ss'
;;; ^not correct in your comment. SSADD without arguments creates an empty
;;; selection set, making it possible to add entities to it later. You might
;;; say that this initializes a selection set ready for use.
(setvar "ERRNO" 0) ; beyond lost here
;;; the sysvar ERRNO does not necessarily get reset after last error. This
;;; means that ERRNO could hold the value 52 from any time during previous
;;; work in the drawing. It's reset here to 0, so that the loop below works.
(while
(and (setq ENT (car (entsel (strcat "\nSelect " SIDE " lot lines: "))))
; prompts to select current side lot lines,
; returns entname w/ car set that entity to
; ent and gets errno and continues if errno
; not equal to 52
;;; ^correct in your comment
(/= (getvar "ERRNO") 52) ; no clue
;;; sysvar ERRNO will be set (automatically by AutoCAD) to 52 if entity
;;; selecting with ENTSEL fails. This gives you a chance to exit the loop
;;; by simply hitting space (or clicking in empty drawing area which should
;;; not happen, but you can play with that particular case :)
)
(setq LASTENT (entlast)) ; reselects the last entity selected/added
;;; No, saves the last entity added
(command ".OFFSET" OFFDIST ENT OFFPT "") ; offsets
;;; ^correct in your comment
(cond ((not (eq LASTENT (entlast))); if entity does not equal last ent, continue
(ssadd (entlast) SS) ; adds new entity to ss
;;; ^correct in both comments
)
)
)
(if (< 0 (sslength SS))
SS
) ; if 0 is less than the # of ents in ss, continue
;;; simply meaning if there are entities in the selection set then return it,
;;; otherwise return nil (if will fail and return nil)
)
;; Main function
(defun C:SB (/ FRONTOFF SIDEOFF REAROFF USERLAY
USERCMD USEROSM USERFILL OSP TMP
SSET ENT LASTENT MYPROMPT *ERROR*
)
(defun *ERROR* (MSG)
(if MSG
(princ (strcat "Rugaroo made an error: " MSG))
) ; lost again
(foreach VAR '(("clayer" USERLAY)
("cmdecho" USERCMD) ; for each variable, set uservars
("orthomode" USERORTH)
("osmode" USEROSM)
("filletrad" USERFILL)
)
(if (eval (cadr VAR)) ; if each uservar evaluate the 2nd item is present
(setvar (car VAR) (eval (cadr VAR)))
; like doing setvar "clayer" "something", and so on with all uservars in var
;;; ^correct. Because variables are provided in a quoted list, they will have
;;; to be "ripped open" to read the value they hold. EVAL does this.
)
)
(princ)
)
(setq USERLAY (getvar "clayer")
USERCMD (getvar "cmdecho")
USERORTH (getvar "orthomode")
USEROSM (getvar "osmode")
USERFILL (getvar "filletrad")
)
(setvar "cmdecho" 0)
(setvar "orthomode" 0)
(setvar "filletrad" 0)
(setq FRONTOFF (distof (getcfg "AppData/Setbacks/Front"))
; sets frontoff to a corresponding integer corresponding w/ users lunits
SIDEOFF (distof (getcfg "AppData/Setbacks/Side")) ; same
REAROFF (distof (getcfg "AppData/Setbacks/Rear")) ; same
)
(setq FRONTOFF (GETVALUE FRONTOFF "Front") ; kind of confused here
;;; As Daron mentioned, look at the GetValue arguments and see what it does.
;;; It simply returns a value based in user input (user's value or default value)
SIDEOFF (GETVALUE SIDEOFF "Side")
REAROFF (GETVALUE REAROFF "Rear")
)
(cond ((and FRONTOFF
SIDEOFF
REAROFF
(setq OSP (getpoint "\nPick the center of the lot: "))
; as long as f.off, s.off, r.off are present continue, but if not an error?
)
;;; ^Exactemento
(setcfg "AppData/Setbacks/Front" (rtos FRONTOFF))
; places the setbacks into our config file
(setcfg "AppData/Setbacks/Side" (rtos SIDEOFF))
(setcfg "AppData/Setbacks/Rear" (rtos REAROFF))
(setq SSET (OFFSETOBJECT FRONTOFF OSP "Front" NIL)
; could you explain this a little more possibly?
;;; I'll leave that to Darons posting
SSET (OFFSETOBJECT SIDEOFF OSP "Side" SSET)
SSET (OFFSETOBJECT REAROFF OSP "Rear" SSET)
)
(setq LASTENT (entlast)) ; grabs the last entity created/added
(command ".BPOLY" OSP "") ;bpoly from osp
(cond ((not (eq (entlast) LASTENT))
; as long as a bpoly is made and does not equal above lastent, continue
(command ".LAYER" "Make" "SETBACKS" "") ;make out layer
(command ".CHPROP" (entlast) "" "Layer" "SETBACKS" "")
; changes properties of our bpoly
(command ".ERASE" SSET "") ; erases our selection set
(command ".EXPLODE" (entlast)) ;explodes our bpoly
(princ "\n\nSetbacks created...") ;ALL DONE!!!!
;;; ^^^^Yup
)
(t (princ "\nNo luck today :-(")) ;lost
;;; If BPOLY did not make a boundary object then announce the sad news.
;;; A condition of T will always be true, so when COND is evaluating
;;; each of its conditions from top to bottom and it stumps into T it will
;;; say, "hey, I take this to be true!" and starts evaluating statements
;;; within the condition.
)
)
)
(*ERROR* NIL) ;lost
;;; Can't explain it better than what I did before. You just have to
;;; make a fresh pot of coffee and stare at it until it reveals itself :)
)