I need help editing a basic lisp i have found. I really like this for labelling parts in my drawings because it is just set up click and go, but when i have multiples i have to go back and copy the "tag" that i add for another panel for all multiples. I would really like to be able to "Shift+click" and have the lisp continue with the current number, and when i release shift, go back to ascending numbers until shift is held again. Is this possible? Thank you anyone.
Scott
;;; TX+INTEGERS+TX (defun c:TAG (/ p n ni pref suff nns ntx ntxx oecho osn ds th txt) (setq oecho (getvar "cmdecho") osn (getvar "osmode") ) (if (= 0 (getvar "dimscale"))(setq ds 1.0)(setq ds (getvar "dimscale"))) (setq th (getvar "dimtxt")) (setq txt (* th ds)) (setvar "cmdecho" 0) (setvar "osmode" 0) (if nn (setq nn (fix nn)) (setq nn 1) ) (if (= nn 0)(setq nn 1)) (princ "\n Increment numbers by < ") (princ nn) (princ " >? : ") (setq ni (getint)) (if (= ni nil) (setq ni nn) (setq nn ni) ) (if np (setq np (fix np)) (setq np nn) ) (princ "\n Start or continue with number < ") (princ np) (princ " >? : ") (setq n (getint)) (if (= n nil) (setq n np) (setq np n) ) (setq nns (itoa n)) (princ "\n Prefix text < ") (princ pre) (princ " >? or <.> for none: ") (setq pref (getstring t)) (if (= pref ".") (progn (setq pre nil) (setq pref nil) ) (progn (if (= pref "") (setq pref pre) (setq pre pref) ) (if pref (setq ntx (strcat pref nns)) ) ) ) (princ "\n Suffix text < ") (princ suf) (princ " >? or <.> for none: ") (setq suff (getstring t)) (if (= suff ".") (progn (setq suf nil) (setq suff nil) ) (progn (if (= suff "") (setq suff suf) (setq suf suff) ) (if suff (if pref (setq ntxx (strcat pref nns suff)) (setq ntxx (strcat nns suff)) ) ) ) ) (setq p (getpoint "\n Insert: ")) (setq oecho (getvar "cmdecho")) (while p (if suff ;(command "text" "j" "mc" p "" "" ntxx) (entmake (list (cons 0 "TEXT") (cons 10 p) (cons 11 p) (cons 1 ntxx) ; actual text (cons 7 (getvar "TEXTSTYLE")) (cons 40 txt) (cons 72 4) ) ) (if pref ;(command "text" "j" "mc" p "" "" ntx) (entmake (list (cons 0 "TEXT") (cons 10 p) (cons 11 p) (cons 1 ntx); actual text (cons 7 (getvar "TEXTSTYLE")) (cons 40 txt) (cons 72 4) ) ) ;(command "text" "j" "mc" p "" "" n) (entmake (list (cons 0 "TEXT") (cons 10 p) (cons 11 p) (cons 1 n); actual text (cons 7 (getvar "TEXTSTYLE")) (cons 40 txt) (cons 72 4) ) ) ) ) (setq p (getpoint "\n Next number location: ") n (+ ni n) nns (itoa n) np n ) (if suff (if pref (setq ntxx (strcat pref nns suff)) (setq ntxx (strcat nns suff)) ) ) (if pref (if suff (setq ntxx (strcat pref nns suff)) (setq ntx (strcat pref nns)) ) ) ) (setvar "cmdecho" oecho) (setvar "osmode" 63) (princ) ) (princ "\n Type > TAG < to insert text with ascending integers.") ;;;*********************************************************
Solved! Go to Solution.
Solved by Gary_J_Orr. Go to Solution.
Solved by Gary_J_Orr. Go to Solution.
Solved by pbejse. Go to Solution.
@Anonymous wrote:
I was basically wanting a resource to learn the basic structure of coding. i.e. What does "defun" do and mean? What is princ? And things such as that.
There are many threads here asking for such resources -- do a Search for terms like tutorials, books, websites, references, etc. And those functions and most others [curiously, not all functions available] are described in Help, with what arguments they take, the returned values, etc. In newer versions, you can type a function name into Help just as you can a command name; in older versions, there's an AutoLISP Reference that describes them, that you can navigate to through the Help window.
sorry,
Due to the "post processing" required by the "shift key" option:
(acet-sys-shift-down)
It isn't possible to truly achieve what you want (at least not as far as I could imagine right now).
Otherwise it wouldn't be much of a rewrite to include the value in the prompt (or print it to the cmd line)... it would just require repeating the actual string constructor, once before the first point is selected and again at the end of each loop (right now the string constructor exists at the beginning of each loop).
But, again, since you won't know what the value will be until AFTER you pick the point (since it depends on determining if the shift key was pressed DURING the point selection) there is no way to have it both ways...
Either you need the extra keystrokes proposed in some of the other responses for the "repeat number" option and enable processing of the string before the pickpoint prompt, or you can have the "shift pick" option without the prompt, but I currently see no way to achieve both.
That being said: It wouldn't take too much to "print" what the string would look like before the first point selection, just not repeatedly showing what the next value will look like.
-Gary
Well, since you were so nice about it (and I didn't have anything else to do anyway)...
Try the attached version...
-G