Jump to content

Recommended Posts

Posted

I can not english well.. so

I attached the file . you can understang easy..:)

QQ.dwg

Posted

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)
     )

Posted

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.^^

Posted
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.

Posted

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.

Posted

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

Posted

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

Posted
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

Posted

Thanks Everyone.

These lisp are useful for me. ^^

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.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...