Arizona Posted February 12, 2024 Posted February 12, 2024 (edited) I'm trying to grab a hundred pieces of MText (polyline contour labels) that are simply a number, and add 2 to them, or increment them by a given number. I'm allowing the user to select them any way they choose first, then use "P" previous in my ssget function. This is very rudimentary, quick and dirty programming. Please excuse my aged style, I learned lisp back in R10. I seem to be stuck on the SUBST, ENTMOD and ENTUPD section. What am I missing? (defun C:IncConTxt () (setq SS1 (ssget "_P")) (setq HTFAC (atoi (getstring "\nHeight Factor: "))) (setq NUM (sslength SS1)) (setq CNT 0) (while (< CNT NUM) (setq ENT (ssname SS1 CNT)) (setq OLDHT (cdr (assoc 1 (entget ENT)))) (setq NEWHT (+ (atoi OLDHT) HTFAC)) (setq NEWHT (itoa NEWHT)) (setq OLDHT (itoa OLDHT)) (setq STUFF (entget ENT)) (setq STUFF (subst (cons 1 NEWHT) (assoc 1 STUFF) STUFF)) (entmod STUFF) (entupd ENT) (setq CNT (+ 1 CNT)) );close while );close defun IncConTxt.lsp Edited February 13, 2024 by fuccaro adding CODE tags Quote
ronjonp Posted February 12, 2024 Posted February 12, 2024 @Arizona Take out this line and it should work: (setq oldht (itoa oldht)) Also .. don't forget to localize your variables: (/ cnt ent htfac newht num oldht ss1 stuff) Quote
Arizona Posted February 12, 2024 Author Posted February 12, 2024 @ronjonp That worked!! Thank you! As far as local variables, yes. I'm going to clean the thing up, put some notes as to what it does and how it works, and credit myself to get the Glory! Thanks so much Ron. Quote
ronjonp Posted February 12, 2024 Posted February 12, 2024 1 hour ago, Arizona said: @ronjonp That worked!! Thank you! As far as local variables, yes. I'm going to clean the thing up, put some notes as to what it does and how it works, and credit myself to get the Glory! Thanks so much Ron. Quote
BIGAL Posted February 13, 2024 Posted February 13, 2024 You might look into using VL lisp as it uses words like (vlax-put obj 'Textstring newht) bit easier than remembering dxf codes and is also very fast. I plus many others do a selection set loops like this. (repeat (setq x (sslength ss)) (setq ent (ssname ss (setq x (1-x)))) .... ) (defun C:IncConTxt ( / ss1 x ent oldht newht) (setq SS1 (ssget "_P")) (setq HTFAC (getint "\nHeight Factor: ")) (repeat (setq x (sslength ss1) (setq ent (vlax-ename->vla-object (ssname ss (setq x (- x 1))))) (setq OLDHT (atoi (vlax-get ent 'Textstring))) (setq NEWHT (+ OLDHT HTFAC)) ) );close defun Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.