cadamrao Posted July 4, 2012 Share Posted July 4, 2012 [ATTACH]35718[/ATTACH]hello! I need little modification for this lisp to easy change my beam schedule beam marking name. I need to increment order of CSHB1.After selection of text; I'm looking pick first point means copy the text from below CSHB1 redline left side endpoint to destination point (Left Click to Copy Increment) at respective left side endpoint of RC beam size (as per specified RC beam size rows values) thanks for the support&value of ur time Venki BEAM.dwg NUMBER INC (NIE).lsp Quote Link to comment Share on other sites More sharing options...
Tharwat Posted July 4, 2012 Share Posted July 4, 2012 Without taking a look at your code and here is my routine to renumber the marketing name if it has a number at the end of its string . First select the text then specify the distance between texts and finally the whole distance . (defun c:TesT (/ s p p1 e n v st str) ;;;; Tharwat 04. July. 2012 ;;;; (setq i (if i d (getvar 'textsize) ) ) (cond ( (not (setq s (ssget "_+.:S" '((0 . "TEXT,MTEXT"))))) ) ( (not (if (and (setq n (last (vl-string->list (setq v (cdr (assoc 1 (setq e (entget (ssname s 0))))) ) ) ) ) (numberp (read (chr n))) ) (setq n (atoi (chr n))) ) ) (princ "\n Last character is not number !! ") ) ( (not (if (progn (initget 6) (setq d (cond ((getdist (strcat "\n Specify distance between texts < " (rtos i 2) " > :" ) ) ) (t i) ) ) ) (setq i d) ) ) ) ( (not (and (setq p (getpoint "\n Specify end point :")) (setq p1 (getpoint "\n Next point :" p)) ) ) ) (t (progn (setq str (substr v 1 (1- (strlen v)))) (repeat (fix (/ (distance p p1) d)) (entmakex (list '(0 . "TEXT") (cons 10 (setq st (trans (polar p (angle p p1) d) 1 0))) (cons 11 st) (assoc 40 e) (cons 1 (strcat str (itoa (setq n (1+ n))))) ) ) (setq p st) ) ) ) ) (princ) ) Quote Link to comment Share on other sites More sharing options...
pBe Posted July 4, 2012 Share Posted July 4, 2012 try it with numbers ending with 9 e.g. "Banana29" "39".... Quote Link to comment Share on other sites More sharing options...
Lee Mac Posted July 4, 2012 Share Posted July 4, 2012 Maybe this will help? Quote Link to comment Share on other sites More sharing options...
Tharwat Posted July 4, 2012 Share Posted July 4, 2012 try it with numbers ending with 9 e.g. "Banana29" "39".... Try it with drawing that brought as an example . Quote Link to comment Share on other sites More sharing options...
pBe Posted July 4, 2012 Share Posted July 4, 2012 (edited) (Defun c:CMI (/ parseStr _inccopy TxtObj fp sp dst ang gr code data) ;;; pBe July 2012 ;;; (vl-load-com) (defun parseStr (str / strA pr v) (setq strA (if (zerop (atoi (setq v str))) (setq pr (vl-string-right-trim "0123456789" str)) (progn (setq pr "") v))) (strcat pr (itoa (1+ (atoi (if (eq strA str) strA (vl-string-trim strA str)))))) ) (defun _inccopy (e p1 p2 / st) (vlax-invoke (setq e (vla-copy e)) 'move p1 p2) (vla-put-textstring e (parseStr (vla-get-textstring e))) e ) (cond ((and (setq TxtObj (ssget "_:L:S:E" '((0 . "TEXT")))) (setq TxtObj (vlax-ename->vla-object (ssname TxtObj 0))) (setq fp (getpoint "\nPick first point: ")) (setq sp (getpoint fp "\nPick second point: ")) (setq dst (distance (setq fp (trans fp 1 0)) (setq sp (trans sp 1 0))) ang (angle fp sp)) (setq TxtObj (_inccopy TxtObj fp sp)) (print) (while (progn (princ "\rPress Space Bar to Copy Increment/Left click to move Previous object/Undo:") (setq gr (grread t 15 0) code (car gr) data (cadr gr) ) (cond [color=blue]((and (= 2 code) (member data '(85 117))) (vlax-invoke TxtObj 'move sp fp) T )[/color] ((and (= 2 code) (= data 32)) (setq TxtObj (_inccopy TxtObj fp sp) fp sp sp (polar sp ang dst)) ) ((= 3 code) (vlax-invoke TxtObj 'move fp sp) (setq fp sp sp (polar sp ang dst)) T ) ((= 5 code) T) ) ) ) ) ) ) (princ) ) Command: CMI Select objects: Pick first point: Pick second point: Press Space Bar to Copy Increment/Left click to move Previous object/Undo: NOTE: It needs getting use. you'll know it when you see it. Edited July 4, 2012 by pBe Add UNDO Quote Link to comment Share on other sites More sharing options...
Tharwat Posted July 5, 2012 Share Posted July 5, 2012 Interesting pBe . It is good to have the object name Mtext with Text into your selection set . Thanks. Quote Link to comment Share on other sites More sharing options...
pBe Posted July 5, 2012 Share Posted July 5, 2012 Interesting pBe . It is good to have the object name Mtext with Text into your selection set . Thanks. I agree, MTEXT option would be nice, but i may need to put an additional sub to handle Charactrer formatting with this http://www.lee-mac.com/unformatstring.html , (kudos to LM), Might as well include as soon as the OP gives the A-OK You will notice that i opted to use move/copy rather than creating the TEXT entity, that way you dont need to deal with properties and the like to match the selected object. Apprecitae your comments tharwat Thank you for that Cheers dude Quote Link to comment Share on other sites More sharing options...
cadamrao Posted July 6, 2012 Author Share Posted July 6, 2012 Thanks you sir,added tikka masala to CMI ;very nice. Thanks a lot venki (Defun c:CMI (/ parseStr _inccopy TxtObj fp sp dst ang gr code data) ;;; pBe July 2012 ;;; (vl-load-com) (defun parseStr (str / strA pr v) (setq strA (if (zerop (atoi (setq v str))) (setq pr (vl-string-right-trim "0123456789" str)) (progn (setq pr "") v))) (strcat pr (itoa (1+ (atoi (if (eq strA str) strA (vl-string-trim strA str)))))) ) (defun _inccopy (e p1 p2 / st) (vlax-invoke (setq e (vla-copy e)) 'move p1 p2) (vla-put-textstring e (parseStr (vla-get-textstring e))) e ) (cond ((and (setq TxtObj (ssget "_:L:S:E" '((0 . "TEXT")))) (setq TxtObj (vlax-ename->vla-object (ssname TxtObj 0))) (setq fp (getpoint "\nPick first point: ")) (setq sp (getpoint fp "\nPick second point: ")) (setq dst (distance (setq fp (trans fp 1 0)) (setq sp (trans sp 1 0))) ang (angle fp sp)) (setq TxtObj (_inccopy TxtObj fp sp)) (print) (while (progn (princ "\rPress Space Bar to Copy Increment/Left click to move Previous object/Undo:") (setq gr (grread t 15 0) code (car gr) data (cadr gr) ) (cond [color=blue]((and (= 2 code)[/color] [color=blue] (member data '(85 117)))[/color] [color=blue] (vlax-invoke TxtObj 'move sp fp) T[/color] [color=blue] )[/color] ((and (= 2 code) (= data 32)) (setq TxtObj (_inccopy TxtObj fp sp) fp sp sp (polar sp ang dst)) ) ((= 3 code) (vlax-invoke TxtObj 'move fp sp) (setq fp sp sp (polar sp ang dst)) T ) ((= 5 code) T) ) ) ) ) ) ) (princ) ) Command: CMI Select objects: Pick first point: Pick second point: Press Space Bar to Copy Increment/Left click to move Previous object/Undo: NOTE: It needs getting use. you'll know it when you see it. Quote Link to comment Share on other sites More sharing options...
pBe Posted July 6, 2012 Share Posted July 6, 2012 Thanks a lot venki You are welcome cadamrao.. Glad I could help Cheers 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.