lisp to create text

Why does this not show a text edit cursor on screen the same as when the command is entered on the command line?

(command "TEXT" "j" "tc" PAUSE "3.5" "0" PAUSE)


Comments

  • Not the answer but user prompts.

    (command "TEXT" "j" "tc" (getpoint "\nPick point ") "3.5" "0" (getstring "\nEnter text " T))
  • Thanks for the suggestion
    ALANH said:

    Not the answer but user prompts.

    (command "TEXT" "j" "tc" (getpoint "\nPick point ") "3.5" "0" (getstring "\nEnter text " T))

  • This one is more laborious, but it might be useful, especially if the textbox editing behavior is required.
    
    (setq pt (getpoint "\nText insertion point: "))
      (if pt
        (progn
          (setq tx_ent (entmakex (list
                                    (cons 0 "TEXT")
                                    (cons 10 pt)
                                    (cons 11 pt)
                                    (cons 1 "")
                                    (cons 40 3.5)
                                    (cons 72 1)
                                    (cons 73 3)
                                  )
                        )
          )
          (vle-edittextinplace tx_ent)
        )
      )
    
  • Thanks Virgil
    This is exactly what I was looking to achieve.
    Virgil said:

    This one is more laborious, but it might be useful, especially if the textbox editing behavior is required.

    
    (setq pt (getpoint "\nText insertion point: "))
      (if pt
        (progn
          (setq tx_ent (entmakex (list
                                    (cons 0 "TEXT")
                                    (cons 10 pt)
                                    (cons 11 pt)
                                    (cons 1 "")
                                    (cons 40 3.5)
                                    (cons 72 1)
                                    (cons 73 3)
                                  )
                        )
          )
          (vle-edittextinplace tx_ent)
        )
      )
    
  • Virgil said:

    This one is more laborious, but it might be useful, especially if the textbox editing behavior is required.

    
    (setq pt (getpoint "\nText insertion point: "))
      (if pt
        (progn
          (setq tx_ent (entmakex (list
                                    (cons 0 "TEXT")
                                    (cons 10 pt)
                                    (cons 11 pt)
                                    (cons 1 "")
                                    (cons 40 3.5)
                                    (cons 72 1)
                                    (cons 73 3)
                                  )
                        )
          )
          (vle-edittextinplace tx_ent)
        )
      )
    
    Be aware that your solution can generate empty strings if the user picks outside the text box, presses enter, or hits the spacebar repeatedly. While you can use the PURGE command to get rid of empty text entities, it's better to avoid creating them in the first place.

    The following code adds a check on the edited text and deletes the text entity if it's an empty string or is made up of spaces.
    (defun C:CreateText ( / pt tx_ent txt)
        (setq pt (getpoint "\nText insertion point: "))
          (cond
            (pt
                (setq tx_ent (entmakex (list
                                        (cons 0 "TEXT")
                                        (cons 10 pt)
                                        (cons 11 pt)
                                        (cons 1 "")
                                        (cons 40 3.5)
                                        (cons 72 1)
                                        (cons 73 3)
                                      )
                            )
                    )
                
                (setq txt (vle-edittextinplace tx_ent)) ; capture generated text
                ;If the created text is an empty string or is made up of spaces
                (if (= (strlen txt) (1- (length (vle-string-split " " txt))))
                    (entdel tx_ent) ; delete the text entity
                )
            )
          )
        (prin1)
    )

    Regards,
    Jason Bourhill
    BricsCAD V24 Ultimate
    CAD Concepts
  • Thanks for the addition information, Jason.

    Virgil said:

    This one is more laborious, but it might be useful, especially if the textbox editing behavior is required.

    
    (setq pt (getpoint "\nText insertion point: "))
      (if pt
        (progn
          (setq tx_ent (entmakex (list
                                    (cons 0 "TEXT")
                                    (cons 10 pt)
                                    (cons 11 pt)
                                    (cons 1 "")
                                    (cons 40 3.5)
                                    (cons 72 1)
                                    (cons 73 3)
                                  )
                        )
          )
          (vle-edittextinplace tx_ent)
        )
      )
    
    Be aware that your solution can generate empty strings if the user picks outside the text box, presses enter, or hits the spacebar repeatedly. While you can use the PURGE command to get rid of empty text entities, it's better to avoid creating them in the first place.

    The following code adds a check on the edited text and deletes the text entity if it's an empty string or is made up of spaces.
    (defun C:CreateText ( / pt tx_ent txt)
        (setq pt (getpoint "\nText insertion point: "))
          (cond
            (pt
                (setq tx_ent (entmakex (list
                                        (cons 0 "TEXT")
                                        (cons 10 pt)
                                        (cons 11 pt)
                                        (cons 1 "")
                                        (cons 40 3.5)
                                        (cons 72 1)
                                        (cons 73 3)
                                      )
                            )
                    )
                
                (setq txt (vle-edittextinplace tx_ent)) ; capture generated text
                ;If the created text is an empty string or is made up of spaces
                (if (= (strlen txt) (1- (length (vle-string-split " " txt))))
                    (entdel tx_ent) ; delete the text entity
                )
            )
          )
        (prin1)
    )

    Regards,
    Jason Bourhill
    BricsCAD V24 Ultimate
    CAD Concepts