Author Topic: a lisp to combine 2 sets of mtext  (Read 2529 times)

0 Members and 1 Guest are viewing this topic.

STEVEDALLAS

  • Guest
a lisp to combine 2 sets of mtext
« on: April 24, 2007, 12:31:50 PM »
Usually one might use txt2mtxt to convert single line to mtext, even multiple strings.

I want to combine mtexts into 1 mtext, without cut/paste.

Is this "do-able"?

T.Willey

  • Needs a day job
  • Posts: 5251
Re: a lisp to combine 2 sets of mtext
« Reply #1 on: April 24, 2007, 12:41:12 PM »
Yes, and I would use ActiveX.  simple example
Code: [Select]
((lambda (/ Sel Obj1 Obj2 Str1 Str2)

(setq Sel (entsel "\n Select text object to add text to end of: "))
(setq Obj1 (vlax-ename->vla-object (car Sel)))
(setq Str1 (vla-get-TextString Obj1))
(setq Sel (entsel "\n Select text to add text to end of previous selected text: "))
(setq Obj2 (vlax-ename->vla-object (car Sel)))
(setq Str2 (vla-get-TextString Obj2))
(vla-put-TextString Obj1 (strcat Str1 " " Str2))
(princ)
))
Tim

I don't want to ' end-up ', I want to ' become '. - Me

Please think about donating if this post helped you.

mkweaver

  • Bull Frog
  • Posts: 352
Re: a lisp to combine 2 sets of mtext
« Reply #2 on: April 24, 2007, 02:04:35 PM »
Just finished this prior to reading your post:

Enjoy,
Mike Weaver
AlasCAD

Code: [Select]
;;;adds text values with a space, doesn't erase anything
(defun c:adt ()
  (adt T nil)
) ;_ end of defun


;;;adds text values without a space, erases subseqent entities
(defun c:adtx ()
  (adt nil T)
) ;_ end of defun

(defun adt (
    spacemode ;add intermediate space if non-nil
    erasemode ;erase all but 1st item if non-nil
    /
   )
  (if (and
(setq pent (nentsel "\nSelect primary entity: "))
(vlax-property-available-p
  (setq pobj (vlax-ename->vla-object (car pent)))
  'TEXTSTRING
) ;_ end of vlax-property-available-p
      ) ;_ end of and
    (while (and
     (setq ent (nentsel "\nSelect text to combine: "))
     (vlax-property-available-p
       (setq obj (vlax-ename->vla-object (car ent)))
       'TEXTSTRING
     ) ;_ end of vlax-property-available-p
   ) ;_ end of and
      (vla-put-textstring
pobj
(strcat
  (vla-get-textstring pobj)
  (if spacemode
    " "
    ""
  ) ;_ end of if
  (vla-get-textstring obj)
) ;_ end of strcat
      ) ;_ end of vla-put-textstring
      (if erasemode
(vla-delete obj)
      ) ;_ end of if
    ) ;end while
  ) ;_ end of if
) ;end adt-new