Jump to content

DCL Image slide by list box & edit box - help!


ODEY

Recommended Posts

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 browsing the 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.

Link to comment
Share on other sites

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
   ( (<= (setq dch (load_dialog "test_dcl.dcl")) 0)

     (princ "\n** DCL File not Found **")
   )
   ( (not (new_dialog "test_dcl" dch))

     (princ "\n** Dialog Could not be Loaded **")
   )
   (t
     (start_list "lst")
     (mapcar 'add_list (setq lst '("A" "B" "C" "D")))
     (end_list)

     (slide "sld" (strcat path (nth (atoi (set_tile "lst" "0")) lst) ".sld"))

     (action_tile "lst" "(slide \"sld\" (strcat path (nth (atoi $value) lst) \".sld\"))")

     (start_dialog)
     (unload_dialog dch)
   )
 )
 (princ)
)

 

(Untested)

 

However, I am not sure about the specification of the slide file, I haven't dealt with Slides in a long time, but in the past, I have only specified the slide name, not a filepath (in which case the slide needs to be in a support path).

Link to comment
Share on other sites

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 is when you dare trying to search for a diagram thru a slide and you don't know the code.

Link to comment
Share on other sites

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)
     )
   )
 )

Link to comment
Share on other sites

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

Link to comment
Share on other sites

BIGAL,

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

Thanks.

Link to comment
Share on other sites

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_tile  pd0  "(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;
}

Link to comment
Share on other sites

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")

Link to comment
Share on other sites

I must have changed the code at some stage its a few years old it was written for a specific purpose but I dont use it now. The file_ref is the name of a txt file which contains the slide names you could just create a list (setq Pts_lst '(dwg1 dwg2 dwg3 dwg4)) and remove the un-necessary code to read a file. It was done that way so it could be given to someone else who put their own slide names in the text file and not have to fiddle with code.

Link to comment
Share on other sites

  • 2 years later...
  • 1 year later...

I want to change the image when it is active when going through another edit_box edit_box to show my other imagime as possible that ,I do not need edit_list

DCL

test_dcl : dialog { label = "Lee Mac Modified";
 spacer;
 :row {
:boxed_column{label="Setari Corpuri Baza Bucatarie";
: edit_box { //define edit box
		key = "eb1" ;				//give it a name
		allow_accept = false; 
		is_tab_stop = false; 
		is_enabled  = true;
		
label = "&Gaura din fata fund/mm" ;		//give it a label
		edit_width = 4 ;			//4 characters only
       }//edit_box			
: edit_box { //define edit box
		key = "eb2" ;				//give it a name
		
		
label = "&Gaura din spate fund/mm" ;		//give it a label
		edit_width = 4 ;			//4 characters only
       }// edit_box		
: edit_box { //define edit box
		key = "eb3" ;				//give it a name
		
label = "&Gaura din spate lateral/mm" ;		//give it a label
		edit_width = 4 ;			//4 characters only
       }// edit_box				
: edit_box { //define edit box
		key = "eb4" ;				//give it a name
		
label = "&Gaura din fata lateral/mm" ;		//give it a label
		edit_width = 4 ;			//4 characters only
       }// edit_box						
	}// end boxed_column

: boxed_column { label = "Image Slide";
     : image { key = "sld"; 
	height = 15; 
	fixed_height = true;
       width = 50; 
	fixed_width = true; 
	color = 0; 
	aspect_ratio = 1;
       is_enabled = false; 
	is_tab_stop = false;
             }
   }
}

 ok_cancel;
}

 

lisp

(defun c:test( / slide path dch lst )
 (setq path "c:\\acad\\")
 (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)
     )
   )
 )
 (cond
   ( (<= (setq dch (load_dialog "test_dcl.dcl")) 0)
     (princ "\n** DCL File not Found **")
  )
   ( (not (new_dialog "test_dcl" dch))
     (princ "\n** Dialog Could not be Loaded **")
   )
   (t
     (start_list "lst")
     (mapcar 'add_list (setq lst '("A" "B" "C" "D" )))
     (end_list)
     (slide "sld" (strcat path (nth (atoi (set_tile "lst" "0")) lst) ".sld"))
     (action_tile "lst" "(slide \"sld\" (strcat path (nth (atoi $value) lst) \".sld\"))") 
     (start_dialog)
     (unload_dialog dch)
   )
 )
 (princ)
)

Edited by plecs
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...