Author Topic: Keys Attributes Values  (Read 1446 times)

0 Members and 1 Guest are viewing this topic.

QuestionEverything

  • Newt
  • Posts: 45
Keys Attributes Values
« on: November 30, 2016, 11:34:10 am »
Hi,
My question might sound weird, but:
Is there a reason not to assign a Key or Attribute or a Value onto a tile?
For example the : text tile, doesn't always need to have a key or a value if its used as a "label" for something next to it.
Can you share some info from your experience?

Lee Mac

  • Seagull
  • Posts: 11799
  • AutoCAD 2015 Windows 7 London, England
Re: Keys Attributes Values
« Reply #1 on: November 30, 2016, 01:44:50 pm »
A tile 'key' attribute is only required if the tile needs to be manipulated at runtime by the program - the key provides a way to uniquely reference the tile.

Provided a tile has either the is_default or is_cancel attribute, you can load & display a dialog with no tile keys:
Code - Auto/Visual Lisp: [Select]
  1. (defun c:test ( / *error* dch dcl des )
  2.    (and (setq *error*
  3.            '(   ( m )
  4.                 (if (< 0 dch) (unload_dialog dch))
  5.                 (if (= 'file (type des)) (close des))
  6.                 (if (and (= 'str (type dcl)) (findfile dcl)) (vl-file-delete dcl))
  7.             )
  8.             dcl (vl-filename-mktemp nil nil ".dcl")
  9.             des (open dcl "w")
  10.         )
  11.         (princ "d:dialog{spacer;:edit_box{edit_width=20;}:button{label=\"Exit\";is_cancel=true;}spacer;}" des)
  12.         (not (setq des (close des)))
  13.         (< 0 (setq dch (load_dialog dcl)))
  14.         (new_dialog "d" dch)
  15.         (start_dialog)
  16.    )
  17.    (*error* nil) (princ)
  18. )


QuestionEverything

  • Newt
  • Posts: 45
Re: Keys Attributes Values
« Reply #2 on: November 30, 2016, 02:25:51 pm »
A tile 'key' attribute is only required if the tile needs to be manipulated at runtime by the program - the key provides a way to uniquely reference the tile.

Provided a tile has either the is_default or is_cancel attribute, you can load & display a dialog with no tile keys:
Code - Auto/Visual Lisp: [Select]
  1. (defun c:test ( / *error* dch dcl des )
  2.    (and (setq *error*
  3.            '(   ( m )
  4.                 (if (< 0 dch) (unload_dialog dch))
  5.                 (if (= 'file (type des)) (close des))
  6.                 (if (and (= 'str (type dcl)) (findfile dcl)) (vl-file-delete dcl))
  7.             )
  8.             dcl (vl-filename-mktemp nil nil ".dcl")
  9.             des (open dcl "w")
  10.         )
  11.         (princ "d:dialog{spacer;:edit_box{edit_width=20;}:button{label=\"Exit\";is_cancel=true;}spacer;}" des)
  12.         (not (setq des (close des)))
  13.         (< 0 (setq dch (load_dialog dcl)))
  14.         (new_dialog "d" dch)
  15.         (start_dialog)
  16.    )
  17.    (*error* nil) (princ)
  18. )
After reading your comment I'm left with the impression that the whole thing works like an association list:
Code: [Select]
'((<Key1> <Label1> <Value1> <Expr1>)(<Key2> <Label2> <Value2> <Expr2>) .... (<KeyN> <LabelN> <ValueN> <ExprN>))Where each item represents a tile and depending on your intentions, you might want to(or not) assign something to it.
And ofcourse accesing the tile through its <Key> (optional), similarly to the Tile- and Attribute-Handling Functions aka *_tile functions, like you said "if the tile needs to be manipulated".

Tho replicating the ok and cancel buttons by using is_default or is_cancel attributes, I wanted to ask how to access the help, info and errtile tiles, when using these built-in functions:
Code: [Select]
ok_cancel_help_info;
ok_cancel_help_errtile;
Thank you!

roy_043

  • Swamp Rat
  • Posts: 1480
  • BricsCAD 16
Re: Keys Attributes Values
« Reply #3 on: November 30, 2016, 02:41:23 pm »
Provided a tile has either the is_default or is_cancel attribute...
An action attribute defined in the DCL that includes (done_dialog) also works.

Lee Mac

  • Seagull
  • Posts: 11799
  • AutoCAD 2015 Windows 7 London, England
Re: Keys Attributes Values
« Reply #4 on: November 30, 2016, 03:06:38 pm »
After reading your comment I'm left with the impression that the whole thing works like an association list:
Code: [Select]
'((<Key1> <Label1> <Value1> <Expr1>)(<Key2> <Label2> <Value2> <Expr2>) .... (<KeyN> <LabelN> <ValueN> <ExprN>))Where each item represents a tile and depending on your intentions, you might want to(or not) assign something to it.
And ofcourse accesing the tile through its <Key> (optional), similarly to the Tile- and Attribute-Handling Functions aka *_tile functions, like you said "if the tile needs to be manipulated".

I don't see the link to an association list, but note that you can assign labels & values to tiles without keys.

Tho replicating the ok and cancel buttons by using is_default or is_cancel attributes, I wanted to ask how to access the help, info and errtile tiles, when using these built-in functions:
Code: [Select]
ok_cancel_help_info;
ok_cancel_help_errtile;

The "ok" tile has key "accept" and the errtile has key "error"; the other tiles have keys equal to their tile names.

See:
http://help.autodesk.com/view/ACD/2016/ENU/?guid=GUID-0376DCD0-ACF6-4269-982E-E396E81C4D93
http://help.autodesk.com/view/ACD/2016/ENU/?guid=GUID-BA3EADFA-E2D7-4D85-9282-3CBB0D83499E
http://help.autodesk.com/view/ACD/2016/ENU/?guid=GUID-DF8DA7C3-7F7E-471C-A6B9-1A5D986CD6E9
http://help.autodesk.com/view/ACD/2016/ENU/?guid=GUID-01A41A6D-5972-4A33-99B8-BA7B7A379527
http://help.autodesk.com/view/ACD/2016/ENU/?guid=GUID-9FB4A683-23CA-4B6C-A5EF-5E43AE7C8D4B

Provided a tile has either the is_default or is_cancel attribute...
An action attribute defined in the DCL that includes (done_dialog) also works.

Note that this is not valid in AutoCAD; also, the action attribute value will only be evaluated for tiles with keys.

QuestionEverything

  • Newt
  • Posts: 45
Re: Keys Attributes Values
« Reply #5 on: November 30, 2016, 04:12:00 pm »
I don't see the link to an association list, but note that you can assign labels & values to tiles without keys.
Sorry I was trying to explain this to myself in lisp words (the tile and their attributes thing), since the DCL LSP connection is inevitable.

The "ok" tile has key "accept" and the errtile has key "error"; the other tiles have keys equal to their tile names.

See:
http://help.autodesk.com/view/ACD/2016/ENU/?guid=GUID-0376DCD0-ACF6-4269-982E-E396E81C4D93
http://help.autodesk.com/view/ACD/2016/ENU/?guid=GUID-BA3EADFA-E2D7-4D85-9282-3CBB0D83499E
http://help.autodesk.com/view/ACD/2016/ENU/?guid=GUID-DF8DA7C3-7F7E-471C-A6B9-1A5D986CD6E9
http://help.autodesk.com/view/ACD/2016/ENU/?guid=GUID-01A41A6D-5972-4A33-99B8-BA7B7A379527
http://help.autodesk.com/view/ACD/2016/ENU/?guid=GUID-9FB4A683-23CA-4B6C-A5EF-5E43AE7C8D4B
Now I'll remember that the following names for keys:
Code: [Select]
"accept" "cancel" "help" "info" "error"Are "protected" (like saying protected symbols) so will try to avoid these names when manually asignning a key attribute.

Thanks alot, you are very helpful! :)

Lee Mac

  • Seagull
  • Posts: 11799
  • AutoCAD 2015 Windows 7 London, England
Re: Keys Attributes Values
« Reply #6 on: November 30, 2016, 04:30:22 pm »
Now I'll remember that the following names for keys:
Code: [Select]
"accept" "cancel" "help" "info" "error"Are "protected" (like saying protected symbols) so will try to avoid these names when manually asignning a key attribute.

On the contrary - since these tiles have predefined action statements, you can exploit this to avoid the need to define action_tile expressions for your tiles:
Code - Auto/Visual Lisp: [Select]
  1. (defun c:test ( / *error* dch dcl des )
  2.    (and (setq *error*
  3.            '(   ( m )
  4.                 (if (< 0 dch) (unload_dialog dch))
  5.                 (if (= 'file (type des)) (close des))
  6.                 (if (and (= 'str (type dcl)) (findfile dcl)) (vl-file-delete dcl))
  7.             )
  8.             dcl (vl-filename-mktemp nil nil ".dcl")
  9.             des (open dcl "w")
  10.         )
  11.         (write-line
  12.             (strcat
  13.                 "dia : dialog"
  14.                 "{"
  15.                 "    label = \"Example\";"
  16.                 " children_alignment = centered;"
  17.                 "    spacer;"
  18.                 "    : edit_box { edit_width=40; }"
  19.                 "    spacer;"
  20.                 "    : button"
  21.                 "    {"
  22.                 "        label = \" Custom OK Button \";"
  23.                 "        fixed_width = true;"
  24.                 "        height = 3.0;"
  25.                 "        key = \"accept\";"
  26.                 "        is_default = true;"
  27.                 "    }"
  28.                 "    spacer;"
  29.                 "}"
  30.         )
  31.             des
  32.         )
  33.         (not (setq des (close des)))
  34.         (< 0 (setq dch (load_dialog dcl)))
  35.         (new_dialog "dia" dch)
  36.         (start_dialog)
  37.    )
  38.    (*error* nil) (princ)
  39. )

Thanks alot, you are very helpful! :)

You're welcome!

Grrr1337

  • Bull Frog
  • Posts: 397
Re: Keys Attributes Values
« Reply #7 on: November 30, 2016, 06:42:06 pm »
Code - Auto/Visual Lisp: [Select]
  1. "dia : dialog"
  2. "{"
  3. "    label = \"Example\";"
  4. " children_alignment = centered;"
  5. "    spacer;"
  6. "    : edit_box { edit_width=40; }"
  7. "    spacer;"
  8. "    : button"
  9. "    {"
  10. "        label = \" Custom OK Button \";"
  11. "        fixed_width = true;"
  12. "        height = 3.0;"
  13. "        key = \"accept\";"
  14. "        is_default = true;"
  15. "    }"
  16. "    spacer;"
  17. "}"
  18. )
  19.  
Hi Lee,
I love the DCL-string formatting you did, do you use some snippet for this?
Because I think about writing some (in case you did this by hand).
BTW, Nice thread! (sorry for the offtopic)

QuestionEverything

  • Newt
  • Posts: 45
Re: Keys Attributes Values
« Reply #8 on: December 01, 2016, 05:18:37 am »

On the contrary - since these tiles have predefined action statements, you can exploit this to avoid the need to define action_tile expressions for your tiles:
Now I know that:
Code - Auto/Visual Lisp: [Select]
  1. is_default; equals to (action_tile "accept" "(done_dialog 1)")
  2. is_cancel; equals to (action_tile "cancel" "(done_dialog 0)")
Just like roy_043 mentioned.

And if I would use one of these:
ok_cancel_help_errtile;
ok_cancel_help;
ok_cancel_help_info;

I will need to define action_tile expressions for these keys: "help" "info" "error".

So there are various ways to handle the ok and cancel buttons.
Similairly for custom cancel button (from your example):
Code - Auto/Visual Lisp: [Select]
  1. "    : button"
  2. "    {"
  3. "        label = \" Custom Cancel Button \";"
  4. "        fixed_width = true;"
  5. "        height = 3.0;"
  6. "        key = \"cancel\";"
  7. "        is_cancel = true;"
  8. "    }"
  9.  

roy_043

  • Swamp Rat
  • Posts: 1480
  • BricsCAD 16
Re: Keys Attributes Values
« Reply #9 on: December 01, 2016, 09:04:26 am »
Provided a tile has either the is_default or is_cancel attribute...
An action attribute defined in the DCL that includes (done_dialog) also works.

Note that this is not valid in AutoCAD; also, the action attribute value will only be evaluated for tiles with keys.
Are you saying that (done_dialog) is not allowed in an action attribute? That seems strange.

Grrr1337

  • Bull Frog
  • Posts: 397
Re: Keys Attributes Values
« Reply #10 on: December 01, 2016, 09:15:53 am »
Provided a tile has either the is_default or is_cancel attribute...
An action attribute defined in the DCL that includes (done_dialog) also works.

Note that this is not valid in AutoCAD; also, the action attribute value will only be evaluated for tiles with keys.
Are you saying that (done_dialog) is not allowed in an action attribute? That seems strange.
Roy, he was 'talking' about tiles with no keys (then you cannot asign <expr> using action_tile).

Since op stated:
Is there a reason not to assign a Key or Attribute or a Value onto a tile?

Lee Mac

  • Seagull
  • Posts: 11799
  • AutoCAD 2015 Windows 7 London, England
Re: Keys Attributes Values
« Reply #11 on: December 01, 2016, 03:13:21 pm »
I love the DCL-string formatting you did, do you use some snippet for this?

I write DCL code in the Visual LISP IDE, and use the same to convert to string format simply using the various find/replace/prefix/append options offered by the IDE.

Because I think about writing some (in case you did this by hand).
BTW, Nice thread! (sorry for the offtopic)

You may get some ideas from this old program: Format DCL.

On the contrary - since these tiles have predefined action statements, you can exploit this to avoid the need to define action_tile expressions for your tiles:
Now I know that:
Code - Auto/Visual Lisp: [Select]
  1. is_default; equals to (action_tile "accept" "(done_dialog 1)")
  2. is_cancel; equals to (action_tile "cancel" "(done_dialog 0)")
Just like roy_043 mentioned.

Not quite: this equivalence is only applicable to the is_cancel attribute; the is_default attribute will only set the tile as the default and will not assign an action - if in doubt, simply include the tile keys.  :-)

Provided a tile has either the is_default or is_cancel attribute...
An action attribute defined in the DCL that includes (done_dialog) also works.
Note that this is not valid in AutoCAD; also, the action attribute value will only be evaluated for tiles with keys.
Are you saying that (done_dialog) is not allowed in an action attribute? That seems strange.

No, (done_dialog) is a perfectly valid action attribute value in AutoCAD, however, I was asserting that the action expression will only be evaluated for tiles with keys (per Grrr1337 above). Also, that this action expression alone is not sufficient for a valid DCL GUI: the tile must also have either an is_cancel or is_default attribute (else AutoCAD will complain that the GUI has no OK or Cancel button).

roy_043

  • Swamp Rat
  • Posts: 1480
  • BricsCAD 16
Re: Keys Attributes Values
« Reply #12 on: December 01, 2016, 03:37:19 pm »
@Grrr1337 + @Lee Mac: Thanks for the clarification. I guess BricsCAD is a bit more flexible here.

Grrr1337

  • Bull Frog
  • Posts: 397
Re: Keys Attributes Values
« Reply #13 on: December 01, 2016, 05:43:47 pm »
I love the DCL-string formatting you did, do you use some snippet for this?

I write DCL code in the Visual LISP IDE, and use the same to convert to string format simply using the various find/replace/prefix/append options offered by the IDE.

Because I think about writing some (in case you did this by hand).
BTW, Nice thread! (sorry for the offtopic)

You may get some ideas from this old program: Format DCL.

Thanks Lee,
I expected that in such particular cases, you might use NP++ (sounds impressive that you push VLIDE to its limits).  :evillaugh:
I was aware about the Format DCL program (and I thought you might used it for this task (before I re-checked its functionality)).

I'll post my idea(inspiration) over the DCL section, when its done. :)

MP

  • Seagull
  • Posts: 16994
  • brevity != aggression
Re: Keys Attributes Values
« Reply #14 on: December 01, 2016, 05:58:39 pm »
Completely nuts how a 10 year old post contributed to this thread. :crazy2:

I feel old. :cry:
\|// Set goal. Experiment tirelessly until
|oo| practice has become expertise.  Loop.
|- | LinkedIn | Dropbox | About