Add number to mtext

Discussion in 'AutoCAD' started by Adam D., May 18, 2004.

  1. Adam D.

    Adam D. Guest

    I have several mtext entities that I do not want to explode, but I want to
    be able to adjust their values by a specified number. I have a routine that
    will do the same thing with text, but I need to be able to do it with mtext.

    Any help would be greatly appreciated...
     
    Adam D., May 18, 2004
    #1
  2. Adam D.

    C Witt Guest

    could you explain a bit more? and give an example..?
     
    C Witt, May 18, 2004
    #2
  3. Adam D.

    ECCAD Guest

    Adam,
    Your existing routine probably does entmod on (assoc 1 txt),
    where txt is the text entity..will work for Mtext also..
    If you post a portion of the routine, someone here can probably 'adjust' a line or two..

    Bob
     
    ECCAD, May 18, 2004
    #3
  4. Adam D.

    Adam D. Guest

    I downloaded it from Cadalyst's web site. I thought the same as you, but it
    did not work for me with mtext. It did work with text. What I have is spot
    elevations I have placed using the qleader with mtext. I need to lower them
    1' and it would be nice to do it globally.


    ;Tip1528: AUMENTA.LSP Modify Elevations (c)1999, Christian Ansel
    Davies Sala

    (DEFUN c:aum (/ conjunto altura nent entidad tipo cotatxt cotac cota)
    (PROMPT "Select text to modify.")
    (SETQ conjunto (SSGET))
    (INITGET 1)
    (SETQ altura (GETREAL "Enter value to change selected text by: "))
    (SETQ nent -1)
    (REPEAT (SSLENGTH conjunto)
    (SETQ nent (1+ nent))
    (SETQ entidad (ENTGET (SSNAME conjunto nent)))
    (SETQ tipo (CDR (ASSOC 0 entidad)))
    (IF (= tipo "TEXT") (PROGN
    (SETQ cotatxt (CDR (ASSOC 1 entidad)))
    (SETQ cotac (cambia cotatxt "." ","))
    (SETQ cota (ATOF cotac))
    (IF (OR (/= cota 0.0) (NOT (chequea cotatxt))) (aumenta))
    )
    )
    )
    (PRIN1)
    )

    ;------------------------------------------------------------------------
    (DEFUN aumenta (/ nueva_cota)
    (SETQ nueva_cota (RTOS (+ cota altura) 2 2) )
    (SETQ entidad (SUBST (CONS 1 nueva_cota) (ASSOC 1 entidad) entidad))
    (ENTMOD entidad)
    )

    ;------------------------------------------------------------------------
    (DEFUN chequea (cotatxt / n i letra no_cero hay_cero)
    (SETQ n (STRLEN cotatxt))
    (SETQ i 0)
    (REPEAT n
    (SETQ i (1+ i))
    (SETQ letra (SUBSTR cotatxt i 1))
    (IF (AND (/= letra "0") (/= letra "-") (/= letra ".") (/= letra ",")
    (/= letra " ")) (SETQ no_cero T))
    (IF (= letra "0") (SETQ hay_cero T))
    )
    (IF (NOT hay_cero) (SETQ no_cero T))
    (SETQ no_cero no_cero)
    )
    ;------------------------------------------------------------------------
    (DEFUN cambia (cota l1 l2 / n i letra cota)
    (SETQ n (STRLEN cota))
    (SETQ i 0)
    (REPEAT (1- n)
    (SETQ i (1+ i))
    (SETQ letra (SUBSTR cota i 1))
    (IF (= letra l2) (SETQ cota (STRCAT (SUBSTR cota 1 (1- i)) l1
    (SUBSTR cota (1+ i) (- n i)) ) ))
    )
    (SETQ cota cota)
    )

    (PRIN1 "Routine is loaded. Enter AUM to start.")
    (TERPRI)
     
    Adam D., May 18, 2004
    #4
  5. Adam D.

    Adam D. Guest

    Please see my post below to Bob (ECCAD).

    Thank you.
     
    Adam D., May 18, 2004
    #5
  6. Adam D.

    ECCAD Guest

    Try replacing:
    (IF (= tipo "TEXT") (PROGN
    with:
    (if (or (= tipo "TEXT")(= tipo "MTEXT"))(progn

    Bob
     
    ECCAD, May 18, 2004
    #6
  7. Adam D.

    Adam D. Guest

    No, that did not work.
     
    Adam D., May 18, 2004
    #7
  8. Adam D.

    Jason Wilder Guest

    I tried what Bob said, it worked for me.

    Here is the full first part:

    (DEFUN c:aum (/ conjunto altura nent entidad tipo cotatxt cotac cota)
    (PROMPT "Select text to modify.")
    (SETQ conjunto (SSGET))
    (INITGET 1)
    (SETQ altura (GETREAL "Enter value to change selected text by: "))
    (SETQ nent -1)
    (REPEAT (SSLENGTH conjunto)
    (SETQ nent (1+ nent))
    (SETQ entidad (ENTGET (SSNAME conjunto nent)))
    (SETQ tipo (CDR (ASSOC 0 entidad)))
    (IF (or (= tipo "TEXT") (= tipo "MTEXT"))
    (PROGN
    (SETQ cotatxt (CDR (ASSOC 1 entidad)))
    (SETQ cotac (cambia cotatxt "." ","))
    (SETQ cota (ATOF cotac))
    (IF (OR (/= cota 0.0) (NOT (chequea cotatxt))) (aumenta))
    )
    )
    )
    (PRIN1)
    )
     
    Jason Wilder, May 18, 2004
    #8
  9. Adam D.

    ECCAD Guest

    Adam,
    If the 'mtext' you have is a part of a qleader or leader, then
    it probably won't grab the mtext, rather , getting the leader, and the mtext is burried a little deeper.

    Bob
     
    ECCAD, May 18, 2004
    #9
  10. Adam D.

    ECCAD Guest

    When selecting the objects, use 'C' for crossing..
    (PROMPT "Select text to modify.")
    Should work. ?

    Bob
     
    ECCAD, May 18, 2004
    #10
  11. Adam D.

    ECCAD Guest

    I added a qleader, filled in 5'6" for elevation, then examined the
    entity. Found: (1 . "\\A1;5'6\"")
    For the 'replacement' string, you might have to add the "\\A1;" portion. To to this: (setq nueva_cota (strcat "\\A1;" nueva_cota)).. before calling the function aumenta.
    But only for 'MTEXT' entity, and qleader..

    Bob
     
    ECCAD, May 18, 2004
    #11
  12. Adam D.

    Joe Burke Guest

    Hi Bob,

    I only glanced at the functions Adam posted.

    I think the problem you found with mtext attached to a leader, also applies to any
    mtext object which contains formatting codes. So simply allowing mtext within these
    functions is a limited solution.

    One possible workaround without more code, run Steve Doman's StripMtext 3.x program
    first with all options checked. This assumes incrementing the text is more important
    to the user than keeping any mtext formatting.

    Joe Burke

    this: (setq nueva_cota (strcat "\\A1;" nueva_cota)).. before calling the function
    aumenta.
     
    Joe Burke, May 19, 2004
    #12
  13. Adam D.

    ECCAD Guest

    Joe,
    Thanks for the tip. I am not familiar with that particular .lsp, but I am sure it can do the job. Adam posted earlier, wanted a way to 'increment' the distances, which we (group) worked through. This time, he has inserted some qleaders, and MTEXT, (probably) with (1) string such as 5'6" or such. I see with playing with the Mtext that there are more codes,,\P, \{font}.. and more..
    He may have got this to work.

    Bob
     
    ECCAD, May 19, 2004
    #13
  14. Adam D.

    Adam D. Guest

    I could not get it to work with the modifications. So I did the old tried
    true way: I exploded the mtext, ran the routine, turned them back into
    mtext, and associated them back with the leader. I will go back an figure it
    out later. I just needed to get it out quickly.

    But thanks for everyone's help...
     
    Adam D., May 19, 2004
    #14
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.