Author Topic: About action_tile  (Read 392 times)

0 Members and 1 Guest are viewing this topic.

Grrr1337

  • Bull Frog
  • Posts: 313
About action_tile
« on: November 26, 2016, 03:10:25 pm »
Hi guys, straight to the question(s):
Quote
Signature

(action_tile key action-expression)
key
Type: String
Names the tile that triggers the action (specified as its key attribute). This argument is case-sensitive.
action-expression
Type: String
Expression evaluated when the tile is selected.
Return Values

Type: T or nil
T if the key was found; otherwise it returns nil.
1.Why action-expression has to be a string? Is it because its being evaluated thru the dialog ?
2.Is there a way to temporarily disable the dialog:
For example the button is about performing a selection - press it and user is prompted for selection, then return to the dialog (doesn't matter if the SS was made or not).
I tried something like this (which didn't worked):
Code: [Select]
(action_tile "SelButton" ; this doesn't work, why?
"
(done_dialog 2)
(if (and (princ \"\\nSelect text objects: \") (setq SS (ssget \"_:L\" (list (cons 0 \"*TEXT\")))) )
(set_tile \"SelPrompt\" (vl-princ-to-string SS))
)
"
); action_tile
 
action_tile seems the only tile function that can assign expression(s). This sounds powerful. :roll:


Lee Mac

  • Seagull
  • Posts: 11679
  • AutoCAD 2015 Windows 7 London, England
Re: About action_tile
« Reply #1 on: November 26, 2016, 06:33:32 pm »
2.Is there a way to temporarily disable the dialog:
For example the button is about performing a selection - press it and user is prompted for selection, then return to the dialog (doesn't matter if the SS was made or not).
I tried something like this (which didn't worked):
Code: [Select]
(action_tile "SelButton" ; this doesn't work, why?
"
(done_dialog 2)
(if (and (princ \"\\nSelect text objects: \") (setq SS (ssget \"_:L\" (list (cons 0 \"*TEXT\")))) )
(set_tile \"SelPrompt\" (vl-princ-to-string SS))
)
"
); action_tile

DCL can only display modal dialogs, meaning that the AutoCAD graphical window cannot take focus to allow an object selection whilst the dialog remains active. The ssget expression will therefore need to be evaluated following the start_dialog expression, i.e. after the dialog has returned focus to the AutoCAD window.

You should test the integer returned by the start_dialog function in order to determine how the dialog window was dismissed, and hence how to proceed - there are numerous examples of this.

Grrr1337

  • Bull Frog
  • Posts: 313
Re: About action_tile
« Reply #2 on: November 27, 2016, 06:00:44 am »
Hi Lee,
In other words (lisp), something like this? :
Code: [Select]
(action_tile "SelButton" "(done_dialog 5)") ; and store the values of all tiles
(setq dlgRtn (start_dialog))
; (alert (vl-princ-to-string dlgRtn))
(if (= 5 dlgRtn)
(progn
(done_dialog)
(princ "\nSelect text objects: ")
(if (setq SS (ssget "_:L" (list (cons 0 "*TEXT"))))
(progn ; if SS, then change the selection associated values
(new_dialog "TextTest" dcl_id) ; recreate the dialog and set new tile values, before restarting it
(set_tile "SelPrompt" (vl-princ-to-string SS))
)
(new_dialog "TextTest" dcl_id) ; recreate the dialog
)
; reset the values of all tiles
(setq dlgRtn (start_dialog)) ; restart the dialog
); progn
); if

(cond
((= 1 dlgRtn) ; ok was pressed
(and RtnLst (setq RtnLst (reverse RtnLst))) ; this is assoc list of ( <key> . <value> ) - collect the results from the dialog
(alert (vl-princ-to-string RtnLst))
)
((= 0 dlgRtn) ; cancel was pressed
(setq RtnLst nil)
)
); cond
(done_dialog)
(unload_dialog dcl_id)
(vl-file-delete FpathWithFname)
I mean (english),
1. if the "SelButton" was pressed, just store all the keys and vals from the dialog into assoc list, and use return of (done_dialog n).
2. Check if n value was returned and prompt for SS, then create new dialog and populate all the tile values with the previous ones using set_tile

Now I feel that I've dropped myself into the deep waters with this question.
This method "works" except that the newly created dialog doesn't obtain the behavior of the "SelButton" - no possibility to be prompted again for SS.
So I think the wayaround for this is to define the whole thing as a subfunction / run it within a while loop.

Aside question:
Do you think that this is the proper policy: When ending(closing) the dialog to obtain all the keys and values from the dialog into one assoc list and continue the computations with lisp, or there is something else I'm missing?

BTW I'm still newbie into the DCL stuff, so I've just learned this:
Code: [Select]
; (done_dialog [int]) ; [int] - what value must be returned after that button is pressed and the dialog is closed

Lee Mac

  • Seagull
  • Posts: 11679
  • AutoCAD 2015 Windows 7 London, England
Re: About action_tile
« Reply #3 on: November 27, 2016, 11:11:44 am »

Grrr1337

  • Bull Frog
  • Posts: 313
Re: About action_tile
« Reply #4 on: November 27, 2016, 01:26:31 pm »
I would suggest reading this tutorial to begin:

http://www.afralisp.net/dialog-control-language/tutorials/hiding-dialog-boxes.php
Thanks Lee,
I have read several times the DCL Beginners' Tutorials and completely forgot that there were also DCL Intermediate Tutorials.
Although I've read the DCL Without the DCL File - Part 1,2  :uglystupid2: