You don't want another routine trying to use the Elev variable. When using global variables, I would always add something to them to look a little different and be specific to the routine. Always remember to localize your variables (unless they're supposed to be global). I think this will do the same thing, just a little differently. If you have a better way i'm all ears.ĭo you tally these prr_* before you close out of a drawing? I'm sure there is an easier way to do it, I just did it this way the first time I wrote a lisp and never looked into it. Saves the value of Elev before the prompt that way a blank entry can be used. This is just a string of the prompt for Elev, not neccessary, just how I like to do it. And just to stay consistant I always name this variable prr_* where * is the text that needs to be entered into the command prompt. In all the longer lisps I write I like to add a counter of how many times it has been ran, which isn't really neccessary, but in this case I use it to determine if the lisp has been previously ran, and if it hasn't set Elev to 29, if it has been ran, leave it at whatever it is. Gotcha, I edited the post and from now on I will do that. (setq prr_of (if (= prr_of nil) 1 (+ prr_of 1))) (setq Elev (if (not Elev) Elev_def Elev))) (vl-load-com) (defun DT:LoadFromProjects ( fileName onFailMessage / return ) Load fileName from usernameprojectscivil-autolisp repository Return T.
(setq Elev_pmt (strcat "\nSpecify new elevation for offset object : ")) (and (eq -1 (getvar 'offsetdist)) (setvar 'offsetdist 0.118)) I changed it up a little to add in a default value and now it also saves the elevation from the previous running: (not (vla-put-layer (vlax-ename->vla-object (entlast)) (getvar 'clayer))) (if (setq Pnt (getpoint "\nSpecify point on side to offset: ")) (if (vl-position (cdr (assoc 0 (entget Obj))) '("ARC" "CIRCLE" "LINE" "LWPOLYLINE")) (while (setq Obj (car (entsel "\nSelect object to offset: "))) (or (setq Elev (getreal "\nSpecify new elevation for offset object: ")) T) (cond ((getdist (strcat "\nSpecify offset distance : "))) (and (eq -1 (getvar 'offsetdist)) (setvar 'offsetdist 1)) (setq *error* (lambda (m) (and Cmd (setvar 'cmdecho Cmd)) (princ (strcat "\nError: " m)))) Offset selected object(s) to current layer and change elevation (defun c:OTE (/ *error* Cmd Elev Obj Pnt) For example, you may want to get a point midway between two other points. Here's a crude example (will fail if selected object is on locked layer). Extracting Elements from a List There are times when you will want to create a list from other lists.