Lisp command function and Text (or Dtext)

I am trying to get my lisp program with (command "TEXT") to work the same as if entering from the command line.
I cannot get the Text cursor to appear from lisp, so you have no clue that you are supposed to type something (other than the command line prompt). This is even worse with mtext, as the text doesn't even show up until you hit enter.
It works fine in the other CAD program.
just run (command "mtext") from the command line and you will see what I mean.
Using Version 19.2.14
Anyone have a workaround for this?

Comments

  • In my v17, (command "text") works the same as entering TEXT from the command line, but (command "mtext") has the problem you described. Here's an underhanded workaround, whose only fault that I could see in first trial is that it leaves an extra blank space at the end of the new mtext entity:

    (defun c:MT (/) (setq p1 (getpoint "First corner of mtext: ")) (setq p2 (getcorner p1 "Second corner of mtext: ")) (command "mtext" p1 p2 " " "") (while (> (getvar "cmdactive") 0) (command pause)) (sssetfirst nil (ssget "L")) (command "ddedit") (while (> (getvar "cmdactive") 0) (command pause)) )

  • Thanks Anthony!
    I had not even thought about ddedit, since I haven't used that command since maybe autocad 2004? I successfully used your idea to make a few of my Annotation routines work.
    Even a decent multileader (create leader and mtext and then delete and replace with mleader).
    Your input is much appreciated!

  • Actually, I think you've been using ddedit all along, but without knowing it. I didn't know it either -- didn't even remember that there was such a command. But when I saw the difference between mtext and (command "mtext") I thought, "it's really just using the mtext command to define the location and size of the entity, i.e. to create the new entity, and then it's jumping into the mtext editor to do the rest." Then I looked at the command line, to see what it would say after I double-click on an mtext entity to start the editor, and it said _ddedit.

  • Being new to BricsCAD, there is a bit of learning curve for me. DDEDIT was deemed obsolete in AutoCAD 2015, although typing it starts the TEXTEDIT command (as does a double click) in AutoCAD. TEXTEDIT does nothing in BricsCAD. I will have to get v20 and see how that impacts my code.
    cheers.
    -steve

  • Anthony Apostolaros
    edited October 2019

    On my v17, entering ddedit (or double-clicking on a text or mtext) puts me in a mode in which I can edit any text or mtext I pick, and as many of them as I want, until I hit Enter or Space or Escape instead of picking one. Pretty nice, I think.

    That's with TextEditMode = 0 = "Multiple edit mode (command repeats until cancelled)." There's also a single edit mode, and a mode that's single if you pre-select and multiple if you don't. But I always start the process by double-clicking on something, which apparently counts as a pre-selection.

  • Anthony
    Have you tried creating plain text (0 . "TEXT") with entmake?
    I cannot seem to create any text with a "Right" justification no matter how I manipulate 10,11,71,72 & 73 codes.
    Have you run into this?
    -steve

  • Roy Klein Gebbinck
    edited November 2019

    Seems to work fine (V18):

    (entmake
      '(
        (0 . "TEXT")
        (8 . "0")
        (10 0.0 0.0 0.0)
        (40 . 2.5)
        (1 . "abc")
        (50 . 0.0)
        (7 . "Standard")
        (72 . 2)
        (11 0.0 0.0 0.0)
      )
    )
    
  • Anthony Apostolaros
    edited November 2019

    Steve,

    I haven't tried that, but I've run into a different problem with text justification. I wrote a custom command to give a text entity right justification. If it had worked, you could've used it to set the justification of the "Last" entity immediately after creating a new text entity.

    But it doesn't work. It does give the selected text right justification, but it also moves it to 0,0. I don't understand why it does that. Giving a text left or center justification by the same method doesn't move it.

    I tried saving the original location and then moving the text back there after the justification change, but that didn't help.

    And another glitch: I can't seem to paste the code in here. So I'm attaching it as a lisp file. But it'll only show you something that doesn't work.

    Sorry I can't help. There are many people on this forum and at The Swamp who are much better at lisp than I am. Maybe one of them knows how to do it.

  • Got it now. Appears to work with (10 0.0 0.0 0.0) and the actual WCS insertion point for 11. ( i didn't help myself with a rookie mistake with (cons 10 0.0 0.0 0. 0) ... dang)
    Thanks for you snippet Roy. Helped me see that it does work.