I'm learning more about Lisp, and for practice developed one that lets a user pick the starting text as the first sentence for notes, then lets user pick another text line anywhere on the dwg, and it matches the first sentence's justification, ht, sz... and places it at a distance the user specifies at the prompt, below the first sentence.
This is so a cluster of notes can be randomly around the dwg, and a user can go around picking which they want for the next line, while matching all the originals properties.
Everything works well. I can pick Any justification to start with, and any justification I pick next, changes and uses the the assoc 11 to locate the next line.
The only group that doesnt work is when the first pick is ANY JUSTIFICATION BUT the Standard Left justification, and the second IS the Standard Left justification, it throws the second sentence down to 0,0.
When I use the Visual Lisp Editor, and Step my way thru the program, watching all the variable involved, the numbers match to what theyre supposed to be, but it still throws the second sentence (when its Left Justified (assoc 11 at 0 0 0)) down to 0,0.
I use !t2tnewloc11 and its showing the values are correct, even try to (entmod second) at the command prompt, or Regen to wake it up, but it won't move back to where its supposed to be, right below the first sentence.
It also works ok if I remove the assoc 72 and 73 out of the routine, but then my justification wont change in case I want to move them orderly later by snaps.
I also tried to save the original location it gets set to to another variable, to reset it to the location its supposed to be at, and entmod it as the very last program line, in case its loosing its value at the last minute for some reason, but it still wont go to the correct spot, still at 0,0.
It always works if I start with Left justified, and pick any other Justification, or start with any other justification, and pick any justification other than Left.
I also print the list associated with that entity name to the screen, and it shows the values have changed, but it doesnt move it to the X,Y (11 . X Y Z) that the variable is holding. Of course listing the text list itself shows that the assoc 11 values changed back to 0 0 0.
Why might my (entmod) not be keeping the changes it says the values are for that variable?
Here is the code, remember, Im new to the deeper coding, even tho Ive been dabbling for years, so my
coding is not high tech, its my first program on my own, and just used the text placement to learn something.
(defun c:txtjust ()
(prompt "Builds a notes list by selecting from existing notes, ")(terpri)
(prompt "Std spcg. for .1875 text, about .32, ")
(prompt "Spcg. for notes with boxes, about .50 ")(terpri)
; (prompt "Current spacing is: ")(princ tspg)
(setq ds (getvar "dimscale")) ; dimscale to match spacing
(prompt "Program factors dimscale with user input, ") ; helping user to enter correct input
(setq tspg (getreal "Enter text spacing: "))
(setq t1ipL (entget (car (entsel "Select text guide: "))))(terpri)
(setq t1as10 (assoc 10 t1ipL))
(setq t1as11 (assoc 11 t1ipL))
(setq t1as40 (assoc 40 t1ipL))
(setq t1as7 (assoc 7 t1ipL))
(setq t1as72 (assoc 72 t1ipL))
(setq t1as73 (assoc 73 t1ipL))
(setq t1ht (cdr t1as40))
(setq t1jpx (cadr t1as10)) ; gets x for 10 for t1
(setq t1jpy (caddr t1as10)) ; gets y for 10 for t1
(if (and (= (cdr t1as72) 0)(= (cadr t1as11) 0)) ; of both, its left just. and sets 11 for 10 since 11 is 0.
(setq t1as11 t1as10))
(setq t1ipx (cadr t1as11)) ; gets x for 11 for t1
(setq t1ipy (caddr t1as11)) ; gets y for 11 for t1
(setq t2ipL (entget (car (entsel "Select next line: "))))
(setq t2as10 (assoc 10 t2ipL))
(setq t2as11 (assoc 11 t2ipL))
(setq t2as72 (assoc 72 t2ipL))
(setq t2as40 (assoc 40 t2ipL))
(setq t2as7 (assoc 7 t2ipL))
(setq t2as73 (assoc 73 t2ipL))
(setq t2jpx (cadr t2as10)) ; gets x for 10 for t2
(setq t2jpy (caddr t2as10)) ; gets y for 10 for t2
(if (and (= (cdr t2as72) 0)(= (cadr t2as11) 0))
(setq t2as11 t2as10))
(setq t2as40 (assoc 40 t2ipL))
(setq t2ipy (- t1ipy (* tspg ds))) ; sets spacing from t1 for 11 of t2
(setq t2jpy (- t1jpy (* tspg ds))) ; sets spacing from t1 for 10 of t2
(setq t2ipx t1ipx) ; grabs x from t1
(setq t2ipL (subst t1as40 t2as40 t2ipL)) ; replaces text size
(entmod t2ipL)
(setq t2ipL (subst t1as7 t2as7 t2ipL)) ; replaces text style
(entmod t2ipL)
(setq t2newloc10 (list 10 t2ipx t2jpy 0.0)) ; creates 10's list for t2
(setq t2ipL (subst t2newloc10 t2as10 t2ipL)) ; substitutes the new 10 value
(entmod t2ipL) ; mods the entity t2ipL
(setq t2ipL (subst t1as72 t2as72 t2ipL)) ; creates 72's list for t2
(entmod t2ipL)
(setq t2newloc11 (list 11 t2ipx t2ipy 0.0)) ; creates 11's list for t2
(setq t2tnewloc11 t2newloc11)
(setq t2ipL (subst t2newloc11 t2as11 t2ipL))
(entmod t2ipL)
(setq t2ipL (subst t1as73 t2as73 t2ipL)) ; creates 73's list for t2
(entmod t2ipL)
; (setq t2ipL (subst t2tnewloc11 t2as11 t2ipL)) ; tried just retrieving orig new saved new loc. value
; (entmod t2ipL) ; and replacing back into the entity name, but noooo
(setq t2tnewloc11 (list 11 t2ipx t2ipy 0.0))
(setq t2ipL (subst t2tnewloc11 t2as11 t2ipL))
(entmod t2ipL)
(princ) ; prog was listing value for t2ipL, this cleaned it up
)
Thanks for any ideas on helping with the magic jumping bean!