Getting defaults to activate within tiles using DCL

Getting defaults to activate within tiles using DCL

tcorey
Mentor Mentor
2,045 Views
11 Replies
Message 1 of 12

Getting defaults to activate within tiles using DCL

tcorey
Mentor
Mentor

Given the attached .dcl, very simple dialog, and the attached .lsp, very simple routine to read the dialog, why can't I retrieve the value I set on a button in the dcl?

 

I have one radio button column within which I have set one radio button value to "1". Yet, when I retrieve the value using my lsp, it says nil until I change the selected button at least once. I don't understand why. Also, if I use (set_tile) to set a value on the button, now there will be no radio button selected within the column.



Tim Corey
MicroCAD Training and Consulting, Inc.
Redding, CA
Autodesk Gold Reseller

New knowledge is the most valuable commodity on earth. -- Kurt Vonnegut
0 Likes
Accepted solutions (2)
2,046 Views
11 Replies
Replies (11)
Message 2 of 12

john.uhden
Mentor
Mentor
Accepted solution

I didn't look at your code at all, but my habit is to always (set_tiles) before beginning any actions.

In addition to avoiding your problem, there's a chance that the user can just hit OK without having to modify any tiles.

John F. Uhden

Message 3 of 12

doaiena
Collaborator
Collaborator
Accepted solution

You aren't getting a value simply by pressing the "ok" button, because no action has taken place on the dialog. 
"set_tile" -  only marks the default option when the dialog is presented to the user, but it doesnt trigger an action/event.
"action_tile" - is an event. This event takes place only when the user activates the control with the corresponding key.


First of all when using a radio column, you should give it a key in the DCL and reference that key in your lisp, not the individual radio buttons.
key = "radio";

You have many options to tackle this issue.
One option is to set default values manually for all the controls.
- (set_tile "radio" "rb12") - mark the radio button
- (setq rb12 "1") - set the default value in the variable
Or you can dinamically set the variable you need.
- (set (read (get_tile "radio")) (get_tile (get_tile "radio")))

Another option is to read the controls at the "Accept" action_tile. Instead of setting individual action_tile statements, you can define a function and use get_tile to gather the information from your controls and then call that function from the "Accept" button.

 

Hope i've helped make things a bit more clear.

PS:
You had written in your lisp (set_tile "rb11" "\"1\""), it won't work like that. That is why you weren't getting a default option marked. It should be just (set_tile "rb11" "1"). And on the DCL part, i think it's better if you set default values from the lisp side. You can have multiple dialogs in a single DCL file, and it gets messy if you try to edit default values there.

Message 4 of 12

tcorey
Mentor
Mentor

Thanks. That helps. 



Tim Corey
MicroCAD Training and Consulting, Inc.
Redding, CA
Autodesk Gold Reseller

New knowledge is the most valuable commodity on earth. -- Kurt Vonnegut
0 Likes
Message 5 of 12

tcorey
Mentor
Mentor

Follow-up:

I used @doaiena's advice and added a key to my radio button boxed column, then set values on the buttons, per his/her code example, see above.

 

Even with that, my default button would not report 0 back to me when the button changed. I solved this by adding a (progn) function within the action_tiles.

 

For example: (action_tile "rb11" "(progn (setq rb11 $value)(setq rb12 \"0\" rb13 \"0\"))")

 

Sets rb11 to whatever is set by the action ("1"), but also sets rb12 and r13 to "0".



Tim Corey
MicroCAD Training and Consulting, Inc.
Redding, CA
Autodesk Gold Reseller

New knowledge is the most valuable commodity on earth. -- Kurt Vonnegut
0 Likes
Message 6 of 12

doaiena
Collaborator
Collaborator

I have edited your lisp and dcl files. If you need a working example of a more complicated dialog, with more controls, just upload it and ill would be happy to help. I'm using OpenDCL for my dialogs, so i find it hard to prepare a demo using standard DCL.

 

PS:

On a radio control you don't need to read all the options, because only one can be marked at a time. So you only need a variable for the marked option, the other 2 options arent relevant anymore.

0 Likes
Message 7 of 12

tcorey
Mentor
Mentor

Thanks, I sincerely appreciate your willingness to help me.

 

Yes, I thought that was true about only needing to read one radio control. I went ahead and put in calls to all so I could set the variable, otherwise an untouched radio button was returning nil, not "0". 

 

The dcl part of my project is complete. Thanks to putting (progn) in my action_tiles, I have it working correctly. Plus, I think I might have been putting some of my reading of the button variables in the wrong place. I have now realized they have to be outside the close_dialog. I think you might have mentioned that to me in a post higher in this thread. Thanks.

 

I have not heard of OpenDCL. Is that an IDE for DCL language files? The one that is part of VLIDE in AutoCAD 2019 is very buggy, as is the LISP editor with 2019, so I have switched to NotePad++. It does a nice job with LISP, but DCL is colorless.



Tim Corey
MicroCAD Training and Consulting, Inc.
Redding, CA
Autodesk Gold Reseller

New knowledge is the most valuable commodity on earth. -- Kurt Vonnegut
0 Likes
Message 8 of 12

doaiena
Collaborator
Collaborator

OpenDCL is a free application with a GUI, where you create your dialogs in a far more intuitive way. There are many more options for both types of dialogs and the controls in them. There is only an *.arx runtime you need to load into AutoCAD in order for those dialogs to work.

From my experience, the best approach is to define "blank" functions, something like a template function for each control type, which describes general functionality and execute that for a list of all controls of the same type. That way editing a dialog window (adding/removing new controls) becomes as simple as adding a symbol name to a list of controls.

0 Likes
Message 9 of 12

scot-65
Advisor
Advisor

When working with radio_buttons, one uses the container

to set and retrieve the current value of radio_button.

 

:boxed_radio_column {key="Rad01";
label="Choose Label";
:radio_button{key = "rb11"; label = "Label_1"; value = "1";}
:radio_button{key = "rb12"; label = "Label_2"; value = "0";}
:radio_button{key = "rb13"; label = "Label_3"; value = "0";}
}//end column

Now, when you initialize the program [from inside LSP]:

(set_tile "Rad01" "rb11")

 

Gathering the current value of the radio cluster:

(setq a (get_tile "Rad01"))

will return "rb11".

 

There is no need to have an action_tile for any of the

radio buttons unless you are doing mode_tile or

repopulating list boxes, popup lists, etc (dialog display).

I have also been known to create a series of text_parts

inside a boxed_column with label and when a particular

radio button is selected, a brief description is rendered

inside the box.

In other words, action_tile other than accept does not

warrant the use of "setq" anywhere inside.

 

When the user presses the OK button, this is the time when

one gathers all the current values of the dialog's tiles:

(action_tile "accept" "(MyProgram_GET)(done_dialog 1)")

 

Where:

(defun MyProgram_GET ()

 (setq a (get_tile "Rad01"))

 ...

);end

 

???

 


Scot-65
A gift of extraordinary Common Sense does not require an Acronym Suffix to be added to my given name.

0 Likes
Message 10 of 12

john.uhden
Mentor
Mentor
Maybe you would have an easier time if you named your variables the same as
your tiles.
Then you can...

(action_tile "rb11" "(set (read $key) $value)")
(action_tile "rb12" "(set (read $key) $value)")

John F. Uhden

0 Likes
Message 11 of 12

tcorey
Mentor
Mentor

I get it now. Talk to the box, not the buttons. You said that once before, but I didn't quite understand. 

 

I understand what you said about not needing action_tiles. I thought I had to have one for every radio button.

 

Using my new-found technique, I will be able to use @john.uhden's advice. I plan to change my code significantly. Instead of using cond statements to step through the variable possibilities to obtain my answer, I will key my buttons to the text I want returned, then just ask the box.

 

Thanks to you both for setting me straight. Boy, was I going at this the long way!



Tim Corey
MicroCAD Training and Consulting, Inc.
Redding, CA
Autodesk Gold Reseller

New knowledge is the most valuable commodity on earth. -- Kurt Vonnegut
0 Likes
Message 12 of 12

doaiena
Collaborator
Collaborator

Glad to hear you've come to a solution. Just as a reminder, action_tiles are events. Not just for radio controls, but for all control types. Action_tiles are used when you need a realtime calculation, while the dialog is still open. An action_tile is a function that executes when you activate the control (user clicks on it).

0 Likes