clint0577 Posted November 13, 2012 Posted November 13, 2012 How can I make this allow me to select the text to be edited? (defun c:AFF ( / ss) (vl-load-com) (if (and (setq ss (ssget "X" (list (cons 0 "*text")))) (setq amt (getreal "\nPlease type the amount you would like to add: "))) (progn (mapcar '(lambda (z) (vla-put-textstring z (rtos (+ (atof (vla-get-textstring z)) amt) 2 2))) (mapcar 'vlax-ename->vla-object (vl-remove-if 'listp (mapcar 'cadr (ssnamex ss))))) ) ) (princ) ) Quote
BlackBox Posted November 13, 2012 Posted November 13, 2012 If you're going to work with the Vla-Object for each entity in the Selection Set, then simply iterate the ActiveSelectionSet Collection Object instead of applying Vlax-Ename->Vla-Object to an iterated Selection Set (using SSNAME)... Much faster (vl-load-com) (defun c:FOO ( / ss amt) (if (and (setq ss (ssget "_:L" '((0 . "*TEXT")))) (setq amt (getreal "\nPlease type the amount you would like to add: ") ) ) (progn (vlax-for x (setq ss (vla-get-activeselectionset (vla-get-activedocument (vlax-get-acad-object) ) ) ) (vla-put-textstring x (rtos (+ (atof (vla-get-textstring x)) amt) 2 2) ) ) (vla-delete ss) ) ) (princ) ) ** Note - Error handling not included. Quote
clint0577 Posted November 13, 2012 Author Posted November 13, 2012 Awesome! I'm pretty new at this stuff. Thanks! Quote
BlackBox Posted November 13, 2012 Posted November 13, 2012 Awesome! I'm pretty new at this stuff. Thanks! No worries, we all start somewhere; I'm happy to help. 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.