Dtext -> Mtext

Discussion in 'AutoCAD' started by TCEBob, Feb 24, 2004.

  1. TCEBob

    TCEBob Guest

    Lots of tools available to transform text to mtext; best I know of is
    Express Tools TXT2MTXT. So. . .

    I want to write a function to "directly" insert mtext, character by
    character, on screen. Just like dtext. Proposed method: use dtext and
    then call t2mt. Problem: dtext, called by (command ) terminates the
    function. Here's a little test code wherein I tried calling dtext as a
    subroutine:

    (defun dtxt()
    (command "dtext")
    )

    (defun c:carryon()
    (dtxt)
    (princ "hello")
    (princ))

    Shows how little I know. The c:carryon routine executes the (princ
    "hello") line before the (dtxt). Oh, yeah, I also tried vl-cmdf. Same
    results.

    Suggestions, hints, speculations?

    rs
     
    TCEBob, Feb 24, 2004
    #1
  2. TCEBob

    TCEBob Guest

    Cheeze, James, you are fast! (While(Cmdactive) pause) will pause the
    current command. But you can't cheat and execute other lisp functions at
    the same time. Can you?

    rs
     
    TCEBob, Feb 24, 2004
    #2
  3. TCEBob

    OLD-CADaver Guest

    What are you trying to gain by such?
     
    OLD-CADaver, Feb 24, 2004
    #3
  4. TCEBob

    TCEBob Guest

    Satisfaction. Will it help me solve the problem if I examine my motive?

    rs
     
    TCEBob, Feb 24, 2004
    #4
  5. TCEBob

    TCEBob Guest

    Ya. There is no function that I can find which will write a temporary
    character to screen (like grdraw).

    Dtext writes each line as a separate entity, but only after the routine
    is completed because you can backspace between lines while the command
    is active. So I assume that it keeps a master list of characters,
    including line feed-carriage returns. It would sure be nice to salvage
    that master list. Probably a local variable.

    I appreciate your interest and hope you think of something!

    rs
     
    TCEBob, Feb 24, 2004
    #5
  6. TCEBob

    James Buzbee Guest

    I don't have time tonight - but let me check it out tomorrow - of course by
    then someone really smart will come along and figure it out for ya! ;-)

    So do you want to type a character and see it on the screen - just like
    dtext? Hmm . . . that would probably rule out activex . . .

    jb
     
    James Buzbee, Feb 25, 2004
    #6
  7. TCEBob

    ECCAD Guest

    Something like this ? You may have to tune it a bit.
    Uses grread.

    Bob
     
    ECCAD, Feb 25, 2004
    #7
  8. TCEBob

    TCEBob Guest

    Bob,

    I already found that one and gave it a spin. It works well, though I am
    scheming to make it behave more like an editor (move a pointer, keep the
    first and second halves of the string updated, make changes at the
    pointer, then weld first and second halves together again.) However in
    this case the problem is to enter new text on screen and when done have
    it turn magically into mtext.

    thanks for your assistance,

    rs
     
    TCEBob, Feb 25, 2004
    #8
  9. TCEBob

    OLD-CADaver Guest

    Yes, it may provide insight to an alternative function.
     
    OLD-CADaver, Feb 25, 2004
    #9
  10. TCEBob

    Joe Burke Guest

    TCEBob,

    Am I missing something here? Seems to do what you want.

    ;; 2/25/2004
    ;; enter dtext as usual
    ;; pause for start point
    ;; assumes Express Tools Txt2Mtxt is loaded
    (defun c:Dtxt2Mtxt ( / ent ss )
    (setq ent (entlast))
    (command "dtext" pause "" "")
    (setq ss (ssadd))
    (while (setq ent (entnext ent))
    (ssadd ent ss))
    (command "txt2mtxt" ss "")
    ) ;end

    Joe Burke
     
    Joe Burke, Feb 26, 2004
    #10
  11. TCEBob

    TCEBob Guest

    Doggone. It does work. I confess, I missed the importance of entlast. If
    I just say (command "dtext") the dtext routine will not allow a return
    to the program. Which is why the help warns not to use (command "dtext")
    unless it is the last line. So howcome your use does return?

    Many thanks,

    rs
     
    TCEBob, Feb 26, 2004
    #11
  12. TCEBob

    TCEBob Guest

    I added that to my macros file, with the small modification:
    (defun c:dm ( / ent ss pt) ;Mtext right to screen (needs express tools)
    ;credit to Joe Burke, acad.customization
    (setq ent (entlast))
    (setq pt (getpoint "\nStart point for Mtext: "))
    ;(command "dtext" pause "" "")
    (command "dtext" pt "" "")
    (setq ss (ssadd))
    (while (setq ent (entnext ent))
    (ssadd ent ss))
    (command "txt2mtxt" ss "")
    ) ;end

    rs
     
    TCEBob, Feb 26, 2004
    #12
  13. TCEBob

    Joe Burke Guest

    TCEBob,

    You're welcome.

    You can use command "dtext" as long as you provide all the command parameters up to
    the point of entering the text. IOW start point, height and angle are required
    arguments. If you omit any of them, the program plows ahead and you get an error.
    Apparently that's why you can use just (command "dtext) at the end because there's no
    following code.

    So if you want to enter the height and angle, something like (command "dtext" pt
    pause pause) will work.

    Joe Burke
     
    Joe Burke, Feb 27, 2004
    #13
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.