AutoCAD2021 pop-up window in lisp

AutoCAD2021 pop-up window in lisp

BB8x
Advocate Advocate
418 Views
5 Replies
Message 1 of 6

AutoCAD2021 pop-up window in lisp

BB8x
Advocate
Advocate

In old AutoCAD2014 I was using lisps with good and old LeeMac lm:listbox. Issue is in AutoCAD2021 it does not work. I spent with claude few hours and 30+ attempt to find another way of displaying populated pop-up window in AutoCAD2021. All failure, almost always lisp like that turned cursor to busy and all I was able to do is zoom in and out before forcing AutoCAD to close. 

Do you know by a chance how to modify bellow or know other way to display populated pop-up window in AutoCAD2021 with Lee Mac's lm:listbox funtionalities?

;; List Box - Lee Mac
(defun LM:listbox (msg lst bit / dch des tmp rtn)
  (cond
    ((not
      (and
        (setq tmp (vl-filename-mktemp nil nil ".dcl"))
        (setq des (open tmp "w"))
        (write-line
          (strcat "listbox:dialog{label=\"" msg "\";spacer;:list_box{key=\"list\";multiple_select="
                  (if (= 1 (logand 1 bit)) "true" "false") 
                  ";width=55;height=35;}spacer;ok_cancel;}")
          des
        )
        (not (close des))
        (< 0 (setq dch (load_dialog tmp)))
        (new_dialog "listbox" dch)
      )
     )
     (prompt "\nError Loading List Box Dialog.")
    )
    (t
      (start_list "list")
      (foreach itm lst (add_list itm))
      (end_list)
      (setq rtn (set_tile "list" "0"))
      (action_tile "list" "(setq rtn $value)")
      (setq rtn
        (if (= 1 (start_dialog))
          (if (= 2 (logand 2 bit))
            (read (strcat "(" rtn ")"))
            (mapcar '(lambda (x) (nth x lst)) (read (strcat "(" rtn ")")))
          )
        )
      )
    )
  )

 

0 Likes
Accepted solutions (1)
419 Views
5 Replies
Replies (5)
Message 2 of 6

cadffm
Consultant
Consultant

Hi,

 

I don't know if it was just a copy&paste issue (while create your post) ,

or you changed something in your lisp file, because this can't run in no version, also not in 2014.

 

Added a missing bracket, tried dummy values and it works as expected in newer and older version,

but I can't test it in 2021. If it doesn't work in 2021, there must be a bug. I am sure there isn't.

 

cadffm_0-1739922009976.png

 

(Note, Lisp board is the next door. Overview of AutoCAD for windows Boards: https://forums.autodesk.com/t5/autocad/ct-p/8 )

Sebastian

0 Likes
Message 3 of 6

BB8x
Advocate
Advocate

It is just a bracked, dcl seems to be not very welcome in 2021 version
Original Lee Mac

;; List Box  -  Lee Mac
;; Displays a DCL list box allowing the user to make a selection from the supplied data.
;; msg - [str] Dialog label
;; lst - [lst] List of strings to display
;; bit - [int] 1=allow multiple; 2=return indexes
;; Returns: [lst] List of selected items/indexes, else nil

(defun LM:listbox ( msg lst bit / dch des tmp rtn )
    (cond
        (   (not
                (and
                    (setq tmp (vl-filename-mktemp nil nil ".dcl"))
                    (setq des (open tmp "w"))
                    (write-line
                        (strcat "listbox:dialog{label=\"" msg "\";spacer;:list_box{key=\"list\";multiple_select="
                            (if (= 1 (logand 1 bit)) "true" "false") ";width=50;height=15;}spacer;ok_cancel;}"
                        )
                        des
                    )
                    (not (close des))
                    (< 0 (setq dch (load_dialog tmp)))
                    (new_dialog "listbox" dch)
                )
            )
            (prompt "\nError Loading List Box Dialog.")
        )
        (   t     
            (start_list "list")
            (foreach itm lst (add_list itm))
            (end_list)
            (setq rtn (set_tile "list" "0"))
            (action_tile "list" "(setq rtn $value)")
            (setq rtn
                (if (= 1 (start_dialog))
                    (if (= 2 (logand 2 bit))
                        (read (strcat "(" rtn ")"))
                        (mapcar '(lambda ( x ) (nth x lst)) (read (strcat "(" rtn ")")))
                    )
                )
            )
        )
    )
    (if (< 0 dch)
        (unload_dialog dch)
    )
    (if (and tmp (setq tmp (findfile tmp)))
        (vl-file-delete tmp)
    )
    rtn
)
0 Likes
Message 4 of 6

cadffm
Consultant
Consultant

I am not sure about what you trying to say.

It works all in 2021 the same way as in other versions.

Sebastian

0 Likes
Message 5 of 6

BB8x
Advocate
Advocate

Lisp works great in 2014 in 2021 is not working as bellow
1.png2.png3.png

Alternatively maybe someone know how to get pop-up window via lisp

   

0 Likes
Message 6 of 6

BB8x
Advocate
Advocate
Accepted solution

Well,  sorted
Support file paths were not properly defined