PDA

View Full Version : DCL help


dfuehrer
2005-10-03, 07:15 PM
Hello everyone,

I was hoping that some of you lisp experts here could help me out with a bit of code I am having trouble with.

I have 10 drawing types (we refer to them here as A1, A2, F1, E1, E2, E3, M1, P1, P2, P3 drawings) and a lisp loading at startup that gives additional functions to AutoCAD. These functions clean up and set drawing parameters accordingly. The code for this runs fine from the command line. I am scratching my head, trying to get the DCL portion of it to work. Right now all I get is the "nil" echoing back on the command line.

I would like to select a radio button on the Dialog Box, and then press a button that runs the correct command either A1, A2, F1, E1, E2, E3, M1, P1, P2, or P3. How do I take the user selected radio button input, and have it pass a command?

I am also having trouble getting a slide to display as an image in the Dialog Box. All I get is a blank rectangle.

I am by no means any sort of lisp expert, so any help would be greatly appreciated!

Thank you in advance,

Don

Glenndp
2005-10-03, 07:38 PM
Hi Don,

Could you post your code so we can get a look at it?

dfuehrer
2005-10-03, 07:56 PM
Hi, and thanks for responding. Here is what I have so far.

The code for the DCL file:

dbcleanup : dialog {
label = "Fix Database Drawing";
: image {
key = "sld";
height = 4;
width = 20;
color = 254;
is_enabled = false;
is_tab_stop = false;
}
: boxed_column {
label = "Choose drawing type to fix";
: radio_column {
: radio_button {
key = "but1";
label = "A1 Drawing";
}
: radio_button {
key = "but2";
label = "A2 Drawing";
}
: radio_button {
key = "but3";
label = "F1 Drawing";
}
: radio_button {
key = "but4";
label = "E1 Drawing";
}
: radio_button {
key = "but5";
label = "E2 Drawing";
}
: radio_button {
key = "but6";
label = "E3 Drawing";
}
: radio_button {
key = "but7";
label = "M1 Drawing";
}
: radio_button {
key = "but8";
label = "P1 Drawing";
}
: radio_button {
key = "but9";
label = "P2 Drawing";
}
: radio_button {
key = "but10";
label = "P3 Drawing";
}
}
}
: boxed_row {
: button {
key = "accept";
label = "Fix Drawing";
is_tab_stop = true;
is_cancel = false;
is_default = true;
}
: button {
key = "cancel";
label = " Cancel ";
is_tab_stop = true;
is_cancel = true;
is_default = false;
}
}
: boxed_column {
label = "Copyright ©2005 Xxxx Xxxxxxxxxx";
}
}

And here is what I have for the lisp portion, note that I have some lines remarked out. Clearly I am in over my head... (please be gentle, I am just learning!):

(defun saveVars ()
(setq myChoice (get_tile "mychoice"))
(setq choice1 (atoi (get_tile "but1"))) ;//0=not chosen 1=chosen
(setq choice1 (atoi (get_tile "but2"))) ;//0=not chosen 1=chosen
(setq choice1 (atoi (get_tile "but3"))) ;//0=not chosen 1=chosen
(setq choice1 (atoi (get_tile "but4"))) ;//0=not chosen 1=chosen
(setq choice1 (atoi (get_tile "but5"))) ;//0=not chosen 1=chosen
(setq choice1 (atoi (get_tile "but6"))) ;//0=not chosen 1=chosen
(setq choice1 (atoi (get_tile "but7"))) ;//0=not chosen 1=chosen
(setq choice1 (atoi (get_tile "but8"))) ;//0=not chosen 1=chosen
(setq choice1 (atoi (get_tile "but9"))) ;//0=not chosen 1=chosen
(setq choice1 (atoi (get_tile "but10"))) ;//0=not chosen 1=chosen
)

(defun c:FD ()
(setq dcl_id (load_dialog "dbcleanup.dcl"))
(if (not (new_dialog "dbcleanup" dcl_id))
(exit)
)
; (action_tile "but10" "(setq ddiag 12)(saveVars)(done_dialog)")
; (action_tile "but9" "(setq ddiag 11)(saveVars)(done_dialog)")
; (action_tile "but8" "(setq ddiag 10)(saveVars)(done_dialog)")
; (action_tile "but7" "(setq ddiag 9)(saveVars)(done_dialog)")
; (action_tile "but6" "(setq ddiag 8)(saveVars)(done_dialog)")
; (action_tile "but5" "(setq ddiag 7)(saveVars)(done_dialog)")
; (action_tile "but4" "(setq ddiag 6)(saveVars)(done_dialog)")
; (action_tile "but3" "(setq ddiag 5)(saveVars)(done_dialog)")
; (action_tile "but2" "(setq ddiag 4)(saveVars)(done_dialog)")
; (action_tile "but1" "(setq ddiag 3)(saveVars)(done_dialog)")
(action_tile
"accept"
"(setq ddiag 2)(saveVars)(done_dialog)"
)
(action_tile "cancel" "(setq ddiag 1)(done_dialog)")
(start_dialog)
(unload_dialog dcl_id)
)

(setq mySlideName "C:/Acad/Xxxx.sld")
(setq myKey "sld")
(defun upDateImage (sldName key)
(upDateImage mySlideName myKey)
(setq width (dimx_tile key))
(setq height (dimy_tile key))
(start_image key)
(fill_image 0 0 width height 0)
(slide_image 0 0 width height sldName)
(end_image)
)

peter
2005-10-03, 11:29 PM
Here is an example for using image tiles as buttons.
Peter Jamtgaard P.E.

peter
2005-10-03, 11:45 PM
I think that a list box would work for you better than a bunch of radio buttons.

Take a look at this function.


Peter Jamtgaard P.E.

Opie
2005-10-03, 11:58 PM
I think one of the problems you were having could be from setting the value of the same variable for each individual button.


(defun saveVars ()
(setq myChoice (get_tile "mychoice"))
(setq choice1 (atoi (get_tile "but1"))) ;//0=not chosen 1=chosen
(setq choice1 (atoi (get_tile "but2"))) ;//0=not chosen 1=chosen
(setq choice1 (atoi (get_tile "but3"))) ;//0=not chosen 1=chosen
(setq choice1 (atoi (get_tile "but4"))) ;//0=not chosen 1=chosen
(setq choice1 (atoi (get_tile "but5"))) ;//0=not chosen 1=chosen
(setq choice1 (atoi (get_tile "but6"))) ;//0=not chosen 1=chosen
(setq choice1 (atoi (get_tile "but7"))) ;//0=not chosen 1=chosen
(setq choice1 (atoi (get_tile "but8"))) ;//0=not chosen 1=chosen
(setq choice1 (atoi (get_tile "but9"))) ;//0=not chosen 1=chosen
(setq choice1 (atoi (get_tile "but10"))) ;//0=not chosen 1=chosen
)

dfuehrer
2005-10-04, 05:14 AM
Thanks for the code Peter!

I am still trying to wrap my head around the list box function....

I only need the slide to display, not be an active button. Your code for it is really cool though!

Don

jim.vipond
2005-10-04, 11:29 AM
Hi,

It seems you saveVars function is just resetting choice1 variable each time. Also you seem to be resetting the ddiag variable at the end of the dialog (is this needed?).
What I would suggest is setting the choice1 variable in the dialog
and scrap the code already in saveVars

(action_tile "but10" "(setq choice1 12))
or
in function saveVars use a cond or if to find the value of ddiag

I've attached a file as an example (although a bit long winded)

peter
2005-10-04, 01:17 PM
Don,

It is a good place to start for either using a list box or displaying slides.

Those two functions should be able to be modified to do what you want. If you need assistance changing them let me know.

The list box dcl function just loads the list you provided and you select the one you want.

You can use it over and over to select parameters for a routine. just pass the prompt and the list of items for each imput. It returns the selected item. If you need a multiple select version let me know I have that one too.

Peter Jamtgaard P.E.


Thanks for the code Peter!

I am still trying to wrap my head around the list box function....

I only need the slide to display, not be an active button. Your code for it is really cool though!

Don