LISP expression in TEXT

Discussion in 'AutoCAD' started by Alexander V. Koshman, Jan 12, 2004.

  1. Good evening (here's evening!)
    or any another time of the day!
    -----------------------------------
    I would know how to pass a LISP expression
    or variable to any of single-line text commands
    to get the *beginning* of the string and allow
    to user to type the *rest* of it while

    (while (= (getvar "CMDACTIVE") 1)
    (command pause)
    ) ; - 'command'

    if it's possible.

    I tried TEXTEVAL with (command txt) and (princ txt)
    and (eval txt) and TEXT and -TEXT and DTEXT...
    Without any success...

    If there is some way or it IS hopeless?

    Thank you in advance!
     
    Alexander V. Koshman, Jan 12, 2004
    #1
  2. Alexander V. Koshman

    RDI Guest

    If I understand what you're asking for, this might point you in the right
    direction. It sits in a loop and accepts one character at a time and
    appends them into a string. As soon as you press enter, it quits. The end
    result is a variable named newTxt.

    (setq tst 1 newTxt "")
    (while tst
    (setq char(grread nil))
    ; (alert (itoa (cadr char)))
    (if(= 2(car char))
    (cond
    ;if it's 13, then return was pressed.
    ((=(cadr char)13)(setq tst nil))

    ;if it's 8 then a backspace was pressed
    ((and (> (strlen newTxt) 0)(=(cadr char) 8))(setq newTxt(substr newTxt
    1 (- (strlen newTxt) 1))))

    ;if it's NOT a backspace or return then append the character to the
    string
    ((and (or (< (cadr char) 13)(>(cadr char)13))
    (or (< (cadr char) 8)(>(cadr char)8)))
    ;append the string here
    (setq newTxt(strcat newTxt (chr (cadr char))))
    );end of last condition
    )
    )
    ;(alert newTxt)
    )

    HTH
     
    RDI, Jan 12, 2004
    #2
  3. Hello!
    -------
    I think about making something like "in-place" Single-line
    Text editing if it's possible.
    My plan was:
    1. ask the user to select a text string ("TEXT" object);
    2. get its content, height, style, justification, start point, rotation ...;
    3. then I want to run the Text or DText command that write the
    beginning of the string with old content:
    4. and
    (while (= (getvar "CMDACTIVE") 1)
    (command pause)
    )
    then to allow user to enter the rest of or modify the old string content.

    What do you think?
    I think it is impossible.
     
    Alexander V. Koshman, Jan 13, 2004
    #3
  4. Alexander V. Koshman

    Mark Propst Guest

    I don't understand.
    how is that different from "Tedit" command?
     
    Mark Propst, Jan 13, 2004
    #4
  5. Hello Mark!
    --------------
    I want to edit the string similar to creating it
    In-place - directly IN THE DRAWING
    and not in some Dialog as DDEDIT did...
    It was not a good idea I see...
     
    Alexander V. Koshman, Jan 14, 2004
    #5
  6. Alexander V. Koshman

    ECCAD Guest

    There are only (2) places to accept 'text' imput. 1>Dialog box,
    2>at Command prompt.
    Attached Lisp modifies the text entry, adds string (char at a time) until <Enter>. Is this what you wanted ?
    Bob
     
    ECCAD, Jan 14, 2004
    #6
  7. Alas, NO, ECCAD!
     
    Alexander V. Koshman, Jan 15, 2004
    #7
  8. Alexander V. Koshman

    BillZ Guest

    Alexander,
    This might get you going in the right direction:

    (defun chang_text ()
    (setq txt (car (entsel "\nSelect Text: <>"))
    ent (entget txt)
    txt_ht (cdr (assoc 40 ent))
    txt_val (cdr (assoc 1 ent))
    xbase (cadr (assoc 10 ent))
    ybase (caddr (assoc 10 ent))
    )
    (setq start_pt (list (+ xbase (caadr (textbox (entget txt))))(+ ybase(cadar (textbox (entget txt)))))
    )
    (command "dtext" start_pt txt_ht "0")
    (setq txt2 (entlast)
    2nd_val (entget txt2)
    new_txt_val (strcat txt_val (cdr (assoc 1 2nd_val)))
    ent (subst (cons 1 new_txt_val)(assoc 1 ent) ent)
    )

    (entmod ent)
    (entdel txt2)
    (princ)
    )

    Bill
     
    BillZ, Jan 15, 2004
    #8
  9. Alexander V. Koshman

    ECCAD Guest

    Bill,
    Kool ! I didn't think to use 'textbox'. Works great.
    Bob
     
    ECCAD, Jan 15, 2004
    #9
  10. Sorry Bill!
    -----------
    It's really cool with textbox, but it isn't that I want
    because the user *can not* press BackSpace
    and really EDIT the source string content!
    He can *only* ADD a new part!

    Now I'm a pessimist...
     
    Alexander V. Koshman, Jan 16, 2004
    #10
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.