See the top rated post in this thread. Click here

Page 1 of 2 12 LastLast
Results 1 to 10 of 13

Thread: Handling autocad plugin dialog boxes (imitating user input)

  1. #1
    Member
    Join Date
    2016-02
    Posts
    25
    Login to Give a bone
    0

    Default Handling autocad plugin dialog boxes (imitating user input)

    Hi,
    can anybody tell me a few things about using autolisp or visuallisp to work with existing dialog boxes. I wouldn't call myself a beginner in lisp programming (and am far from expert), but have never had the need to use dialog boxes in my routines, so I don't know much about them.
    Specifically, I would like to know if there is a way to imitate user input in a dialog box of some autocad plugin. Even imitating pressing keyboard buttons would help. Or it isn't possible with lisp, since the command line isn't accesible when a dialog box appears?

  2. #2
    AUGI Addict
    Join Date
    2015-12
    Posts
    2,095
    Login to Give a bone
    0

    Default Re: Handling autocad plugin dialog boxes (imitating user input)

    You cannot have LISP "plug in" data to dialog boxes you haven't created (and are controlling). The usual process is to use a custom dialog to collect user input then feed that to either a command line version of the function, or a custom equivalent.

  3. #3
    Member
    Join Date
    2016-02
    Posts
    25
    Login to Give a bone
    0

    Default Re: Handling autocad plugin dialog boxes (imitating user input)

    Thanks for the reply, thought so. What would be the easiest way to work around this? Some simple programming in a language other than lisp? I literally need to just close a dialog box which appeears after executing a set of commands in a drawing, like pressing ENTER. A way to automatically input data in a dialog box would be a bonus, but I feel that would require significantly improving my programming skills.

  4. #4
    Certifiable AUGI Addict
    Join Date
    2001-03
    Location
    Tallahassee, FL USA
    Posts
    3,667
    Login to Give a bone
    0

    Default Re: Handling autocad plugin dialog boxes (imitating user input)

    If you have lisp that turns control over to a dialog box modify the lisp to stop doing that. If you are talking about a dialog box that pops up as a result of AutoCAD commands state which ones you are talking about, we may know a workaround for you.

  5. #5
    All AUGI, all the time
    Join Date
    2003-07
    Posts
    561
    Login to Give a bone
    0

    Default Re: Handling autocad plugin dialog boxes (imitating user input)

    Writing DCL can be a bit of a task but one way around this is by writing a library routine that can be used over multiple programs. So here is an example called getvals it allows you via 1 line in your code to instantly make a dialouge box and you do not have to worry about coding. Other universal ones are a list dialouge to allow pick from a selection of items.

    Code:
    ; Input  Dialog box with variable title
    ; multiple lines of dcl supported
    ; add extra lines if required by copying code defun
    ; By Alan H 2015
    
    ; example code just use these next two lines
    ; (if (not AH:getval1)(load "getvals.lsp"))
    ; (ah:getval1 "Enter size " 5 4)  ;
    
    ; 1 line dcl
    ; sample code (ah:getval1 "line 1" 5 4)
    (defun AH:getval1 (title width limit / fo)
    ; you can hard code a directory if you like for dcl file
    (setq fo (open (setq fn (vl-filename-mktemp "" "" ".dcl")) "w"))
    (write-line "ddgetval : dialog {" fo)
    (write-line " : row {" fo)
    (write-line ": edit_box {" fo)
    (write-line (strcat "    key = "  (chr 34) "key1" (chr 34) ";") fo)
    (write-line  (strcat " label = "  (chr 34) title (chr 34) ";"  )   fo)
    ; these can be replaced with shorter value etc
    (write-line (strcat "     edit_width = " (rtos width 2 0) ";" ) fo)
    (write-line (strcat "     edit_limit = " (rtos limit 2 0) ";" ) fo)
    (write-line "   is_enabled = true;" fo)
    (write-line "    }" fo)
    (write-line "  }" fo)
    (write-line "ok_only;}" fo)
    (close fo)
    
    (setq dcl_id (load_dialog  fname))
    (if (not (new_dialog "ddgetval" dcl_id))
    (exit))
    (action_tile "key1" "(setq val1 $value)")
    (mode_tile "key1" 3)
    (start_dialog)
    (done_dialog)
    (unload_dialog dcl_id)
    ; returns the value of val1 as a string
    ) ; defungetval1
    
    ; 2 line dcl
    ; sample code 
    ; (if (not AH:getval2)(load "getvals.lsp"))
    ; (ah:getval2 "line 1" 5 4 "line2" 8 7)
    
    (defun AH:getval2 (title1 width1 limit1 title2 width2 limit2 / fo)
    (setq fo (open (setq fn (vl-filename-mktemp "" "" ".dcl")) "w"))
    (write-line "ddgetval2 : dialog {" fo)
    (write-line " : column {" fo)
    (write-line ": edit_box {" fo)
    (write-line (strcat "    key = " (chr 34) "key1" (chr 34) ";") fo)
    (write-line  (strcat " label = "  (chr 34) title1 (chr 34) ";" ) fo)
    (write-line (strcat "     edit_width = " (rtos width1 2 0) ";" ) fo)
    (write-line (strcat "     edit_limit = " (rtos limit1 2 0) ";" ) fo)
    (write-line "   is_enabled = true ;" fo)
    (write-line "    }" fo)
    (write-line "spacer_1 ;" fo)
    (write-line ": edit_box {" fo)
    (write-line (strcat "    key = " (chr 34) "key2" (chr 34) ";") fo)
    (write-line (strcat " label = "  (chr 34) title2 (chr 34) ";"  ) fo)
    (write-line (strcat "     edit_width = " (rtos width2 2 0) ";" ) fo)
    (write-line (strcat "     edit_limit = " (rtos limit2 2 0) ";" ) fo)
    (write-line "   is_enabled = true ;" fo)
    (write-line "    }" fo)
    (write-line "    }" fo)
    (write-line "spacer_1 ;" fo)
    (write-line "ok_only;}" fo)
    (close fo)
    
    ; code part
    (setq dcl_id (load_dialog  fname))
    (if (not (new_dialog "ddgetval2" dcl_id))
    (exit))
    (mode_tile "key1" 3)
    (action_tile "key1" "(setq val1 $value)")
    (mode_tile "key2" 3)
    (action_tile "key2" "(setq val2 $value)")
    (start_dialog)
    (done_dialog)
    (unload_dialog dcl_id)
    ; returns the value of val1 and val2 as strings
    ) ; defungetval2
    
    ; 3 line dcl
    ; sample code
    ;(if (not AH:getval3)(load "getvals.lsp"))
    ;(ah:getval3 "line 1" 5 4 "line2" 8 7 "line3" 6 4)
    
    (defun AH:getval3 (title1 width1 limit1 title2 width2 limit2 title3 width3 limit3 / fo)
    (setq fo (open (setq fn (vl-filename-mktemp "" "" ".dcl")) "w"))
    (write-line "ddgetval3 : dialog {" fo)
    (write-line " : column {" fo)
    (write-line ": edit_box {" fo)
    (write-line (strcat "    key = " (chr 34) "key1" (chr 34) ";") fo)
    (write-line  (strcat " label = "  (chr 34) title1 (chr 34) ";" ) fo)
    (write-line (strcat "     edit_width = " (rtos width1 2 0) ";" ) fo)
    (write-line (strcat "     edit_limit = " (rtos limit1 2 0) ";" ) fo)
    (write-line "   is_enabled = true ;" fo)
    (write-line "    }" fo)
    (write-line "spacer_1 ;" fo)
    (write-line ": edit_box {" fo)
    (write-line (strcat "    key = " (chr 34) "key2" (chr 34) ";") fo)
    (write-line (strcat " label = "  (chr 34) title2 (chr 34) ";"  ) fo)
    (write-line (strcat "     edit_width = " (rtos width2 2 0) ";" ) fo)
    (write-line (strcat "     edit_limit = " (rtos limit2 2 0) ";" ) fo)
    (write-line "   is_enabled = true ;" fo)
    (write-line "    }" fo)
    (write-line "spacer_1 ;" fo)
    (write-line ": edit_box {" fo)
    (write-line (strcat "    key = " (chr 34) "key3" (chr 34) ";") fo)
    (write-line (strcat " label = "  (chr 34) title3 (chr 34) ";"  ) fo)
    (write-line (strcat "     edit_width = " (rtos width3 2 0) ";" ) fo)
    (write-line (strcat "     edit_limit = " (rtos limit3 2 0) ";" ) fo)
    (write-line "   is_enabled = true ;" fo)
    (write-line "    }" fo)
    (write-line "    }" fo)
    (write-line "spacer_1 ;" fo)
    (write-line "ok_only;}" fo)
    (close fo)
    
    ; code part
    (setq dcl_id (load_dialog  fname))
    (if (not (new_dialog "ddgetval3" dcl_id))
    (exit))
    (mode_tile "key1" 3)
    (action_tile "key1" "(setq val1 $value)")
    (mode_tile "key2" 3)
    (action_tile "key2" "(setq val2 $value)")
    (mode_tile "key3" 3)
    (action_tile "key3" "(setq val3 $value)")
    (start_dialog)
    (done_dialog)
    (unload_dialog dcl_id)
    ; returns the value of val1 and val2 val3 as strings
    ) ; defungetval3
    Attached Images Attached Images

  6. #6
    Member
    Join Date
    2016-02
    Posts
    25
    Login to Give a bone
    0

    Default Re: Handling autocad plugin dialog boxes (imitating user input)

    Thank you, but I am aware I can control my own dialog boxes (but am yet to learn how to implement them in my routines). I wanted to know if I could simulate pressing OK or ESC for any dialog box that pops up, and then continue my lisp routine. I found a workaround using a utility called Hot Keyboard Pro (automation tool). Pretty awesome app, would recommend to anyone who doesn't have extensive programming knowledge, like myself (and no, this isn't an advertisement ). Thanks again!

  7. #7
    Certifiable AUGI Addict
    Join Date
    2001-03
    Location
    Tallahassee, FL USA
    Posts
    3,667
    Login to Give a bone
    0

    Default Re: Handling autocad plugin dialog boxes (imitating user input)

    Quote Originally Posted by mattko View Post
    Thank you, but I am aware I can control my own dialog boxes (but am yet to learn how to implement them in my routines). I wanted to know if I could simulate pressing OK or ESC for any dialog box that pops up, and then continue my lisp routine. I found a workaround using a utility called Hot Keyboard Pro (automation tool). Pretty awesome app, would recommend to anyone who doesn't have extensive programming knowledge, like myself (and no, this isn't an advertisement ). Thanks again!
    Again for a dialog box that pops up as a result of AutoCAD commands state which ones you are talking about, many have workarounds while others can be replaced with a little code.

    Hard to give more of an answer without knowing what you want to do.

  8. #8
    Member
    Join Date
    2016-02
    Posts
    25
    Login to Give a bone
    0

    Default Re: Handling autocad plugin dialog boxes (imitating user input)

    Not exactly Autocad commands, I know almost every dialog box can be avoided by preceding a command with "-" . The dialog boxes in question appear after generating building elements from lines/polylines/etc using Advance Concrete, prompting for user input about element properties. I have managed to relatively easy automate mouse and keyboard events using before mentioned utility. May not be the most elegant solution, but it works

  9. #9
    Administrator Opie's Avatar
    Join Date
    2002-01
    Location
    jUSt Here (a lot)
    Posts
    9,106
    Login to Give a bone
    1

    Default Re: Handling autocad plugin dialog boxes (imitating user input)

    AutoLISP, as you've discovered, cannot automate the user interaction with dialog boxes.
    If you have a technical question, please find the appropriate forum and ask it there.
    You will get a quicker response from your fellow AUGI members than if you sent it to me via a PM or email.
    jUSt

  10. #10
    Woo! Hoo! my 1st post
    Join Date
    2024-02
    Posts
    1
    Login to Give a bone
    0

    Default Re: Handling autocad plugin dialog boxes (imitating user input)

    Quote Originally Posted by Tom Beauford View Post
    Again for a dialog box that pops up as a result of AutoCAD commands state which ones you are talking about, many have workarounds while others can be replaced with a little code.

    Hard to give more of an answer without knowing what you want to do.
    Hey Tom, Are you still active on here? I was looking through this thread and am trying to figure out a similar problem.

Page 1 of 2 12 LastLast

Similar Threads

  1. Replies: 1
    Last Post: 2017-04-15, 03:28 PM
  2. 2015: air handling unit - plugin
    By MEP2 in forum Revit MEP - Families
    Replies: 0
    Last Post: 2015-07-24, 06:02 PM
  3. 2013: AutoCAD 2013 not responding and missing dialog boxes
    By george.gilbert627321 in forum AutoCAD General
    Replies: 8
    Last Post: 2014-04-18, 02:16 PM
  4. 2014: How to turn off balloon tips in Autocad dialog boxes?
    By laysh in forum AutoCAD General
    Replies: 3
    Last Post: 2013-08-12, 06:16 PM
  5. 2013: AutoCAD 2013 Some dialog boxes not displaying
    By rick in forum AutoCAD General
    Replies: 10
    Last Post: 2012-12-14, 05:50 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •