Author Topic: How to Create a Dialog Box  (Read 7655 times)

0 Members and 1 Guest are viewing this topic.

bmossman

  • Guest
How to Create a Dialog Box
« on: July 24, 2008, 02:05:58 PM »
Can someone steer me in the right direction on creating a dialog box with check boxes that run script files?

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
Re: How to Create a Dialog Box
« Reply #1 on: July 24, 2008, 02:18:20 PM »
By Script Files, do you mean other lisp routines?

I would think you would want buttons for each routine. But do you want to check several & have then run concurrently?

More explanation is needed. Can you describe the process you want the user to do & what the dialog box is to do for the user?
I've reached the age where the happy hour is a nap. (°¿°)
Windows 10 core i7 4790k 4Ghz 32GB GTX 970
Please support this web site.

bmossman

  • Guest
Re: How to Create a Dialog Box
« Reply #2 on: July 24, 2008, 02:32:45 PM »
By Script Files, do you mean other lisp routines?

I would think you would want buttons for each routine. But do you want to check several & have then run concurrently?

More explanation is needed. Can you describe the process you want the user to do & what the dialog box is to do for the user?

I have a series of script files that manipulate layering to achieve a certain plan. I would like for a user to  bring up the dialog box and have the option to check multiple plan options that would call the corresponding script commands. See below:

[X]     Site Plan
[  ]     Landscape Plan
[X]     Utility Plan


CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
Re: How to Create a Dialog Box
« Reply #3 on: July 24, 2008, 05:03:57 PM »
Here's a quick example of how to set up the lisp & dcl file.
Download the dcl into a folder in the ACAD search path.
Then load & run the lisp.
You will need to fill in what script action is needed.
Code: [Select]
(defun c:LayerSetUp(/ dclfile dcl# action layers2load)
  (vl-load-com)
  (defun get_checks(/ result)
    (if (= (get_tile "ck1") "1")
      (setq result (cons "Site Plan" result))
    )
    (if (= (get_tile "ck2") "1")
      (setq result (cons "Landscape Plan" result))
    )
    (if (= (get_tile "ck3") "1")
      (setq result (cons "Utility Plan" result))
    )
    result
  )
  ;;================================================================
  ;;                    Start of Routine                           
  ;;================================================================
  (setq dclfile "LayersSetUp.dcl")
  (cond
    ((< (setq dcl# (load_dialog dclfile)) 0) (prompt (strcat "\nCannot load " dclfile ".")))
    ((not (new_dialog "layersetup" dcl#)) (prompt (strcat "\nProblem with " dclfile ".")))
    (t ; No DCL problems: fire it up
      ;;  set actions
      (action_tile "accept" ; DCL OK exit action
                   "(setq layers2load (get_checks)) (done_dialog 1)")
       (setq action (start_dialog))
       (unload_dialog dcl#)
       (if (= action 1) ; OK was pressed
         (progn
           (print "OK was pressed")
           ;;  do you scripr files here
           ;; layers2load = a list of checked items
         )
         (print "User Quit.")
       )
    )
  ) ; end cond
  (princ)
)
(prompt "\nLayer Setup loaded, enter LayerSetUp to run.")
(princ)
I've reached the age where the happy hour is a nap. (°¿°)
Windows 10 core i7 4790k 4Ghz 32GB GTX 970
Please support this web site.

Patrick_35

  • Guest
Re: How to Create a Dialog Box
« Reply #4 on: July 25, 2008, 05:04:14 AM »
Hi

You have this great site

@+

jbuzbee

  • Swamp Rat
  • Posts: 851
Re: How to Create a Dialog Box
« Reply #5 on: July 25, 2008, 07:05:10 AM »
James Buzbee
Windows 8

bmossman

  • Guest
Re: How to Create a Dialog Box
« Reply #6 on: July 28, 2008, 08:25:46 AM »
Here's a quick example of how to set up the lisp & dcl file.
Download the dcl into a folder in the ACAD search path.
Then load & run the lisp.
You will need to fill in what script action is needed.
Code: [Select]
(defun c:LayerSetUp(/ dclfile dcl# action layers2load)
  (vl-load-com)
  (defun get_checks(/ result)
    (if (= (get_tile "ck1") "1")
      (setq result (cons "Site Plan" result))
    )
    (if (= (get_tile "ck2") "1")
      (setq result (cons "Landscape Plan" result))
    )
    (if (= (get_tile "ck3") "1")
      (setq result (cons "Utility Plan" result))
    )
    result
  )
  ;;================================================================
  ;;                    Start of Routine                           
  ;;================================================================
  (setq dclfile "LayersSetUp.dcl")
  (cond
    ((< (setq dcl# (load_dialog dclfile)) 0) (prompt (strcat "\nCannot load " dclfile ".")))
    ((not (new_dialog "layersetup" dcl#)) (prompt (strcat "\nProblem with " dclfile ".")))
    (t ; No DCL problems: fire it up
      ;;  set actions
      (action_tile "accept" ; DCL OK exit action
                   "(setq layers2load (get_checks)) (done_dialog 1)")
       (setq action (start_dialog))
       (unload_dialog dcl#)
       (if (= action 1) ; OK was pressed
         (progn
           (print "OK was pressed")
           ;;  do you scripr files here
           ;; layers2load = a list of checked items
         )
         (print "User Quit.")
       )
    )
  ) ; end cond
  (princ)
)
(prompt "\nLayer Setup loaded, enter LayerSetUp to run.")
(princ)

Thanks Cab...That worked beautifully

bmossman

  • Guest
Re: How to Create a Dialog Box
« Reply #7 on: July 28, 2008, 08:53:37 AM »
How do you call a script file from within lisp?

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
Re: How to Create a Dialog Box
« Reply #8 on: July 28, 2008, 09:03:10 AM »
If you are talking about another lisp you use
(my-lisp-name) when the lisp starts like this (defun my-lisp-name
or this
(c:my-lisp-name) when the lisp starts like this (defun c:my-lisp-name
I've reached the age where the happy hour is a nap. (°¿°)
Windows 10 core i7 4790k 4Ghz 32GB GTX 970
Please support this web site.

bmossman

  • Guest
Re: How to Create a Dialog Box
« Reply #9 on: July 28, 2008, 09:09:08 AM »
It's actually a command. Don't I have to call the command function similar to this:

(command "script" "script file name here")

Alan Cullen

  • Guest
Re: How to Create a Dialog Box
« Reply #10 on: July 28, 2008, 09:23:20 AM »
(sorry CAB...about time I joined in here...hope you don't mind)

For invocing a script file...which is a series of commands, then you must issue each command as you would issue a command from within lisp. In other words you have a lisp within a lisp, but not as the same stucture you would use as a script file......

Use this format for each command.....

(command "CHANGE" sspipe "" "P" "C" pen12 "")
(command "chprop" "L" "" "C" ptc "LA" ptlay "" )
(command "COPY" name "" p1 p6)
(command "ELLIPSE" p1 p2 p3)
(command "ERASE" sstxt "")

call it whatever...but comply with CAB's advise...and call it in as CAB suggested.

A script ceases to be a script if you want to invoke it from within a lisp routine.

I really hope that makes sense......... :|

bmossman

  • Guest
Re: How to Create a Dialog Box
« Reply #11 on: July 28, 2008, 09:28:36 AM »
Ok, I inserted the the command to call the script files, but how do i associate the script file to the corresponding function in the dialog box?

ie, line 5 corresponds to line 33
and line 6 corresponds to line 34

Quote
(defun c:LayerSetUp(/ dclfile dcl# action layers2load)
  (vl-load-com)
  (defun get_checks(/ result)
    (if (= (get_tile "ck1") "1")
      (setq result (cons "Site Plan" result))
    )
    (if (= (get_tile "ck2") "1")
      (setq result (cons "GEOMETRY Plan" result))
    )
    (if (= (get_tile "ck3") "1")
      (setq result (cons "Utility Plan" result))
    )
    result
  )
  ;;================================================================
  ;;                    Start of Routine                           
  ;;================================================================
  (setq dclfile "LayersSetUp.dcl")
  (cond
    ((< (setq dcl# (load_dialog dclfile)) 0) (prompt (strcat "\nCannot load " dclfile ".")))
    ((not (new_dialog "layersetup" dcl#)) (prompt (strcat "\nProblem with " dclfile ".")))
    (t ; No DCL problems: fire it up
      ;;  set actions
      (action_tile "accept" ; DCL OK exit action
                   "(setq layers2load (get_checks)) (done_dialog 1)")
       (setq action (start_dialog))
       (unload_dialog dcl#)
       (if (= action 1) ; OK was pressed
         (progn
           (print "OK was pressed")
      (command "script" "M:/Resources/Acad/Scripts/S-SITE.scr")
      (command "script" "M:/Resources/Acad/Scripts/S-GEOM.scr")
          ;;  do you scripr files here
           ;; layers2load = a list of checked items
         )
         (print "User Quit.")
       )
    )
  ) ; end cond
  (princ)
)
(prompt "\nLayer Setup loaded, enter LayerSetUp to run.")
(princ)

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
Re: How to Create a Dialog Box
« Reply #12 on: July 28, 2008, 09:35:30 AM »
Alan, thank you for juping in. :-)

I already typed this so here are my comments:

Usually you would supply the COMMAND with the same information you type at the
ACAD Command Line. Like this:
Code: [Select]
Command: zoom                                                 
                                                             
Specify corner of window, enter a scale factor (nX or nXP), or
[All/Center/Dynamic/Extents/Previous/Scale/Window] <real time>: e
       
So the lisp code would look like this:
Code: [Select]
(command "zoom" "e")
You may use Lisp variables to supply arguments to the commands.
Using the ACAD LINE command you might want to have the Lisp supply the points
needed to draw the line. Something like this:
Code: [Select]
(setq pt1 '(0 0))
(setq pt2 '(10 20))
(command "line" pt1 pt2 "")
Note that the "" is the same as pressing the ENTER key when you are entering
information at the command line.

Alan feel free to continue, please.
I've reached the age where the happy hour is a nap. (°¿°)
Windows 10 core i7 4790k 4Ghz 32GB GTX 970
Please support this web site.

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
Re: How to Create a Dialog Box
« Reply #13 on: July 28, 2008, 09:41:38 AM »
Perhaps this will do what you want.
Note that there are many ways to set this up and this is only one example:
Code: [Select]
(defun c:LayerSetUp(/ dclfile dcl# action layers2load)
  (vl-load-com)
  (defun get_checks(/ result)
    (if (= (get_tile "ck1") "1")
      (setq result (cons "Site Plan" result))
    )
    (if (= (get_tile "ck2") "1")
      (setq result (cons "Landscape Plan" result))
    )
    (if (= (get_tile "ck3") "1")
      (setq result (cons "Utility Plan" result))
    )
    result
  )
  ;;================================================================
  ;;                    Start of Routine                           
  ;;================================================================
  (setq dclfile "LayersSetUp.dcl")
  (cond
    ((< (setq dcl# (load_dialog dclfile)) 0) (prompt (strcat "\nCannot load " dclfile ".")))
    ((not (new_dialog "layersetup" dcl#)) (prompt (strcat "\nProblem with " dclfile ".")))
    (t ; No DCL problems: fire it up
      ;;  set actions
      (action_tile "accept" ; DCL OK exit action
                   "(setq layers2load (get_checks)) (done_dialog 1)")
       (setq action (start_dialog))
       (unload_dialog dcl#)
       (if (= action 1) ; OK was pressed
         (progn
           (print "OK was pressed")
           ;;  do you scripr files here
           ;; layers2load = a list of checked items
           (if (member "Site Plan" layers2load)
             (command "script" "M:/Resources/Acad/Scripts/S-SITE.scr")
           )
           (if (member "Landscape Plan" layers2load)
             (command "script" "M:/Resources/Acad/Scripts/S-GEOM.scr")
           )
           (if (member "Utility Plan" layers2load)
             (princ)
           )
         )
         (print "User Quit.")
       )
    )
  ) ; end cond
  (princ)
)
(prompt "\nLayer Setup loaded, enter LayerSetUp to run.")
(princ)
I've reached the age where the happy hour is a nap. (°¿°)
Windows 10 core i7 4790k 4Ghz 32GB GTX 970
Please support this web site.

Alan Cullen

  • Guest
Re: How to Create a Dialog Box
« Reply #14 on: July 28, 2008, 09:46:24 AM »
Yup...thanks CAB...I reckon you nailed it

I just thought it was time I earnt my place here...so I will try to help with lisp where I can. I'm still trying to come to grips with the level of knowledge that exists here with regard to lisp.