jondoeiowa Posted August 3, 2011 Share Posted August 3, 2011 Is it possible to write a lisp routine that will take a single line text and adjust it up or down digets? When I draft a line and tag is 10-0 I would like to be able to build a routine to go through the drawing click on the object and have it adjust down 2, making it 9-10. Anyone have some suggestions or idea if it is even possible? Quote Link to comment Share on other sites More sharing options...
MSasu Posted August 3, 2011 Share Posted August 3, 2011 First, please ask a moderator to move your thread in the appropriate section. You issue will get more support there. Second, what type of entity is that tag? You are talking about a text or a dimension? Regards, Mircea Quote Link to comment Share on other sites More sharing options...
MSasu Posted August 3, 2011 Share Posted August 3, 2011 Your routine will be like: ;select entity to edit (ENTSEL) ;get the associated list of the entity (ENTGET) ;get the label content (ASSOC) ;convert that value to a double taking care of format (DISTOF) ;perform the math ;convert back the value to string taking care of format (RTOS) ;modify the associated list of the entity (SUBST) ;update the entity (ENTMOD) Please try to follow the above scheme and ask where you have issues. Good luck! Regards, Mircea Quote Link to comment Share on other sites More sharing options...
fuccaro Posted August 3, 2011 Share Posted August 3, 2011 Thank you for the tip, Mircea. The thread is moved. Quote Link to comment Share on other sites More sharing options...
Tharwat Posted August 4, 2011 Share Posted August 4, 2011 I guess you mean reversing string. (defun c:TesT (/ ss sset lst e) ;; Tharwat 04. 08. 2011 (prompt "\n Select Texts to reverse >> ...") (if (setq ss (ssget "_:L" '((0 . "TEXT,MTEXT")))) (while (setq sset (ssname ss 0)) (setq lst (vl-string->list (cdr (assoc 1 (setq e (entget sset)))))) (entmod (subst (cons 1 (vl-list->string (reverse lst)))(assoc 1 e) e )) (ssdel sset ss) ) (princ) ) (princ) ) Tharwat Quote Link to comment Share on other sites More sharing options...
MSasu Posted August 4, 2011 Share Posted August 4, 2011 I guess you mean reversing string. Sorry @Tharwat, but seems to me that the OP isn’t looking for a reversing string routine. Regards, Mircea Quote Link to comment Share on other sites More sharing options...
pBe Posted August 5, 2011 Share Posted August 5, 2011 ......When I draft a line and tag is 10-0 I would like to be able to build a routine to go through the drawing click on the object and have it adjust down 2, making it 9-10. Are you saying "adjust it down" is 10-0 less 2 is 9-10. so 10-1 will be 9-11?, and if "up" 9-11 will be 10-1? 10-2 to 10-0? Quote Link to comment Share on other sites More sharing options...
MSasu Posted August 5, 2011 Share Posted August 5, 2011 @pBe: The OP is talking about imperial values: 10'-0" (10 feet, 11 inches) minus 2" (2 inches) will be 9'-10" (9 feet, 10 inches). (rtos (- (distof "10'0\"" 4) (distof "2\"" 4)) 4) (Or, maybe, I didn't understood your question?) Regards, Mircea Quote Link to comment Share on other sites More sharing options...
pBe Posted August 5, 2011 Share Posted August 5, 2011 (edited) @pBe: The OP is talking about imperial values: 10'-0" (10 feet, 11 inches) minus 2" (2 inches) will be 9'-10" (9 feet, 10 inches). (rtos (- (distof "10'0\"" 4) (distof "2\"" 4)) 4) (Or, maybe, I didn't understood your question?) Regards, Mircea I guess you're right msasu.. thought it would be more complex than that like sheet numbering, i.e. sheet number 9 of 10 sheets or 13 of 19... , so the first and second digits would vary greatly, it would have been a fun code to write EDIT: Odd as it is, give this a try (defun c:Addless ( / DoTheMath strs str j intval) (defun AddSub (ent sym num / strs g DoTheMath ft) (setq strs (vla-get-textstring ent)) (setq g (read (strcat "(" (vl-string-subst " " "-" strs) ")"))) (setq DoTheMath (/ ((eval (read sym)) (+ (* (car g) 12.0) (cadr g)) num) 12))(vla-put-textstring ent (strcat (itoa (setq ft (fix DoTheMath))) "-" (rtos (* (- DoTheMath ft) 12) 2 0))) ) (cond ((and (setq strs (ssget ":L" '((0 . "*TEXT")))) (progn (initget 7) (setq IntVal (getint "\nEnter Value to Add\Subtact: ")) ) (princ "\nPress [+/-] Any key to Exit") (while (member (setq j (grread nil 10)) '((2 45)(2 43))) (if (member j '((2 45) (2 43))) (repeat (setq i (sslength strs)) (setq str (vlax-ename->vla-object (ssname strs (setq i (1- i))))) (Addsub str (chr (cadr j)) IntVal)) ) ) ) ) ) (princ) ) Notice how mess up the way i do the math? well i guess you get the general idea Edited August 9, 2011 by pBe Quote Link to comment Share on other sites More sharing options...
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.