Arin9916 Posted May 20, 2011 Posted May 20, 2011 I can not english well.. so I attached the file . you can understang easy.. QQ.dwg Quote
pBe Posted May 20, 2011 Posted May 20, 2011 try this (defun c:test ( / Text obj ht str ptList) (vl-load-com) (defun Text (pt hgt wd str) (entmakex (list (cons 0 "TEXT") (cons 10 pt) (cons 40 hgt) (cons 41 wd) (cons 1 str)))) (cond ( (and (setq obj (car (entsel "\nSelect Text:"))) (setq obj (entget obj)) (eq (cdr (assoc 0 obj)) "TEXT") (setq ht (cdr (assoc 40 obj))) (setq str (vl-remove-if '(lambda (y) (eq " " (chr y))) (vl-string->list (cdr (assoc 1 obj))))) (setq ptList (list (setq Pt (getpoint "\nPick point to place text:")))) (repeat (1- (length str)) (setq ptList (cons (setq pt (vl-list* (+ (* ht 1.5) (car pt)) (cdr pt))) ptList))) (mapcar '(lambda (k l) (Text l (cdr (assoc 40 obj)) (cdr (assoc 41 obj))(chr k))) str (reverse ptList)) ) ) ) (princ) ) Quote
Arin9916 Posted May 20, 2011 Author Posted May 20, 2011 Thanks. PBe lisp is working. but it`s not different my intention. i want explode original text. and this lisp is change position that original text..... Thanks For attention my question.^^ Quote
pBe Posted May 21, 2011 Posted May 21, 2011 Thanks. PBe i want explode original text. and this lisp is change position that original text..... (defun c:test ( / Text obj [color=blue]objent[/color] ht str ptList) (defun Text (pt hgt wd str) (entmakex (list (cons 0 "TEXT") (cons 10 pt) (cons 40 hgt) (cons 41 wd) (cons 1 str)))) (cond ( (and (setq obj (car (entsel "\nSelect Text:"))) (setq [color=blue]objent[/color] (entget obj)) (eq (cdr (assoc 0 [color=blue]objent[/color])) "TEXT") (setq ht (cdr (assoc 40 [color=blue]objent[/color]))) (setq str (vl-remove-if '(lambda (y) (eq " " (chr y))) (vl-string->list (cdr (assoc 1 [color=blue]objent[/color]))))) [color=blue](progn (vla-GetBoundingBox (vlax-ename->vla-object obj) 'a 'b) (setq ptList (list (setq Pt (vlax-safearray->list a)) ))) [/color] (repeat (1- (length str)) (setq ptList (cons (setq pt (vl-list* (+ (* ht 1.5) (car pt)) (cdr pt))) ptList))) (mapcar '(lambda (k l) (Text l (cdr (assoc 40 objent)) (cdr (assoc 41 objent))(chr k))) str (reverse ptList)) [color=blue](entdel obj) [/color] ) ) ) (princ) ) This is close as i can get it. Quote
Organic Posted May 21, 2011 Posted May 21, 2011 You're missing a (vl-load-com) in there. Looks pretty good to me. One thing where it fails is if the dtext is rotated the separate text components do not maintain their orientation/position. Quote
Tharwat Posted May 21, 2011 Posted May 21, 2011 Hope you do not mind pBe I did enjoy writing it . (defun c:Test (/ i ss e spc lst p t1 hgt) (setq i 0) (if (and (setq ss (car (entsel "\n Select Text :"))) (eq (cdr (assoc 0 (setq e (entget ss)))) "TEXT") ) (progn (setq spc (* (cdr (assoc 40 e)) 1.5)) (setq lst (vl-string->list (cdr (assoc 1 e)))) (setq p (cdr (assoc 10 e))) (repeat (length lst) (setq t1 (chr (nth i lst))) (entmakex (list (cons 0 "TEXT") (cons 10 p) (cons 40 (setq hgt (cdr (assoc 40 e)))) (cons 1 t1) ) ) (setq i (+ i 1) p (list (+ (car p) spc) (cadr p) ) ) ) (entdel ss) ) ) (princ) ) Tharwat Quote
Tharwat Posted May 21, 2011 Posted May 21, 2011 One thing where it fails is if the dtext is rotated the separate text components do not maintain their orientation/position. Good point Dink (defun c:Test (/ i ss e spc lst p t1 hgt) (setq i 0) (if (and (setq ss (car (entsel "\n Select Text :"))) (eq (cdr (assoc 0 (setq e (entget ss)))) "TEXT") ) (progn (setq spc (* (cdr (assoc 40 e)) 1.5)) (setq lst (vl-string->list (cdr (assoc 1 e)))) (setq p (cdr (assoc 10 e))) (repeat (length lst) (setq t1 (chr (nth i lst))) (entmakex (list (cons 0 "TEXT") (cons 10 p) (cons 40 (setq hgt (cdr (assoc 40 e)))) (cons 1 t1) ) ) (setq i (+ i 1) p (polar (list (+ (car p) spc)(cadr p))(cdr (assoc 50 e)) spc) ) ) (entdel ss) ) ) (princ) ) Tharwat Quote
pBe Posted May 21, 2011 Posted May 21, 2011 You're missing a (vl-load-com) in there. Looks pretty good to me. One thing where it fails is if the dtext is rotated the separate text components do not maintain their orientation/position. That is correct, plus there are a few factors to consider as well. like number of space " " on the str , it would have been easier if the orignal text justifiation is not Middle Center to resolve the postion issue (thats why i threw in the boundingbox function) , and yes rotation. what i wrote is the bare minimum, works only for certain condtions (hence the command name TEST) Thank you for your insights Dink87522 and also to tharwat. EDIT. Feel free to modify my code to resovle rotation and postion, i would want to see how others would approach it Quote
Arin9916 Posted May 21, 2011 Author Posted May 21, 2011 Thanks Everyone. These lisp are useful for me. ^^ 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.