Text string in MTEXT

Discussion in 'AutoCAD' started by rolibolibo, Jul 13, 2004.

  1. rolibolibo

    rolibolibo Guest

    Can anyone please provide me w/ some codes for accessing TEXT STRINGs in MTEXT. This is what I need to access..

    If the text string is less than 250 characters, all characters appear in group 1. If the text string is greater than 250 characters, the string is divided into 250-character chunks, which appear in one or more group 3 codes. If group 3 codes are used, the last group is a group 1 and has fewer than 250 characters.

    How do I retrieve multiple data in multiple groups?
     
    rolibolibo, Jul 13, 2004
    #1
  2. rolibolibo

    Jeff Mishler Guest

    Here's something for you that will return the entire string in a variable.

    Jeff

    ;; retrieve the full text string from an Mtext entity. Pass the entity name
    ;; or a valid vla-object
    ;; Usage: (get_txt_str ename) or (get_txt_str vla-object)
    ;; Example:
    ;; (setq obj (car (entsel)))
    ;; (setq txtstr (get_txt_str obj))
    ;; by Jeff Mishler - July 12, 2004

    (defun get_txt_str (txtobj / txtstr ent)
    ;; The first cond gets the text string from a normal ename
    (cond ((= (type txtobj) 'ENAME)
    (setq ent (entget txtobj)
    txtstr "")
    (if (assoc 3 ent);check for long strings
    (progn ; it's > 256 characters
    (foreach x ent
    (if (= 3 (car x))
    (setq txtstr (strcat txtstr (cdr x)))
    );if
    );for
    (setq txtstr (strcat txtstr (cdr (assoc 1 ent))))
    );progn
    (setq txtstr (cdr (assoc 1 ent)));it's < 256 characters
    );if
    );cond 1
    ;; The second cond gets the text string from a vla-object
    ((= (type txtobj) 'VLA-OBJECT)
    (setq txtstr (vla-get-textstring txtobj))
    );cond 2
    );cond
    txtstr
    );defun

    --
    For additional help, try out www.cadvault.com
    remove USES from email address to reply

    MTEXT. This is what I need to access..
    group 1. If the text string is greater than 250 characters, the string is
    divided into 250-character chunks, which appear in one or more group 3
    codes. If group 3 codes are used, the last group is a group 1 and has fewer
    than 250 characters.
     
    Jeff Mishler, Jul 13, 2004
    #2
  3. rolibolibo

    T.Willey Guest

    (vl-load-com)
    (setq ent1 (entsel "\nSelect text string: "))
    (setq ent1 (vlax-ename->vla-object (car ent1)))
    (setq txst (vla-get-TextString ent1))

    No error checking, but this will get you want you want.

    Tim
     
    T.Willey, Jul 13, 2004
    #3
  4. rolibolibo

    rolibolibo Guest

    Thanks Jeff. All this time I didn't know that doing the CAR function repeatedly would let me 'scroll' through my list. Also, aside from CADVAULT, can you refer any other CAD sites that have lisp/vba program.
     
    rolibolibo, Jul 13, 2004
    #4
  5. rolibolibo

    Jeff Mishler Guest

    www.afralisp.com www.theswamp.org are a few others you may want to check
    out.


    --
    For additional help, try out www.cadvault.com
    remove USES from email address to reply

    repeatedly would let me 'scroll' through my list. Also, aside from
    CADVAULT, can you refer any other CAD sites that have lisp/vba program.
     
    Jeff Mishler, Jul 14, 2004
    #5
Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.