leonucadomi Posted 19 hours ago Author Posted 19 hours ago 17 hours ago, BIGAL said: This post is like option 2 of this post. Is there an option 3 ? Will answer last question in other post. Suggest keep all in one post. Give this a try does both requests. (defun c:addval ( / lst lst2 att cnt lst3) (setq inc (getreal "\nEnter increment + or - ")) (setq ss (ssget '((0 . "TEXT,ATTDEF")))) (setq lst '() tnum 0 tatt 0) (repeat (setq x (sslength ss)) (setq obj (vlax-ename->vla-object (ssname ss (setq x (1- x))))) (setq objname (vlax-get obj 'objectname)) (if (= objname "AcDbText") (progn (vlax-put obj 'textstring (rtos (+ (atof (vlax-get obj 'textstring)) inc) 2 0)) (setq tnum (1+ tnum)) ) (progn (vlax-put obj 'tagstring (rtos (+ (atof (vlax-get obj 'tagstring)) inc) 2 0)) (setq tatt (1+ tatt)) ) ) ) (alert (strcat (rtos tnum 2 0) " text changed \n" (rtos tatt 2 0) " tags Changed")) (princ) ) If you introduce more objects may need a cond rather than using IF. This tool is great but I need the numbering to be in this format 001, 050....I mean that a zero accompanies the number la numeracion que aqui manejamos usa 3 digitos Quote
leonucadomi Posted 18 hours ago Author Posted 18 hours ago 17 hours ago, BIGAL said: This post is like option 2 of this post. Is there an option 3 ? Will answer last question in other post. Suggest keep all in one post. Give this a try does both requests. (defun c:addval ( / lst lst2 att cnt lst3) (setq inc (getreal "\nEnter increment + or - ")) (setq ss (ssget '((0 . "TEXT,ATTDEF")))) (setq lst '() tnum 0 tatt 0) (repeat (setq x (sslength ss)) (setq obj (vlax-ename->vla-object (ssname ss (setq x (1- x))))) (setq objname (vlax-get obj 'objectname)) (if (= objname "AcDbText") (progn (vlax-put obj 'textstring (rtos (+ (atof (vlax-get obj 'textstring)) inc) 2 0)) (setq tnum (1+ tnum)) ) (progn (vlax-put obj 'tagstring (rtos (+ (atof (vlax-get obj 'tagstring)) inc) 2 0)) (setq tatt (1+ tatt)) ) ) ) (alert (strcat (rtos tnum 2 0) " text changed \n" (rtos tatt 2 0) " tags Changed")) (princ) ) If you introduce more objects may need a cond rather than using IF. You can add something like this to make the numbering 3 digits? like this (setq i 1 ) (foreach sub lst (setq lent (entget (last sub)) txt (strcat (if (< i 10) "00" (if (< i 100) "0" "")) (itoa i)) i (1+ i) ) (entmod (subst (cons 1 txt)(assoc 1 lent) lent)) ) Quote
BIGAL Posted 6 hours ago Posted 6 hours ago Another go. (defun c:addval ( / lst lst2 att cnt lst3) (setq inc (getreal "\nEnter increment + or - ")) (setq ss (ssget '((0 . "TEXT,ATTDEF")))) (setq lst '() tnum 0 tatt 0) (repeat (setq x (sslength ss)) (setq obj (vlax-ename->vla-object (ssname ss (setq x (1- x))))) (setq objname (vlax-get obj 'objectname)) (if (= objname "AcDbText") (progn (setq newt (+ (atof (vlax-get obj 'textstring)) inc)) (cond ((< newt 10 ) (setq newt (strcat "00" (rtos newt 2 0)))) ((< newt 100) (setq newt (strcat "0" (rtos newt 2 0)))) (setq newt (rtos newt 2 0)) ) (vlax-put obj 'textstring newt) (setq tnum (1+ tnum)) ) (progn (setq newt (+ (atof (vlax-get obj 'tagstring)) inc)) (cond ((< newt 10) (setq newt (strcat "00" (rtos newt 2 0)))) ((< newt 100) (setq newt (strcat "0" (rtos newt 2 0)))) (setq newt (rtos newt 2 0)) ) (vlax-put obj 'tagstring newt) (setq tatt (1+ tatt)) ) ) ) (alert (strcat (rtos tnum 2 0) " text changed \n" (rtos tatt 2 0) " tags Changed")) (princ) ) 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.