Visual LISP, AutoLISP and General Customization
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Using DCl to open another dialog while closing the current dialog

11 REPLIES 11
SOLVED
Reply
Message 1 of 12
dvertz
1812 Views, 11 Replies

Using DCl to open another dialog while closing the current dialog

I have a need to setup "pages" in my dialogs. The help file states this can be done but doesn't go into any detail on how. I assumed it would be with closing the current dialog and opening the next. But I cannot seem to get it to work.

 

I understand why "(done_dialog) (shownext)" would fail. That's because it would close the current (and stop processing the code) before issuing the command for the next to show.

 

But there is a different issue by swapping the positions to "(shownext) (done_dialog)". I believe its because the interpreter gets confused about which dialog is to be "done". When it is ran this way the result is the next dialog appears and the program freezes. You can't close the current, but you can move it. When you move it, you can find the first dialog underneath. But you can't close that one either. At this point it is required to kill Autocad.

 

Does anyone know how to write the code to show pages in DCL?

Civil 3D 2022,
Windows 10 Pro, x64, Nvidia Quadro P1000
Intel Core i9-11900k; 3.50GHz, 32 GB RAM, 500GB WD BLACK M.2


11 REPLIES 11
Message 2 of 12
rkmcswain
in reply to: dvertz

 

        Are you talking about nested dialog boxes, like this?

R.K. McSwain     | CADpanacea | on twitter
Message 3 of 12
dvertz
in reply to: rkmcswain

I am afraid that nesting dialogs is not what I am looking to do. As I have too many pages and it would go beyond the 8 levels max. As I want to select a button and have the current dialog removed and open a new dialog at the same time. I understand how to nest dialogs and I understand how to hide dialogs for screen selection and then have the dialog come back. I am attempting to remove a nested dialog requiring extra buttons to initiate the next page in a series of dialogs. If the dialog was just hidden, to display the next dialog, then how would I get ride of it when all pages were done. (terminate maybe?) If the dialogs are just hidden does that impose the limit of 8 max?

Civil 3D 2022,
Windows 10 Pro, x64, Nvidia Quadro P1000
Intel Core i9-11900k; 3.50GHz, 32 GB RAM, 500GB WD BLACK M.2


Message 4 of 12
hak_vz
in reply to: dvertz

On this forum we've had similar requests before. If you search trough past forum posts you may find several solution. There are various approaches to the problem. I personally use the method that before closing dialog box,either to run some command or to start new dialog, close main dialog and store its values  to temporary file and depending on selected action perform that action. When sub-dialog is closed on its closing one can open main dialog. Each dialog box has its own dialog id. It's maybe a little bit complicated to handle multiple ids but this way if done well there is no way to break the window queue and to halt Autocad. Check this post for more details

 

 

Miljenko Hatlak

EESignature

Did you find this post helpful? Feel free to Like this post.
Did your question get successfully answered? Then click on the ACCEPT SOLUTION button.
Message 5 of 12
john.uhden
in reply to: hak_vz

@hak_vz 

Without looking, I'm pretty sure that's exactly what I do... store the previous tile values, close the dialog, open the new one, and when you close that you reopen the first repopulating it with the stored values.

I may even temporarily close the first to select objects or an entsel or a getpoint, but I run everything within a continual grread, so that even if I Esc it returns to the previous dialog (or whatever dialog is appropriate).

What's really fun is that you can call an alert with a dialog open.

John F. Uhden

Message 6 of 12
Sea-Haven
in reply to: hak_vz

Like others running a new dcl is probably the only way I have a couple of library dcl's that accept a list of label and value,  getvalues or using radio buttons or toggles. These only require like 3 lines of code to work as all the dcl stuff is done by a external defun. Advantage is can be from 1 to around 20 items. Can have images as well. Like John save the default values as well as say button picked in a file. 

 

This may save duplicating dcls.

 

(if (not AH:Butts)(load "Multi Radio buttons.lsp"))
(if (= but nil)(setq but 1))
(setq ans (ah:butts but "V"   '("Choose colour to remain " "  1" "  2" "  3" "  4" "  5" "  6" "  7")) )

(setq ans (ah:butts but "V"   '("Choose colour to remain " v1 v2 v3 v4 v5 v6 v7)) )

 

Message 7 of 12
dvertz
in reply to: dvertz

Thanks to all that replied, but I guess I was not explaining myself very well as none of the answers came close to what I was needing. And only Sea_Haven provided any code. After hours of searching through the forums (as hak_vz suggested) I still found nothing to help (that's why I posted the question). So I worked the problem myself and found the solution. I was trying to call the next dialog from the current and that couldn't work because the dialog was closing before completion of the lisp code. So, I realized I could do it through the main dialog that called the page 1 of the settings dialog, and when that page of settings closed the main dialog would take over to show page 2 of the settings.

 

Here's the test code that worked for me.

 

TEST_PAGES : dialog {
label = "Test Pages";
: boxed_column {
label = "Pages";
: button { key = "d:testpage"; label = "Settings"; width = 15; fixed_width = true; }
ok_cancel;
}
}

PAGE01 : dialog {
label = "Page 1";
: row {
: button { key = "d:page1"; label = "Page 1"; width = 15; fixed_width = true; }
: button { key = "d:page2"; label = "Page 2"; width = 15; fixed_width = true; }
: button { key = "d:page3"; label = "Page 3"; width = 15; fixed_width = true; }
}
: text_part { label = "Page 1"; }
ok_cancel;
}

PAGE02 : dialog {
label = "Page 2";
: row {
: button { key = "d:page1"; label = "Page 1"; width = 15; fixed_width = true; }
: button { key = "d:page2"; label = "Page 2"; width = 15; fixed_width = true; }
: button { key = "d:page3"; label = "Page 3"; width = 15; fixed_width = true; }
}
: text_part { label = "Page 2"; }
ok_cancel;
}

PAGE03 : dialog {
label = "Page 3";
: row {
: button { key = "d:page1"; label = "Page 1"; width = 15; fixed_width = true; }
: button { key = "d:page2"; label = "Page 2"; width = 15; fixed_width = true; }
: button { key = "d:page3"; label = "Page 3"; width = 15; fixed_width = true; }
}
: text_part { label = "Page 3"; }
ok_cancel;
}

 

(defun C:TESTPAGES (/)
(setq INT:DCLMAIN (load_dialog "TESTPAGES.dcl"))
(if (not (new_dialog "TEST_PAGES" INT:DCLMAIN)) (exit))
(action_tile "d:testpage" "(setq INT:PAGE 11)(LOAD_PAGE)")
(action_tile "accept" "(done_dialog)")
(start_dialog)
(unload_dialog INT:DCLMAIN)
)

;;Choose page to load
(defun LOAD_PAGE (/)
(while (> INT:PAGE 1)
(cond ((= INT:PAGE 11)
(setq INT:DCL_11 (load_dialog "TESTPAGES.dcl"))
(if (not (new_dialog "PAGE01" INT:DCL_11)) (exit))
(action_tile "accept" "(done_dialog 1)")
(action_tile "cancel" "(done_dialog 0)")
(action_tile "d:page1" "(done_dialog 11)")
(action_tile "d:page2" "(done_dialog 12)")
(action_tile "d:page3" "(done_dialog 13)")
(setq INT:PAGE (start_dialog))
(unload_dialog INT:DCL_11)
)
((= INT:PAGE 12)
(setq INT:DCL_12 (load_dialog "TESTPAGES.dcl"))
(if (not (new_dialog "PAGE02" INT:DCL_12)) (exit))
(action_tile "accept" "(done_dialog 1)")
(action_tile "cancel" "(done_dialog 0)")
(action_tile "d:page1" "(done_dialog 11)")
(action_tile "d:page2" "(done_dialog 12)")
(action_tile "d:page3" "(done_dialog 13)")
(setq INT:PAGE (start_dialog))
(unload_dialog INT:DCL_12)
)
((= INT:PAGE 13)
(setq INT:DCL_13 (load_dialog "TESTPAGES.dcl"))
(if (not (new_dialog "PAGE03" INT:DCL_13)) (exit))
(action_tile "accept" "(done_dialog 1)")
(action_tile "cancel" "(done_dialog 0)")
(action_tile "d:page1" "(done_dialog 11)")
(action_tile "d:page2" "(done_dialog 12)")
(action_tile "d:page3" "(done_dialog 13)")
(setq INT:PAGE (start_dialog))
(unload_dialog INT:DCL_13)
)
)
)
)

Civil 3D 2022,
Windows 10 Pro, x64, Nvidia Quadro P1000
Intel Core i9-11900k; 3.50GHz, 32 GB RAM, 500GB WD BLACK M.2


Message 8 of 12
hak_vz
in reply to: dvertz


@dvertz wrote:

Thanks to all that replied, but I guess I was not explaining myself very well as none of the answers came close to what I was needing. And only Sea_Haven provided any code.


@dvertz  You have my code in the post I've linked (see under more details)

 

https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/remember-previous-dcl-values-default... 

 

Anyway, the best solution is the one you make it yourself.

Miljenko Hatlak

EESignature

Did you find this post helpful? Feel free to Like this post.
Did your question get successfully answered? Then click on the ACCEPT SOLUTION button.
Message 9 of 12
Sea-Haven
in reply to: dvertz

Using Multi radio butons would remove 3 of the dcls possibly all 4. As all the pages are a repeating pattern, 

 

(setq INT:DCL_13 (load_dialog "TESTPAGES.dcl")) 

 

Just need to add the cancel button as that is not in Multi Radio Buttons.

Message 10 of 12
dvertz
in reply to: Sea-Haven

I realize the code repeats and I am always for cutting down on code, but I am not understanding how radio buttons can help in my situation. I used test code here, but the actual dialogs have MANY options (the reason I need pages of dialogs rather than just one). If I removed the buttons and put in radio buttons, I would still need to run the loop and duplicate code to show the next page, correct?

Civil 3D 2022,
Windows 10 Pro, x64, Nvidia Quadro P1000
Intel Core i9-11900k; 3.50GHz, 32 GB RAM, 500GB WD BLACK M.2


Message 11 of 12
Sea-Haven
in reply to: dvertz

No worries I may be misinterpreting exactly what your doing, in the past I have used parent child DCL,s not close and open another.

 

SeaHaven_0-1628034583150.png

 

 

Message 12 of 12
galibardiWNXEW
in reply to: dvertz

You can use DONE_DIALOG with an exit code (ex. (DONE_DIALOG 100)) then load new dialog after first in unloaded

 (setq status (start_dialog))
    (unload_dialog dcl_id)
    (if (= 100 status)
       (LOAD_OTHER)
    )

 

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

AutoCAD Inside the Factory


Autodesk Design & Make Report