ODEY 发表于 2022-7-5 22:24:08

DCL Image slide by list box &

hi guys!it's been quite a long time since my last visit here. i discovered autolisp last march & got interested to learn it. but due to my busy schedule i stopped some time in june and recently i just found myself browsingthe afralisp tutorials and some other sites, and this time i trying to include DCL w/c i was avoiding before. and i find a autolisp routine more appreciative if DCL is include. can somebody help me cause i'm stocked with this one. 1'm creating a routine with image slide changing according to the list box selected.
i think synchronizing list box to edit box has drained my brain (as a novice) and nothing is left to figure out for the image slide ;-)
thanks in advance.
 

test_dcl : dialog {             : row {       : boxed_column {       label = "Image Slide";       : image {         key = "dclsld";         height = 10;      fixed_height = true;      width = 30;      fixed_width = true;            color = 0;         aspect_ratio = 1;         is_enabled = false;          is_tab_stop = false;       }       }       : boxed_column {       : edit_box {       label = "Enter";       key = "dclebox";       edit_width = 2;       edit_limit = 2;       }       : list_box {       key = "dcllbox";       height = 7;                      fixed_height = true;       width = 10;       fixed_width = true;            allow_accept = false;       is_tab_stop = false;       is_enabled= true;       }       }       }       ok_cancel;       }      
 

(defun c:test(/) (setq path "c:/acad/") (setq wrd "A") (setq wrdlst (list "A" "B" "C" "D")) (setq lstlen (length wrdlst)) (setq dcl_id (load_dialog "test_dcl.dcl ")) (if (not (new_dialog "test_dcl" dcl_id))   (exit)) (start_image "dclsld")(setq X (- (dimx_tile "dclsld") 2)) (setq Y (- (dimy_tile "dclsld") 2))(end_image) (start_image "dclsld")(slide_image 1 1 X Y (strcat path wrd))(end_image) (set_tile "dclebox" wrd) (set_tile_list "dcllbox" wrdlst wrd);;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;(action_tile "dcllbox" "(set_list_value \"wrdlst\" \"wrd\")")(action_tile "dcllbox" "(dcllbox_action $value $reason)")       (action_tile "dclebox" "(dclebox_action $value $reason)")(action_tile "accept" "(setq wrd (get_tile \"dclebox\"))             (done_dialog)(setq userclick T)") (start_dialog)    (unload_dialog dcl_id) (princ));defun;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;(defun set_tile_list (KeyName$ ListName@ Selected / Item) (start_list KeyName$ 3) (mapcar 'add_list ListName@) (end_list) (foreach Item (if (listp Selected) Selected (list Selected))(if (member Item ListName@)    (set_tile KeyName$ (itoa (- (length ListName@) (length (member Item ListName@))))));if );foreach);defun set_tile_list;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;(defun set_list_value (SentList$ SentVar$ / SaveVar$ SubList@) (setq SubList@ (eval (read SentList$))) (setq SaveVar$ (eval (read SentVar$))) (set (read SentVar$) (nth (atoi $value) SubList@)) (if (= (eval (read SentVar$)) "")   (progn   (set (read SentVar$) SaveVar$)   (set_tile_list $key SubList@ SaveVar$)   );progn );if (princ));defun set_list_value;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;(defun dcllbox_action (val why)            (if (or (= why 2) (= why 1))      (set_tile "dclebox" (nth (atoi val) wrdlst))))         ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;(defun dclebox_action (val why)                (if (or (= why 2) (= why 1))   (set_tile "dcllbox" (itoa(+(- lstlen (length(member val wrdlst))))))))
 
 
"set_tile_list & set_list_value" syntax is courtesy of TERRYCAD
 
......i found this here in previous thread but i can't seem to work it.
 

;(start_image "dclsld") ;this will start image actions;(fill_image "dclsld" 0 0 (dimx_tile "dclsld") (dimy_tile "dclsld") -15) ;this will clear previous display;(slide_image "dclsld" 0 0 (dimx_tile "dclsld") (strcat path wrd )) ;this will load a slide image;(end_image) ;this will close image actions   
 
 
i'm having a problem w/ uploading my slide files. it says invalid file. any way, anybody wants to help can make them thru mslide.

Lee Mac 发表于 2022-7-5 22:29:02

In principal, something like this (not sure what you wanted to do with the edit_box setup, so just focused on the list_box):
 

test_dcl : dialog { label = "Lee Mac Modified"; spacer; : row {    : boxed_column { label = "Image Slide";   : image { key = "sld"; height = 10; fixed_height = true;               width = 30; fixed_width = true; color = 0; aspect_ratio = 1;               is_enabled = false; is_tab_stop = false;             }   }   : boxed_column {   : list_box { key = "lst"; height = 7; fixed_height = true; width = 10;                  fixed_width = true; allow_accept = false; is_tab_stop = false; is_enabled= true;                }   } } ok_cancel;}
 

(defun c:test( / slide path dch lst ) (setq path "c:\\acad\\") (defun slide ( key file )   (if (setq file (findfile file))   (progn       (start_image key)       (slide_image 1 1 (- (dimx_tile key) 2) (- (dimy_tile key) 2) file)       (end_image)   )   ) ) (cond   ( (

ODEY 发表于 2022-7-5 22:33:13

mr. lee,
thanks for the quick response. it is almost working good but there's one problem, the previous slide isn't clearing every time you select an option.
by the way, the function of the edit box is when you have like hundred of list options and you know exactly what you need, just simply type it and as for the list box iswhen you dare trying to search for a diagram thru a slide and you don't know the code.

Lee Mac 发表于 2022-7-5 22:38:48

Ah I see, change:
 

(defun slide ( key file )   (if (setq file (findfile file))   (progn       (start_image key)       (slide_image 1 1 (- (dimx_tile key) 2) (- (dimy_tile key) 2) file)       (end_image)   )   ) )to:
 

(defun slide ( key file )   (if (setq file (findfile file))   (progn       (start_image key)       (fill_image 0 0 (dimx_tile key) (dimy_tile key) 0)       (slide_image 1 1 (- (dimx_tile key) 2) (- (dimy_tile key) 2) file)       (end_image)   )   ) )

ODEY 发表于 2022-7-5 22:45:32

PERFECT! Thank you very much.

Lee Mac 发表于 2022-7-5 22:48:24

You're welcome ODEY

BIGAL 发表于 2022-7-5 22:51:16

Dont know if this of any any help but you can create dcl's with multiple image display I created 2x2 3x3 4x4 dcl's making them globaly useable to any program so not hard coded to one program.
 
If you want info just ask

ODEY 发表于 2022-7-5 22:57:01

BIGAL,
Sure, can you show me? sometimes i don't realized i need something untili've seen one. i may not need it at the moment but perhaps in thefuture.
Thanks.

BIGAL 发表于 2022-7-5 23:01:47

Heres a 2x2 just add more for 3x2 3x3 etc
Lisp
only thing missing is pts_lst which would be a list of names of your 4 slides

;;;   LaN4.LSP   used to set up dimension varaibles;;;               Uses a 2x2.dcl for the dialogue definition.The;;;               slide images are in list pts_lst.;;;               pads out blank screens(setvar "CMDECHO" 0)(setq pts_lst nil)(defun subdlg () (setq dcl_id (load_dialog"ddval")) (if (not (new_dialog "ddval" dcl_id)) (exit)) (action_tile "sizze" "(setq dimval (atof $value))(done_dialog)") (mode_tile "sizze" 3) (start_dialog))(defun alan2 ()   (setq ans $key)   (cond   ((= ans "22sq1")(done_dialog) (setq ans (nth 0 pts_lst)))   ((= ans "22sq2")(done_dialog) (setq ans (nth 1 pts_lst)))   ((= ans "22sq3")(done_dialog) (setq ans (nth 2 pts_lst)))   ((= ans "22sq4")(done_dialog) (setq ans (nth 3 pts_lst)))   ))                                                   ; calculates next slide(defun alan4 () (setq x (+ x 1)) (setq sldname (nth x pts_lst))); third step; set up slide libraray (defun ptype_start () (setq x -1) (foreach pts0 pts_lst2   (alan4)   (start_image pts0)   (slide_image 0 0 (- (dimx_tile pts0) 1) (- (dimy_tile pts0) 1) sldname)   (end_image) )); this is second step;now check each sq if picked then run alan2(defun ptype_main (/ globals) (ptype_start) (foreach pd0 pts_lst2   (action_tilepd0"(alan2)") ) (start_dialog)); this is first step passed file name from autocad menu (setq file_ref "c:\acadstds\cogg-1.lst");(setq file_ref (findfile refname))(setq fo (open file_ref "r"));1st line are not needed just a heading      ;(read-line fo)(while (setq new_line (read-line fo)) (setq pts_lst (cons new_line pts_lst)) )(reverse pts_lst)(close fo); pad the blankboxes out with the lanig logo(setq z (length pts_lst))(if (< z 4)   (progn    (setq new_line (strcase "c:\\acadstds\\cogglogo" T))   (setq w (- 4 z))   (repeat w   (setq pts_lst (cons new_line pts_lst))      )   )); name of squares in dialog box(setq pts_lst2 '("22sq1" "22sq2" "22sq3" "22sq4")) (setq app "dd2x2.dcl")(setq dcl_id (load_dialog app)) (if (not (new_dialog "dd2x2" dcl_id)) (exit))(ptype_main) (setq *error* old_error old_error nil)(done_dialog)(setq      pts_lst nil   x nil   y nil   z nil         new_line nil   pts_lst2 nil   sldname nil)(princ)
 
DCL

//DD2x2 dialogue.Used by the DD2x2 command in DD2x2.lsp.//Called from the AutoCAD Release 12 Standard Menu.dd2x2 : dialog { label      = "Please choose item"; : column {   : row {   : image_button {       key          = "22sq1";       width      = 35;       aspect_ratio = 0.85;       color      = graphics_background;       allow_accept = true;   }   : image_button {       key          = "22sq2";       width      = 35;       aspect_ratio = 0.85;       color      = graphics_background;       allow_accept = true;   }   }   : row {   : image_button {       key          = "22sq3";       width      = 35;       aspect_ratio = 0.85;       color      = graphics_background;       allow_accept = true;   }   : image_button {       key          = "22sq4";       width      = 35;       aspect_ratio = 0.85;       color      = graphics_background;       allow_accept = true;   }   } }ok_cancel;}

ODEY 发表于 2022-7-5 23:06:09

This is great. Thou I haven’t tried running this yet but I think I have an idea how can it be useful. I think this can work when you need a diagram slide to show views, let say front, left, right &top then the next move will be determined by opting from those views. If it is so, then yes I may need this. But I have a couple of questions.
   Is this means this routine doesn’t deal w/ .sld file?. If it is not, then how can I create such file. Please excuse my ignorance.

(setq file_ref "c:\acadstds\cogg-1.lst")
页: [1] 2
查看完整版本: DCL Image slide by list box &