TheSwamp
Code Red => AutoLISP (Vanilla / Visual) => Topic started by: Lee Mac on September 09, 2009, 08:29:50 AM
-
In my current project I would like to be able to double click on an item in a DCL list_box and have another dialog open with this action, however the only way I have found to have a double click is the "allow_accept" attribute.
But this would follow the action of the tile with the "accept" key. Therefore I considered having an arbitrary tile with the "accept" key to perform the actions I wanted, but this would mean a superfluous tile on the dialog (unless such things can be hidden?)
I am a bit stumped as to how to approach this one - but I do believe it to be possible, as I have seen a similar thing in action in MP's axprops.fas application (a very nice piece of work indeed).
Any help is appreciated,
Thanks,
Lee
-
Hi Lee..
Maybe this can Help..
Not very elegant...but it work.
(defun c:test (/ mylist dcl_id)
(createleemacdialog)
(setq dcl_id (load_dialog (strcat (getvar "SAVEFILEPATH") "test.dcl")))
(if (not (new_dialog "test" dcl_id))
(exit)
)
(setq mylist (list "Electrical" "Structural" "Plumbing" "Foundation"))
(start_list "LB1" 3)
(mapcar 'add_list mylist)
(end_list)
(action_tile
"LB1"
"(setq readlist (get_tile \"LB1\"))
(if (eq (nth (atoi readlist) myList) firstitem)
(progn
(alert (nth (atoi readlist) myList))
(setq firstitem nil)
)
(setq firstitem (nth (atoi readlist) myList))
)"
)
;;ACTION
(action_tile "accept" "(done_dialog) (setq userclick T)")
(action_tile "cancel" "(done_dialog) (setq userclick nil)")
(start_dialog)
(unload_dialog dcl_id)
(princ)
)
(defun createleemacdialog (/ dialf)
(setq dialf (open (strcat (getvar "SAVEFILEPATH") "test.dcl") "w"))
(write-line
"test : dialog {
label = \"test double click\" ;
: column {
: spacer {}
: boxed_column {
: spacer {}
label = \"ListBox :\";
: list_box {
key = \"LB1\";
}
}
: spacer {}
: text {
label = \"For LeeMac Only ! ;-)\";
}
: row {
children_alignment = top ;
}
}
: spacer {}
ok_cancel ;
}
" dialf
)
(close dialf)
)
-
Nice idea Andrea,
Thats a good substitute for the double click action - it doesn't emulate it exactly, as there can be an indefinite delay between the two clicks, but its pretty close :-)
Thanks,
Lee
-
maybe by adding this..
(defun c:test (/ mylist dcl_id)
(createleemacdialog)
(setq dcl_id (load_dialog (strcat (getvar "SAVEFILEPATH") "test.dcl")))
(if (not (new_dialog "test" dcl_id))
(exit)
)
(setq mylist (list "Electrical" "Structural" "Plumbing" "Foundation"))
(start_list "LB1" 3)
(mapcar 'add_list mylist)
(end_list)
(action_tile
"LB1"
"(setq readlist (get_tile \"LB1\"))
(setq start# (getvar \"date\"))
(if (and
(eq (nth (atoi readlist) mylist) firstitem)
(< (abs (read (rtos (- end# start#) 2 10))) 0.0000011667)
)
(progn (alert (nth (atoi readlist) mylist))
(setq firstitem nil)
)
(progn
(setq end# (getvar \"date\"))
(setq firstitem (nth (atoi readlist) mylist))
)
)"
)
;;ACTION
(action_tile "accept" "(done_dialog) (setq userclick T)")
(action_tile "cancel" "(done_dialog) (setq userclick nil)")
(start_dialog)
(unload_dialog dcl_id)
(princ)
)
(rtos (getvar "date") 2 8)
(defun createleemacdialog (/ dialf)
(setq dialf (open (strcat (getvar "SAVEFILEPATH") "test.dcl") "w"))
(write-line
"test : dialog {
label = \"test double click\" ;
: column {
: spacer {}
: boxed_column {
: spacer {}
label = \"ListBox :\";
: list_box {
key = \"LB1\";
}
}
: spacer {}
: text {
label = \"For LeeMac Only ! ;-)\";
}
: row {
children_alignment = top ;
}
}
: spacer {}
ok_cancel ;
}
" dialf
)
(close dialf)
)
-
Haven't tried your most recent post yet - but I had a dabble with this:
(defun c:test (/ mylist dcl_id ptr acptr)
(createleemacdialog)
(setq dcl_id (load_dialog (strcat (getvar "SAVEFILEPATH") "test.dcl")))
(if (not (new_dialog "test" dcl_id))
(exit)
)
(setq mylist (list "Electrical" "Structural" "Plumbing" "Foundation"))
(start_list "LB1" 3)
(mapcar 'add_list mylist)
(end_list)
(action_tile "accept" "(or (and acPtr
(not (alert (nth (atoi acPtr) mylist)))
(not (setq acPtr nil)))
(done_dialog))")
(action_tile "LB1" "(or (and (eq ptr $value)
(not (setq acPtr ptr ptr nil)))
(setq ptr $value))")
(action_tile "cancel" "(done_dialog)")
(start_dialog)
(unload_dialog dcl_id)
(princ)
)
(defun createleemacdialog (/ dialf)
(setq dialf (open (strcat (getvar "SAVEFILEPATH") "test.dcl") "w"))
(write-line
"test : dialog {
label = \"test double click\" ;
: column {
: spacer {}
: boxed_column {
: spacer {}
label = \"ListBox :\";
: list_box {
key = \"LB1\";
allow_accept = true;
}
}
: spacer {}
: text {
label = \"For LeeMac + Andrea Only ! ;-)\";
}
: row {
children_alignment = top ;
}
}
: spacer {}
ok_cancel ;
}
" dialf
)
(close dialf)
)
-
Very nice Andrea! - I like your thinking... when I said there was an indefinite about of time between clicks, you took this literally and put a cap on that time... nice thinking 8-)
-
Very nice Andrea! - I like your thinking... when I said there was an indefinite about of time between clicks, you took this literally and put a cap on that time... nice thinking 8-)
Thanks ! :angel:
that way you will be able to set double-click delay. :ugly:
-
A slightly tider action statement:
(action_tile "LB1"
"(setq start# (getvar \"date\"))
(if (and (eq ptr $value)
(< (abs (read (rtos (- end# start#) 2 10))) 0.0000011667))
(progn
(alert (nth (atoi ptr) mylist))
(setq ptr nil))
(setq end# (getvar \"date\") ptr $value))"
)
-
A slightly tider action statement:
(action_tile "LB1"
"(setq start# (getvar \"date\"))
(if (and (eq ptr $value)
(< (abs (read (rtos (- end# start#) 2 10))) 0.0000011667))
(progn
(alert (nth (atoi ptr) mylist))
(setq ptr nil))
(setq end# (getvar \"date\") ptr $value))"
)
not sure to understand...
why (eq ptr $value) ?
$value and ptr always = nil ?
-
$value is the value of the tile when the action_tile is triggered :-)
-
$value is the value of the tile when the action_tile is triggered :-)
oh ! I see... :?
nice...!! thanks !
-
;;;double clicking on image tile
(defun ARCH:SET_X (a) (setq x a))
(defun ARCH:READ_X (a)
(if (= x a)
(done_dialog)))
(action_tile
"S1"
"(ARCH:READ_X 1)(RESETNO-OFF)(ARCH:PLAY-SYM \"S1\" \"North\" \"Arrow\")(ARCH:SET_X 1)")
This is what I do for double clicking on button in a dialog box.
In the SYMS dialog box image below, a single click changes the image and a double click does the action.
The S1 image is in the upper left (north arrow) button.
-
. . . psst: OpenDCL.com
all the cool kids are doing it . . . 8-)
-
. . . psst: OpenDCL.com
all the cool kids are doing it . . . 8-)
I prefer ObjectDCL.com :pissed:
-
. . . psst: OpenDCL.com
all the cool kids are doing it . . . 8-)
I prefer ObjectDCL.com :pissed:
I haven't tried either tbh...
Andrea, is ObjectDCL part of your company?
JBuz > I have had a look at OpenDCL.com - may look into getting into it... not sure how easy it is to get to grips with though... :|
-
Andrea, is ObjectDCL part of your company?
Yes,..OpenDCL is a derivate product of ObjectDCL (the original)
-
OpenDCL is very easy to learn. Great support over at OpenDCL.com at the discussion forums and lots of tutorials and examples. The team is dedicated to keeping it in continual development. And it's free. Do a search here - I've posted some stuff. Defenitely check it out.
jb
-
Thanks mate,
Will definitely check it out.
I see quite a few downloads on the OpenDCL site, should I get: OpenDCL.Runtime.6.0.0.3.msi?
-
[...] should I get: OpenDCL.Runtime.6.0.0.3.msi?
You need OpenDcl.Studio (http://sourceforge.net/projects/opendcl/)
-
Ahh... thanks Mr Crank :-)
-
Haven't tried your most recent post yet - but I had a dabble with this:
(defun c:test (/ mylist dcl_id ptr acptr)
(createleemacdialog)
(setq dcl_id (load_dialog (strcat (getvar "SAVEFILEPATH") "test.dcl")))
(if (not (new_dialog "test" dcl_id))
(exit)
)
(setq mylist (list "Electrical" "Structural" "Plumbing" "Foundation"))
(start_list "LB1" 3)
(mapcar 'add_list mylist)
(end_list)
(action_tile "accept" "(or (and acPtr
(not (alert (nth (atoi acPtr) mylist)))
(not (setq acPtr nil)))
(done_dialog))")
(action_tile "LB1" "(or (and (eq ptr $value)
(not (setq acPtr ptr ptr nil)))
(setq ptr $value))")
(action_tile "cancel" "(done_dialog)")
(start_dialog)
(unload_dialog dcl_id)
(princ)
)
(defun createleemacdialog (/ dialf)
(setq dialf (open (strcat (getvar "SAVEFILEPATH") "test.dcl") "w"))
(write-line
"test : dialog {
label = \"test double click\" ;
: column {
: spacer {}
: boxed_column {
: spacer {}
label = \"ListBox :\";
: list_box {
key = \"LB1\";
allow_accept = true;
}
}
: spacer {}
: text {
label = \"For LeeMac + Andrea Only ! ;-)\";
}
: row {
children_alignment =
}
}
: spacer {}
ok_cancel ;
}
" dialf
)
(close dialf)
)
nice one.we can use command also?lee....like copy text(replaced by that "Electrical" "Structural" "Plumbing" "Foundation") double click means copy commend should active.....possible?
-
nice one.we can use command also?lee....like copy text(replaced by that "Electrical" "Structural" "Plumbing" "Foundation") double click means copy commend should active.....possible?
Many things are possible. :-)
-
nice one.we can use command also?lee....like copy text(replaced by that "Electrical" "Structural" "Plumbing" "Foundation") double click means copy commend should active.....possible?
Many things are possible. :-)
can you say for sample?i have tried with this.but this one autocad alert box.so command is not support.
-
Hi Lee
I just saw how old is original post... sorry if it is not actual anymore
Anyway, another method for double-click for your example
(action_tile "accept" "(done_dialog)")
(action_tile "LB1" "(if (= $reason 4)
(alert (nth (atoi $value) mylist))
(setq ptr $value))")
(action_tile "cancel" "(done_dialog)")
Note that is working no matter how allow_accept is set..
-
(= $reason 4)
How could I have missed that all this time... (http://www.theswamp.org/screens/leemac/facepalm.gif)
Thanks phanaem, appreciated.
-
nice one.we can use command also?lee....like copy text(replaced by that "Electrical" "Structural" "Plumbing" "Foundation") double click means copy commend should active.....possible?
Many things are possible. :-)
can you say for sample?i have tried with this.but this one autocad alert box.so command is not support.
The functionality you are looking for could probably be achieved using the allow_accept attribute, since the command would be started using the same action as the accept tile.
Example:
([color=BLUE]defun[/color] c:test ( [color=BLUE]/[/color] *error* coms dch file ok tmp )
[color=GREEN];;----------------------------------------------;;[/color]
[color=GREEN];; Example by Lee Mac 2011 - www.lee-mac.com ;;[/color]
[color=GREEN];;----------------------------------------------;;[/color]
([color=BLUE]defun[/color] *error* ( msg )
([color=BLUE]if[/color] ([color=BLUE]and[/color] dch ([color=BLUE]<[/color] 0 dch)) ([color=BLUE]unload_dialog[/color] dch))
([color=BLUE]if[/color] ([color=BLUE]and[/color] tmp ([color=BLUE]setq[/color] tmp ([color=BLUE]findfile[/color] tmp))) ([color=BLUE]vl-file-delete[/color] tmp))
([color=BLUE]if[/color] ([color=BLUE]and[/color] msg ([color=BLUE]not[/color] ([color=BLUE]wcmatch[/color] ([color=BLUE]strcase[/color] msg) [color=MAROON]"*BREAK,*CANCEL*,*EXIT*"[/color])))
([color=BLUE]princ[/color] ([color=BLUE]strcat[/color] [color=MAROON]"\n** Error: "[/color] msg [color=MAROON]" **"[/color]))
)
([color=BLUE]princ[/color])
)
([color=BLUE]setq[/color] coms
'(
[color=MAROON]"LINE"[/color]
[color=MAROON]"CIRCLE"[/color]
[color=MAROON]"ELLIPSE"[/color]
[color=MAROON]"XLINE"[/color]
[color=MAROON]"PLINE"[/color]
[color=MAROON]"POLYGON"[/color]
[color=MAROON]"ARC"[/color]
[color=MAROON]"POINT"[/color]
)
)
([color=BLUE]cond[/color]
(
([color=BLUE]not[/color]
([color=BLUE]and[/color] ([color=BLUE]setq[/color] file ([color=BLUE]open[/color] ([color=BLUE]setq[/color] tmp ([color=BLUE]vl-filename-mktemp[/color] [color=BLUE]nil[/color] [color=BLUE]nil[/color] [color=MAROON]".dcl"[/color])) [color=MAROON]"w"[/color]))
([color=BLUE]progn[/color]
([color=BLUE]write-line[/color]
([color=BLUE]strcat[/color]
[color=MAROON]"com : dialog { label = \"Commands\"; spacer; "[/color]
[color=MAROON]" : list_box { key = \"lst\"; alignment = centered; allow_accept = true; } ok_cancel; }"[/color]
)
file
)
([color=BLUE]<[/color] 0 ([color=BLUE]setq[/color] file ([color=BLUE]close[/color] file) dch ([color=BLUE]load_dialog[/color] tmp)))
)
([color=BLUE]new_dialog[/color] [color=MAROON]"com"[/color] dch)
)
)
([color=BLUE]princ[/color] [color=MAROON]"\n--> Error Loading Dialog."[/color])
)
([color=BLUE]t[/color]
([color=BLUE]start_list[/color] [color=MAROON]"lst"[/color])
([color=BLUE]mapcar[/color] '[color=BLUE]add_list[/color] ([color=BLUE]setq[/color] coms ([color=BLUE]acad_strlsort[/color] coms))) ([color=BLUE]end_list[/color])
([color=BLUE]setq[/color] *com ([color=BLUE]set_tile[/color] [color=MAROON]"lst"[/color] ([color=BLUE]cond[/color] ( *com ) ( [color=MAROON]"0"[/color] ))))
([color=BLUE]action_tile[/color] [color=MAROON]"lst"[/color] [color=MAROON]"(setq *com $value)"[/color])
([color=BLUE]setq[/color] ok ([color=BLUE]start_dialog[/color]))
)
)
(*error* [color=BLUE]nil[/color])
([color=BLUE]if[/color] ([color=BLUE]=[/color] 1 ok) ([color=BLUE]command[/color] ([color=BLUE]strcat[/color] [color=MAROON]"_."[/color] ([color=BLUE]nth[/color] ([color=BLUE]atoi[/color] *com) coms))))
([color=BLUE]princ[/color])
)
-
nice one.we can use command also?lee....like copy text(replaced by that "Electrical" "Structural" "Plumbing" "Foundation") double click means copy commend should active.....possible?
Many things are possible. :-)
can you say for sample?i have tried with this.but this one autocad alert box.so command is not support.
The functionality you are looking for could probably be achieved using the allow_accept attribute, since the command would be started using the same action as the accept tile.
Example:
([color=BLUE]defun[/color] c:test ( [color=BLUE]/[/color] *error* coms dch file ok tmp )
[color=GREEN];;----------------------------------------------;;[/color]
[color=GREEN];; Example by Lee Mac 2011 - www.lee-mac.com ;;[/color]
[color=GREEN];;----------------------------------------------;;[/color]
([color=BLUE]defun[/color] *error* ( msg )
([color=BLUE]if[/color] ([color=BLUE]and[/color] dch ([color=BLUE]<[/color] 0 dch)) ([color=BLUE]unload_dialog[/color] dch))
([color=BLUE]if[/color] ([color=BLUE]and[/color] tmp ([color=BLUE]setq[/color] tmp ([color=BLUE]findfile[/color] tmp))) ([color=BLUE]vl-file-delete[/color] tmp))
([color=BLUE]if[/color] ([color=BLUE]and[/color] msg ([color=BLUE]not[/color] ([color=BLUE]wcmatch[/color] ([color=BLUE]strcase[/color] msg) [color=MAROON]"*BREAK,*CANCEL*,*EXIT*"[/color])))
([color=BLUE]princ[/color] ([color=BLUE]strcat[/color] [color=MAROON]"\n** Error: "[/color] msg [color=MAROON]" **"[/color]))
)
([color=BLUE]princ[/color])
)
([color=BLUE]setq[/color] coms
'(
[color=MAROON]"LINE"[/color]
[color=MAROON]"CIRCLE"[/color]
[color=MAROON]"ELLIPSE"[/color]
[color=MAROON]"XLINE"[/color]
[color=MAROON]"PLINE"[/color]
[color=MAROON]"POLYGON"[/color]
[color=MAROON]"ARC"[/color]
[color=MAROON]"POINT"[/color]
)
)
([color=BLUE]cond[/color]
(
([color=BLUE]not[/color]
([color=BLUE]and[/color] ([color=BLUE]setq[/color] file ([color=BLUE]open[/color] ([color=BLUE]setq[/color] tmp ([color=BLUE]vl-filename-mktemp[/color] [color=BLUE]nil[/color] [color=BLUE]nil[/color] [color=MAROON]".dcl"[/color])) [color=MAROON]"w"[/color]))
([color=BLUE]progn[/color]
([color=BLUE]write-line[/color]
([color=BLUE]strcat[/color]
[color=MAROON]"com : dialog { label = \"Commands\"; spacer; "[/color]
[color=MAROON]" : list_box { key = \"lst\"; alignment = centered; allow_accept = true; } ok_cancel; }"[/color]
)
file
)
([color=BLUE]<[/color] 0 ([color=BLUE]setq[/color] file ([color=BLUE]close[/color] file) dch ([color=BLUE]load_dialog[/color] tmp)))
)
([color=BLUE]new_dialog[/color] [color=MAROON]"com"[/color] dch)
)
)
([color=BLUE]princ[/color] [color=MAROON]"\n--> Error Loading Dialog."[/color])
)
([color=BLUE]t[/color]
([color=BLUE]start_list[/color] [color=MAROON]"lst"[/color])
([color=BLUE]mapcar[/color] '[color=BLUE]add_list[/color] ([color=BLUE]setq[/color] coms ([color=BLUE]acad_strlsort[/color] coms))) ([color=BLUE]end_list[/color])
([color=BLUE]setq[/color] *com ([color=BLUE]set_tile[/color] [color=MAROON]"lst"[/color] ([color=BLUE]cond[/color] ( *com ) ( [color=MAROON]"0"[/color] ))))
([color=BLUE]action_tile[/color] [color=MAROON]"lst"[/color] [color=MAROON]"(setq *com $value)"[/color])
([color=BLUE]setq[/color] ok ([color=BLUE]start_dialog[/color]))
)
)
(*error* [color=BLUE]nil[/color])
([color=BLUE]if[/color] ([color=BLUE]=[/color] 1 ok) ([color=BLUE]command[/color] ([color=BLUE]strcat[/color] [color=MAROON]"_."[/color] ([color=BLUE]nth[/color] ([color=BLUE]atoi[/color] *com) coms))))
([color=BLUE]princ[/color])
)
lee our lisp commands is not supporting here!!???its supporting only cad commands.why?
-
lee our lisp commands is not supporting here!!???its supporting only cad commands.why?
Because the code was designed for AutoCAD commands, not LISP functions.
-
lee our lisp commands is not supporting here!!???its supporting only cad commands.why?
Because the code was designed for AutoCAD commands, not LISP functions.
how can modify this for lsp commands lee
-
lee our lisp commands is not supporting here!!???its supporting only cad commands.why?
Because the code was designed for AutoCAD commands, not LISP functions.
how can modify this for lsp commands lee
You would have to change the line:
(if (= 1 ok) (command (strcat "_." (nth (atoi *com) coms))))
To call the LISP function instead, something like:
(if (= 1 ok) (eval (read (strcat "(c:" (nth (atoi *com) coms) ")"))))
-
JBuz > I have had a look at OpenDCL.com - may look into getting into it... not sure how easy it is to get to grips with though... :|
Lee, If i can whiz around in this you absolutely will be able to
it is very easy to learn in a days time