Jump to content

connection between listbox and slides


wesleyaqua

Recommended Posts

Hi

I'm trying to modify a blocklibary manager from teddycad.

no link.jpg

I would like that i can select the picture or the word in the listbox.

and that the matching word or picture is also selected.

also if i now click on the word it doesn't load the block.

maybe this is fixed when both are matched or otherwise i need to get it working when selected the word first.

 

if you need more info just ask


; User_Lib [user Library] - Inserts blocks from Library with user options. ; Arguments: 3 ; LibTitle$ = Library title ; PathDef$ = Pathname and DefFile name for slides ; PathBlk$ = Pathname and DefFile name for blocks ; Returns: Inserts a block from Library. ;------------------------------------------------------------------------------- (defun User_Lib (LibTitle$ PathDef$ PathBlk$ / Attribs$ AttribsList@ BlkList@ BlkPath$ Block$ BlockLen# Cnt# Dcl_Id% DefFile$ DefPath$ EOF Explode$ ExplodeList@ Field# FileName% ImageName$ Item$ Layer$ LayerList@ Mid$ No_Blks# No_Pages# Old_error Option# Osmode PathBlock$ Pg_No# Pick Point@ PointList@ Q$ Ref# Rep# Scale~ ScaleList@ SlideRef$ StartNo# Text$ UserPoint@ UserScale~ );variables (setq Old_error *error* *error* *BL_error*) (setvar "ATTREQ" 0) (setvar "CMDECHO" 0) (setvar "REGENMODE" 1) ;----------------------------------------------------------------------------- ; Evaluate Arguments and get DefPath$ and DefFile$ variables. ;----------------------------------------------------------------------------- (if (null LibTitle$) (setq LibTitle$ "Block") );if (if (null PathDef$) (setq PathDef$ "C:\\Custom\\Blk_Lib\\Blk_Lib.def") );if (setq DefPath$ (car (GetPathFile PathDef$))) (setq DefFile$ (cadr (GetPathFile PathDef$))) (if (null PathBlk$) (setq PathBlk$ PathDef$) );if (setq BlkPath$ (car (GetPathFile PathBlk$))) (princ (strcat "\n" LibTitle$ " Library "))(princ) (Custom_Dirs LibTitle$ PathDef$ PathBlk$) ;----------------------------------------------------------------------------- ; Get Lists from PathDef$ file. ;----------------------------------------------------------------------------- (if (findfile PathDef$) (setq FileName% (open PathDef$ "r")) (progn (GetOK "Block Library" (strcat DefFile$ " file not found\nfor " LibTitle$ " Library.") "AlertX" );GetOK (exit) );progn );if (setq Q$ "\"") (setq Rep# 0) (setq EOF nil) (setq Item$ "") (while (null EOF) (setq Rep# (1+ Rep#)) (if (= Rep# 20) (progn (setq Rep# 0) (Whirl) );progn );if (setq Text$ (read-line FileName%)) (if Text$ (if (= (substr Text$ 1 1) Q$) (progn (setq StartNo# 2) (setq Cnt# 1) (setq Field# 1) (while (and (<= Cnt# (strlen Text$)) (< Field# 6)) (setq Mid$ (substr Text$ Cnt# 3)) (if (= Mid$ "\",\"") (progn (setq Item$ (substr Text$ StartNo# (- Cnt# StartNo#)) );setq (cond ((= Field# 1) (if BlkList@ (setq BlkList@ (append BlkList@ (list Item$))) (setq BlkList@ (list Item$)) );if );Field# 1 ((= Field# 2) (if LayerList@ (setq LayerList@ (append LayerList@ (list Item$))) (setq LayerList@ (list Item$)) );if );Field# 2 ((= Field# 3) (if PointList@ (setq PointList@ (append PointList@ (list Item$))) (setq PointList@ (list Item$)) );if );Field# 3 ((= Field# 4) (if ScaleList@ (setq ScaleList@ (append ScaleList@ (list Item$))) (setq ScaleList@ (list Item$)) );if );Field# 4 ((= Field# 5) (if ExplodeList@ (setq ExplodeList@ (append ExplodeList@ (list Item$))) (setq ExplodeList@ (list Item$)) );if );Field# 5 (t (exit)) );cond (setq Field# (1+ Field#)) (setq StartNo# (+ Cnt# 3)) );progn );if (setq Cnt# (1+ Cnt#)) );while (setq Item$ (substr Text$ StartNo# (- (strlen Text$) StartNo#)) );setq (if AttribsList@ (setq AttribsList@ (append AttribsList@ (list Item$))) (setq AttribsList@ (list Item$)) );if );progn );if (setq EOF t) );if );while (princ " ") (close FileName%) (setq No_Pages# (fix (/ (1- (length BlkList@)) 20.0)) Pg_No# 0 BlockLen# (length BlkList@) Option# 99 );setq ;----------------------------------------------------------------------------- ; Load DCL dialog: Dwg_Blks in Blk_Lib.dcl ;----------------------------------------------------------------------------- (princ "\nSelect a block or option: ")(princ) (setq Dcl_Id% (load_dialog "Blk_Lib.dcl")) (while (/= Option# 1) (new_dialog "Dwg_Blks" Dcl_Id%) (start_list "blocknameslist")(mapcar 'add_list blkList@)(end_list) (set_tile "title" (strcat " " LibTitle$ " Library " (itoa (+ Pg_No# 1)) " of " (itoa (+ No_Pages# 1))) );set_tile (if (= Pg_No# No_Pages#) (mode_tile "next" 1) (mode_tile "next" 0) );if (if (= Pg_No# 0) (mode_tile "previous" 1) (mode_tile "previous" 0) );if (if (> BlockLen# 19) (setq No_Blks# 20) (setq No_Blks# BlockLen#) );if (action_tile "next" "(done_dialog 4)") (action_tile "previous" "(done_dialog 3)") (action_tile "cancel" "(done_dialog 2)") (setq Rep# 1) (repeat (fix No_Blks#) (action_tile (strcat "sld" (itoa Rep#)) "(setq SlideRef$ $key Pick t)") (setq ImageName$ (nth (+ (* Pg_No# 20) (- Rep# 1)) BlkList@)) (start_image (strcat "sld" (itoa Rep#))) (slide_image 0 0 (dimx_tile (strcat "sld" (itoa Rep#))) (dimy_tile (strcat "sld" (itoa Rep#))) (strcat DefPath$ ImageName$ ".sld") );slide_image (end_image) (set_tile (strcat "sld" (itoa Rep#) "text") ImageName$ );set_tile (setq Rep# (1+ Rep#)) );repeat (setq Option# (start_dialog)) (if (= Option# 4);next (setq Pg_No# (1+ Pg_No#) BlockLen# (- BlockLen# 20) SlideRef$ nil );setq );if (if (= Option# 3);previous (setq Pg_No# (- Pg_No# 1) BlockLen# (+ BlockLen# 20) SlideRef$ nil );setq );if (if (= Option# 2);cancel (setq Option# 1 SlideRef$ nil );setq );if );while (unload_dialog Dcl_Id%) (if (and SlideRef$ Pick) (progn (setq Ref# (- (+ (* Pg_No# 20) (atoi (substr SlideRef$ 4))) 1)) (setq Block$ (nth Ref# BlkList@) Layer$ (nth Ref# LayerList@) Point@ (nth Ref# PointList@) Scale~ (nth Ref# ScaleList@) Explode$ (nth Ref# ExplodeList@) Attribs$ (nth Ref# AttribsList@) );setq (setq PathBlock$ (strcat BlkPath$ Block$ ".dwg")) (if (or (= Block$ " ") (not (findfile PathBlock$))) (progn (if (/= Block$ " ") (GetOK (strcat LibTitle$ " Library") (strcat PathBlock$ "\nblock not found.") "AlertX" );GetOK );if (exit) );progn );if (if (= Point@ "Lower left limits") (setq Point@ (getvar "LIMMIN")) );if (if (= Point@ "Lower right limits") (setq Point@ (list (car (getvar "LIMMAX")) (cadr (getvar "LIMMIN")))) );if (if (= Point@ "Upper left limits") (setq Point@ (list (car (getvar "LIMMIN")) (cadr (getvar "LIMMAX")))) );if (if (= Point@ "Upper right limits") (setq Point@ (getvar "LIMMAX")) );if (if (and (= Point@ "User selects") (/= Scale~ "User selects")) (progn (while (null UserPoint@) (setq UserPoint@ (getpoint (strcat "\nInsertion point for " Block$ " block: ")) );setq );while (setq Point@ UserPoint@) );progn );if (if (/= Point@ "User selects") (progn (if (= (type Point@) 'STR) (setq Point@ (RealList Point@)) );if (if (/= (type Point@) 'LIST) (progn (GetOK (strcat LibTitle$ " Library") (strcat "Invalid insertion point for " Block$ "\nblock in " DefFile$ " file.") "AlertX" );GetOK (exit) );progn );if );progn );if (if (= Scale~ "Dim scale") (if (= (getvar "DIMSCALE") 0) (progn (GetOK (strcat LibTitle$ " Library") "DIMSCALE value must be greater than 0." "AlertX" );GetOK (exit) );progn (setq Scale~ (getvar "DIMSCALE")) );if );if (if (and (= Scale~ "User selects") (/= Point@ "User selects")) (progn (while (or (null UserScale~) (< UserScale~ 0)) (setq UserScale~ (getreal (strcat "\nScale factor for " Block$ " block <1>: ") );getreal );setq (if (null UserScale~) (setq UserScale~ 1.0) );if (if (<= UserScale~ 0) (princ "\nScale factor must be greater than 0.")(princ) );if );while (setq Scale~ (rtosr UserScale~)) );progn );if (if (/= Scale~ "User selects") (progn (if (= (type Scale~) 'STR) (setq Scale~ (atof Scale~)) );if (if (<= Scale~ 0) (progn (GetOK (strcat LibTitle$ " Library") (strcat "Invalid scale factor for " Block$ "\nblock in " DefFile$ " file.") "AlertX" );GetOK (exit) );progn );if );progn );if (setq Osmode (getvar "OSMODE")) (setvar "OSMODE" 0);None (if (= Explode$ "1");Yes (progn (setq PathBlock$ (strcat "*" BlkPath$ Block$)) (if (and (= Point@ "User selects") (= Scale~ "User selects")) (command ".INSERT" PathBlock$) (command ".INSERT" PathBlock$ Point@ Scale~) );if );progn (progn (setq PathBlock$ (strcat BlkPath$ Block$)) (if (/= Layer$ "Current layer") (if (tblsearch "LAYER" Layer$) (command ".LAYER" "T" Layer$ "U" Layer$ "ON" Layer$ "S" Layer$ "") (command ".LAYER" "M" Layer$ "") );if );if (if (and (= Point@ "User selects") (= Scale~ "User selects")) (progn (command ".INSERT" PathBlock$) );progn (command ".INSERT" PathBlock$ Point@ Scale~ "") );if );progn );if (setvar "OSMODE" Osmode) );progn );if (setq *error* Old_error) (princ) );defun User_Lib

Link to comment
Share on other sites

  • Replies 77
  • Created
  • Last Reply

Top Posters In This Topic

  • ymg3

    24

  • wesleyaqua

    24

  • Snownut

    12

  • AIberto

    6

Top Posters In This Topic

Posted Images

Instead of just image tiles (as shown), you need to make the pictures, image buttons, then you could select either (provided all the other code was updated also).

 

You will need to modify the lisp & dcl files.

Link to comment
Share on other sites

Instead of just image tiles (as shown), you need to make the pictures, image buttons, then you could select either (provided all the other code was updated also).

 

You will need to modify the lisp & dcl files.

 

I do agree , besides that you would need to have an action tile like this .

 

(action_tile "lst" "(mode_tile (nth (atoi (get_tile \"lst\")) l) 2)")

 

Where "lst" is the key of the List box tile and the variable l is a list of image keys .

 

Hope this helps .

Link to comment
Share on other sites

wesleyaqua,

 

Your code is missing function GETOK.

 

You would also need to post the dcl "Blk_Lib.dcl"

 

In order to test we would also need a portion of the library

with the slides.

 

Basic way is as per Tharwat's and Snownut answers.

 

ymg

Link to comment
Share on other sites

Bit old fashioned but does what you want is to use a mnu and use the image section you dont any need any fancy coding autocad does all that for you, you have to make slides though of our blocks, the manager will auto page if you have more than 1 page worth and select either image or text and the two highlight.

 

ScreenShot004.jpg

 

***image
**TRENCH
[TRENCH]
[sLD(CGG101,KERB)]^C^C(openblk "P:/ACADSTDS/CIVIL STANDARDS/CGG101") 
[sLD(CGG102,NATURE)]^C^C(openblk "P:/ACADSTDS/CIVIL STANDARDS/CGG102") 
**PIPES
[PIPES]
[sLD(SD201,SUBSOIL)]^C^C(openblk "P:/ACADSTDS/CIVIL STANDARDS/CGG201") 
[sLD(SD202,FLUSHOUT)]^C^C(openblk "P:/ACADSTDS/CIVIL STANDARDS/CGG202") 
[sLD(SD203,CATCH)]^C^C(openblk "P:/ACADSTDS/CIVIL STANDARDS/CGG203") 
[sLD(SD204,HOUSE)]^C^C(openblk "P:/ACADSTDS/CIVIL STANDARDS/CGG204") 
[sLD(SD205,STREET)]^C^C(openblk "P:/ACADSTDS/CIVIL STANDARDS/CGG205") 
[sLD(SD206,EASEMENT)]^C^C(openblk "P:/ACADSTDS/CIVIL STANDARDS/CGG206") 
[sLD(SD207,ANCHOR)]^C^C(openblk "P:/ACADSTDS/CIVIL STANDARDS/CGG207") 

Link to comment
Share on other sites

hi bigal.

wel we already uses the mnu way but we are going to revisted the whole library.

and with this lsp its easy to update the library. also we made the icons a bit bigger and the text space also.

thx for the info anyway

 

this is the part of the dcl he cals

//------------------------------------------------------------------------------
// Dwg_Blks [Drawing Blocks] - View and select drawing blocks
//------------------------------------------------------------------------------
Dwg_Blks : dialog {
 label = "";
 key = "title";
 initial_focus = "cancel";
 spacer;
 : row {
   : column {
     : list_box {
       label ="selecteer";
       key = "blocknameslist";
       height = 50;
       width = 25;
       multiple_select = false;
       fixed_width_font = true;
   allow_accept = true;
     }
   }
   : column {
     : row {
       : icon_image {
         key = "sld1";
         width = 25.92;
         height = 7.97;
         aspect_ratio = 1;
   }  
       : icon_image {
         key = "sld2";
         width = 25.92;
         height = 7.97;
         aspect_ratio = 1;
       }
       : icon_image {
         key = "sld3";
         width = 25.92;
         height = 7.97;
         aspect_ratio = 1;
       }
       : icon_image {
         key = "sld4";
         width = 25.92;
         height = 7.97;
         aspect_ratio = 1;
       }
       : icon_image {
         key = "sld5";
         width = 25.92;
         height = 7.97;
         aspect_ratio = 1;
       }
     }
     : row {
       : column {
         : text {
           key = "sld1text";
           label = "";
           width = 25.92;
           fixed_width = true;
           alignment = centered;
         }
       }
       : column {
         : text {
           key = "sld2text";
           label = "";
           width = 25.92;
           fixed_width = true;
           alignment = centered;
         }
       }
       : column {
         : text {
           key = "sld3text";
           label = "";
           width = 25.92;
           fixed_width = true;
           alignment = centered;
         }
       }
       : column {
         : text {
           key = "sld4text";
           label = "";
           width = 25.92;
           fixed_width = true;
           alignment = centered;
         }
       }
       : column {
         : text {
           key = "sld5text";
           label = "";
           width = 25.92;
           fixed_width = true;
           alignment = centered;
         }
       }
     }
     : row {
       : icon_image {
         key = "sld6";
         width = 25.92;
         height = 7.97;
         aspect_ratio = 1;
       }
       : icon_image {
         key = "sld7";
         width = 25.92;
         height = 7.97;
         aspect_ratio = 1;
       }
       : icon_image {
         key = "sld8";
         width = 25.92;
         height = 7.97;
         aspect_ratio = 1;
       }
       : icon_image {
         key = "sld9";
         width = 25.92;
         height = 7.97;
         aspect_ratio = 1;
       }
       : icon_image {
         key = "sld10";
         width = 25.92;
         height = 7.97;
         aspect_ratio = 1;
       }
     }
     : row {
       : column {
         : text {
           key = "sld6text";
           label = "";
           width = 25.92;
           fixed_width = true;
           alignment = centered;
         }
       }
       : column {
         : text {
           key = "sld7text";
           label = "";
           width = 25.92;
           fixed_width = true;
           alignment = centered;
         }
       }
       : column {
         : text {
           key = "sld8text";
           label = "";
           width = 25.92;
           fixed_width = true;
           alignment = centered;
         }
       }
       : column {
         : text {
           key = "sld9text";
           label = "";
           width = 25.92;
           fixed_width = true;
           alignment = centered;
         }
       }
       : column {
         : text {
           key = "sld10text";
           label = "";
           width = 25.92;
           fixed_width = true;
           alignment = centered;
         }
       }
     }
     : row {
       : icon_image {
         key = "sld11";
         width = 25.92;
         height = 7.97;
         aspect_ratio = 1;
       }
       : icon_image {
         key = "sld12";
         width = 25.92;
         height = 7.97;
         aspect_ratio = 1;
       }
       : icon_image {
         key = "sld13";
         width = 25.92;
         height = 7.97;
         aspect_ratio = 1;
       }
       : icon_image {
         key = "sld14";
         width = 25.92;
         height = 7.97;
         aspect_ratio = 1;
       }
       : icon_image {
         key = "sld15";
         width = 25.92;
         height = 7.97;
         aspect_ratio = 1;
       }
     }
     : row {
       : column {
         : text {
           key = "sld11text";
           label = "";
           width = 25.92;
           fixed_width = true;
           alignment = centered;
         }
       }
       : column {
         : text {
           key = "sld12text";
           label = "";
           width = 25.92;
           fixed_width = true;
           alignment = centered;
         }
       }
       : column {
         : text {
           key = "sld13text";
           label = "";
           width = 25.92;
           fixed_width = true;
           alignment = centered;
         }
       }
       : column {
         : text {
           key = "sld14text";
           label = "";
           width = 25.92;
           fixed_width = true;
           alignment = centered;
         }
       }
       : column {
         : text {
           key = "sld15text";
           label = "";
           width = 25.92;
           fixed_width = true;
           alignment = centered;
         }
       }
     }
     : row {
       : icon_image {
         key = "sld16";
         width = 25.92;
         height = 7.97;
         aspect_ratio = 1;
       }
       : icon_image {
         key = "sld17";
         width = 25.92;
         height = 7.97;
         aspect_ratio = 1;
       }
       : icon_image {
         key = "sld18";
         width = 25.92;
         height = 7.97;
         aspect_ratio = 1;
       }
       : icon_image {
         key = "sld19";
         width = 25.92;
         height = 7.97;
         aspect_ratio = 1;
       } 
       : icon_image {
         key = "sld20";
         width = 25.92;
         height = 7.97;
         aspect_ratio = 1;
       }
     }
     : row {
       : column {
         : text {
           key = "sld16text";
           label = "";
           width = 25.92;
           fixed_width = true;
           alignment = centered;
         }
       }
       : column {
         : text {
           key = "sld17text";
           label = "";
           width = 25.92;
           fixed_width = true;
           alignment = centered;
         }
       }
       : column {
         : text {
           key = "sld18text";
           label = "";
           width = 25.92;
           fixed_width = true;
           alignment = centered;
         }
       }
       : column {
         : text {
           key = "sld19text";
           label = "";
           width = 25.92;
           fixed_width = true;
           alignment = centered;
         }
       }
       : column {
         : text {
           key = "sld20text";
           label = "";
           width = 25.92;
           fixed_width = true;
           alignment = centered;
         } 
       }
     }
   }
 }
 : row {
   : column {
     : button {
       key   = "previous";
       label = "< Previous";
       mnemonic = "P";
       width = 70;
       fixed_width = true;
       alignment = centered;
     }
     : ok_button {
       mnemonic = "O";
       alignment = right;
       width = 11;
     }
   }
   : column {
     : button {
       key   = "next";
       label = "Next >";
       mnemonic = "N";
       width = 70;
       fixed_width = true;
       alignment = centered;
     }
     : cancel_button {
       mnemonic = "C";
       alignment = left;
       width = 11;
     }
   }
 }
}//Dwg_Blks

Edited by wesleyaqua
Link to comment
Share on other sites

i add the action_tile but i don't understand what to fill in as keys.

could i get some more info on how it works in more detail.

thx

 

;-------------------------------------------------------------------------------
; c:User_Lib - Calls function User_Lib with default arguments.
;-------------------------------------------------------------------------------
(defun c:User_Lib () (User_Lib nil nil nil) (princ))
;-------------------------------------------------------------------------------
; User_Lib [user Library] - Inserts blocks from Library with user options.
; Arguments: 3
;   LibTitle$ = Library title
;   PathDef$ = Pathname and DefFile name for slides
;   PathBlk$ = Pathname and DefFile name for blocks
; Returns: Inserts a block from Library.
;-------------------------------------------------------------------------------
(defun User_Lib (LibTitle$ PathDef$ PathBlk$ / Attribs$ AttribsList@
   BlkList@ BlkPath$ Block$ BlockLen# Cnt# Dcl_Id% DefFile$ DefPath$ EOF
   Explode$ ExplodeList@ Field# FileName% ImageName$ Item$ Layer$ LayerList@
   Mid$ No_Blks# No_Pages# Old_error Option# Osmode PathBlock$ Pg_No# Pick
   Point@ PointList@ Q$ Ref# Rep# Scale~ ScaleList@ SlideRef$ StartNo# Text$
   UserPoint@ UserScale~
 );variables
 (setq Old_error *error* *error* *BL_error*)
 (setvar "ATTREQ" 0) (setvar "CMDECHO" 0) (setvar "REGENMODE" 1)
 ;-----------------------------------------------------------------------------
 ; Evaluate Arguments and get DefPath$ and DefFile$ variables.
 ;-----------------------------------------------------------------------------
 (if (null LibTitle$)
   (setq LibTitle$ "Block")
 );if
 (if (null PathDef$)
   (setq PathDef$ "C:\\Custom\\Blk_Lib\\Blk_Lib.def")
 );if
 (setq DefPath$ (car (GetPathFile PathDef$)))
 (setq DefFile$ (cadr (GetPathFile PathDef$)))
 (if (null PathBlk$)
   (setq PathBlk$ PathDef$)
 );if
 (setq BlkPath$ (car (GetPathFile PathBlk$)))
 (princ (strcat "\n" LibTitle$ " Library "))(princ)
 (Custom_Dirs LibTitle$ PathDef$ PathBlk$)
 ;-----------------------------------------------------------------------------
 ; Get Lists from PathDef$ file.
 ;-----------------------------------------------------------------------------
 (if (findfile PathDef$)
   (setq FileName% (open PathDef$ "r"))
   (progn
     (GetOK "Block Library"
       (strcat DefFile$ " file not found\nfor " LibTitle$ " Library.") "AlertX"
     );GetOK
     (exit)
   );progn
 );if
 (setq Q$ "\"") (setq Rep# 0)
 (setq EOF nil) (setq Item$ "")
 (while (null EOF)
   (setq Rep# (1+ Rep#))
   (if (= Rep# 20)
     (progn
       (setq Rep# 0)
       (Whirl)
     );progn
   );if
   (setq Text$ (read-line FileName%))
   (if Text$
     (if (= (substr Text$ 1 1) Q$)
       (progn
         (setq StartNo# 2)
         (setq Cnt# 1)
         (setq Field# 1)
         (while (and (<= Cnt# (strlen Text$)) (< Field# 6))
           (setq Mid$ (substr Text$ Cnt# 3))
           (if (= Mid$ "\",\"")
             (progn
               (setq Item$
                 (substr Text$ StartNo# (- Cnt# StartNo#))
               );setq
               (cond
                 ((= Field# 1)
                   (if BlkList@
                     (setq BlkList@ (append BlkList@ (list Item$)))
                     (setq BlkList@ (list Item$))
             );if
                 );Field# 1
                 ((= Field# 2)
                   (if LayerList@
                     (setq LayerList@ (append LayerList@ (list Item$)))
                     (setq LayerList@ (list Item$))
                   );if
                 );Field# 2
                 ((= Field# 3)
                   (if PointList@
                     (setq PointList@ (append PointList@ (list Item$)))
                     (setq PointList@ (list Item$))
                   );if
                 );Field# 3
                 ((= Field# 4)
                   (if ScaleList@
                     (setq ScaleList@ (append ScaleList@ (list Item$)))
                     (setq ScaleList@ (list Item$))
                   );if
                 );Field# 4
                 ((= Field# 5)
                   (if ExplodeList@
                     (setq ExplodeList@ (append ExplodeList@ (list Item$)))
                     (setq ExplodeList@ (list Item$))
                   );if
                 );Field# 5
                 (t (exit))
               );cond
               (setq Field# (1+ Field#))
               (setq StartNo# (+ Cnt# 3))
             );progn
           );if
           (setq Cnt# (1+ Cnt#))
         );while
         (setq Item$
           (substr Text$ StartNo# (- (strlen Text$) StartNo#))
         );setq
         (if AttribsList@
           (setq AttribsList@ (append AttribsList@ (list Item$)))
           (setq AttribsList@ (list Item$))
         );if
       );progn
     );if
     (setq EOF t)
   );if
 );while
 (princ " ")
 (close FileName%)
 (setq No_Pages# (fix (/ (1- (length BlkList@)) 20.0))
       Pg_No# 0
       BlockLen# (length BlkList@)
       Option# 99
 );setq
 ;-----------------------------------------------------------------------------
 ; Load DCL dialog: Dwg_Blks in Blk_Lib.dcl
 ;-----------------------------------------------------------------------------
 (princ "\nSelect a block or option: ")(princ)
 (setq Dcl_Id% (load_dialog "Blk_Lib.dcl"))
 (while (/= Option# 1)
   (new_dialog "Dwg_Blks" Dcl_Id%)
     (start_list "blocknameslist")(mapcar 'add_list blklist@)(end_list)    
     (set_tile "blocknameslist" (strcat " " Libtitle$ " library "))
     (set_tile "title" (strcat " " LibTitle$ " Library "
     (itoa (+ Pg_No# 1)) " of " (itoa (+ No_Pages# 1)))
   );set_tile
   (if (= Pg_No# No_Pages#)
     (mode_tile "next" 1)
     (mode_tile "next" 0)
   );if
   (if (= Pg_No# 0)
     (mode_tile "previous" 1)
     (mode_tile "previous" 0)
   );if
   (if (> BlockLen# 19)
     (setq No_Blks# 20)
     (setq No_Blks# BlockLen#)
   );if
   (action_tile "next" "(done_dialog 4)")
   (action_tile "previous" "(done_dialog 3)")
   (action_tile "cancel" "(done_dialog 2)")
   (action_tile "blocknameslist" "(mode_tile (nth (atoi (get_tile \"blocknameslist\")) 1) 2)")
   (setq Rep# 1)
   (repeat (fix No_Blks#)
     (action_tile (strcat "sld" (itoa Rep#)) "(setq SlideRef$ $key Pick t)")
     (setq ImageName$ (nth (+ (* Pg_No# 20) (- Rep# 1)) BlkList@))
     (start_image (strcat "sld" (itoa Rep#)))
     (slide_image 0 0
       (dimx_tile (strcat "sld" (itoa Rep#)))
       (dimy_tile (strcat "sld" (itoa Rep#)))
       (strcat DefPath$ ImageName$ ".sld")
     );slide_image
     (end_image)
     (set_tile
       (strcat "sld" (itoa Rep#) "text") ImageName$
     );set_tile
     (setq Rep# (1+ Rep#))
   );repeat
   (setq Option# (start_dialog))
   (if (= Option# 4);next
     (setq Pg_No# (1+ Pg_No#)
           BlockLen# (- BlockLen# 20)
           SlideRef$ nil
     );setq
   );if
   (if (= Option# 3);previous
     (setq Pg_No# (- Pg_No# 1)
           BlockLen# (+ BlockLen# 20)
           SlideRef$ nil
     );setq
   );if
   (if (= Option# 2);cancel
     (setq Option# 1
           SlideRef$ nil
     );setq
   );if
 );while
 (unload_dialog Dcl_Id%)
 (if (and SlideRef$ Pick)
   (progn
     (setq Ref# (- (+ (* Pg_No# 20) (atoi (substr SlideRef$ 4))) 1))
     (setq Block$   (nth Ref# BlkList@)
           Layer$   (nth Ref# LayerList@)
           Point@   (nth Ref# PointList@)
           Scale~   (nth Ref# ScaleList@)
           Explode$ (nth Ref# ExplodeList@)
           Attribs$ (nth Ref# AttribsList@)
     );setq
     (setq PathBlock$ (strcat BlkPath$ Block$ ".dwg"))
     (if (or (= Block$ " ") (not (findfile PathBlock$)))
       (progn
         (if (/= Block$ " ")
           (GetOK (strcat LibTitle$ " Library")
             (strcat PathBlock$ "\nblock not found.") "AlertX"
           );GetOK
         );if
         (exit)
       );progn
     );if
     (if (= Point@ "Lower left limits")
       (setq Point@ (getvar "LIMMIN"))
     );if
     (if (= Point@ "Lower right limits")
       (setq Point@ (list (car (getvar "LIMMAX")) (cadr (getvar "LIMMIN"))))
     );if
     (if (= Point@ "Upper left limits")
       (setq Point@ (list (car (getvar "LIMMIN")) (cadr (getvar "LIMMAX"))))
     );if
     (if (= Point@ "Upper right limits")
       (setq Point@ (getvar "LIMMAX"))
     );if
     (if (and (= Point@ "User selects") (/= Scale~ "User selects"))
       (progn
         (while (null UserPoint@)
           (setq UserPoint@ (getpoint
             (strcat "\nInsertion point for " Block$ " block: "))
           );setq
         );while
         (setq Point@ UserPoint@)
       );progn
     );if
     (if (/= Point@ "User selects")
       (progn
         (if (= (type Point@) 'STR)
           (setq Point@ (RealList Point@))
         );if
         (if (/= (type Point@) 'LIST)
           (progn
             (GetOK (strcat LibTitle$ " Library")
               (strcat "Invalid insertion point for " Block$
               "\nblock in " DefFile$ " file.") "AlertX"
             );GetOK
             (exit)
           );progn
         );if
       );progn
     );if
     (if (= Scale~ "Dim scale")
       (if (= (getvar "DIMSCALE") 0)
         (progn
           (GetOK (strcat LibTitle$ " Library")
             "DIMSCALE value must be greater than 0." "AlertX"
           );GetOK
           (exit)
         );progn
         (setq Scale~ (getvar "DIMSCALE"))
       );if
     );if
     (if (and (= Scale~ "User selects") (/= Point@ "User selects"))
       (progn
         (while (or (null UserScale~) (< UserScale~ 0))
           (setq UserScale~
             (getreal
               (strcat "\nScale factor for " Block$ " block <1>: ")
             );getreal
           );setq
           (if (null UserScale~)
             (setq UserScale~ 1.0)
           );if
           (if (<= UserScale~ 0)
             (princ "\nScale factor must be greater than 0.")(princ)
           );if
         );while
         (setq Scale~ (rtosr UserScale~))
       );progn
     );if
     (if (/= Scale~ "User selects")
       (progn
         (if (= (type Scale~) 'STR)
           (setq Scale~ (atof Scale~))
         );if
         (if (<= Scale~ 0)
           (progn
             (GetOK (strcat LibTitle$ " Library")
               (strcat "Invalid scale factor for " Block$
               "\nblock in " DefFile$ " file.") "AlertX"
             );GetOK
             (exit)
           );progn
         );if
       );progn
     );if
     (setq Osmode (getvar "OSMODE"))
     (setvar "OSMODE" 0);None
     (if (= Explode$ "1");Yes
       (progn
         (setq PathBlock$ (strcat "*" BlkPath$ Block$))
         (if (and (= Point@ "User selects") (= Scale~ "User selects"))
           (command ".INSERT" PathBlock$)
           (command ".INSERT" PathBlock$ Point@ Scale~)
         );if
       );progn
       (progn
         (setq PathBlock$ (strcat BlkPath$ Block$))
         (if (/= Layer$ "Current layer")
           (if (tblsearch "LAYER" Layer$)
             (command ".LAYER" "T" Layer$ "U" Layer$ "ON" Layer$ "S" Layer$ "")
             (command ".LAYER" "M" Layer$ "")
           );if
         );if
         (if (and (= Point@ "User selects") (= Scale~ "User selects"))
           (progn
             (command ".INSERT" PathBlock$)
           );progn
           (command ".INSERT" PathBlock$ Point@ Scale~ "")
         );if
       );progn
     );if
     (setvar "OSMODE" Osmode)
   );progn
 );if
 (setq *error* Old_error)
 (princ)
);defun User_Lib

Link to comment
Share on other sites

Keys are your way to tie a portion of code within a lsp to the relevant portions within a dcl.

They are your "tile pointers" that you will use to reference back and forth the same tile in lisp and dcl, the main common element being the key name. Just like they're named. Put an action_tile with key "slide1" and you will cause the slide1 image to preform an action when a user clicks on it, because of the code that includes that tile's key. It's how the lisp knows which button/image/tile to associate which code with. Keep them clear in your head and clearer in your routine. Messing up your keys really badly can take hours to sort-out, and is no fun. I've re-written a routine or two because of the keys getting fudged up, but now that I understand them a bit better, they're pretty easy to use.

I'll post an excerpt from an app I've been working on (finally about 95% finished), as well as additional comments to help you understand, Wesley.

 

   ; Set Dialog Initial Settings, set initial values to be shown in DCL before user has a chance to input anything, also where code is to tell routine to store and re-load the last values that were used instead of the default values that are set up here.
  (set_tile "Title" "AutoExcel - AutoCAD to Excel for Instrument Index");;key "Title", pretty clear if you understand that set_tile presets tiles in a dcl then you can see that this is simply setting the title to the string right next to it.
  (set_tile "Dir" @excel_file);;for my tile "Dir" which is a directory selection I've got it defaulted to the global variable for the excel file in use
  (set_tile "eb1" @excel_row);;starting value for excel row, establishes global variable to use elsewhere
  (set_tile "dir" @excel_file);;redundant code that should be removed immediately, thanks for assisting me to catch this 
  (mode_tile "eb1" 2);;mode_tile sets the way tiles act 2 means to set focus i.e. pre-selected
  (mode_tile "eb1" 3);;mode_tile 3 means select edit box contents
  (set_tile "Rad101" "1");;set_tile with a radio button and "0" or "1" means off or on respectively, so i'm turning rad101 on and rad102 off
  (set_tile "Rad102" "0");; see above
  (if (set_tile "Rad103" "1")(setq @newfile T));if the app is successful in setting rad103 to on, then set newfile global variable to true
  (if (= (get_tile "Rad100") "Rad101")(mode_tile "But102" 1) );if rad100 and rad101 are the same values then disable but102.

   ; Dialog Actions
  (action_tile "Rad101" "(mode_tile \"But102\" 1)") ;;if rad101 selected then disallow selection of button 102
  (action_tile "eb1" "(setq ptx (vl-bb-set 'excelrow (atoi $value)))");;starting excel row, if changed store value in variable ptx and write to blackboard. atoi cause its a number and a string
  (action_tile "dir" "(setq @excel_file (atoi $value))")         ;;edit box for excel file selection, set file to variable @excel_file 
  (action_tile "accept"                                                     ;;ok button, main button to progress routine
(strcat                                                                           ;;strcat because all contents of an action tile are a string therefor multiple expressions must be wrapped in strcat
"(setq @Excel_ROW (get_tile \"eb1\"))"                           ;;when ok pressed store @excel_row from the value of "eb1"
"(done_dialog 1)"                                                           ;;done dialog 1
)                                                                                   ;;end strcat
)                                                                                   ;;close tile
  (action_tile "cancel" "(done_dialog 0)(setq result nil)")    ;;cancel button- done dialog 0 and set result to nil, action tiles do not need strcat if it is only two expressions or under, anything 3+ needs strcat.
  (action_tile "But102" "(done_dialog 4)")                         ;;if button 102 is pressed do done dialog 4
  (action_tile "Browse" "(folderdia)(done_dialog 5)")          ;;if browse button is pressed do folderdia subfunction and then done dialog 5
  (action_tile "Rad102" "(mode_tile \"Rad103\" 0)(setq @appendfile T)(setq @newfile nil)")           ;;toggle button, one must always be T, one always nil, this code controls that
  (action_tile "Rad103" "(mode_tile \"Rad102\" 0)(setq @newfile T)(setq @appendfile nil)")           ;;other button in toggle set, this for New/Append.
  (setq Return# (start_dialog))                                         ;;set return# to start_dialog 

   ; Unload Dialog and preform commands once dialog is unloaded but before processing further
  (unload_dialog Dcl_Id%)                       ;;remove dcl screen
  (vl-bb-set 'excelrow ptx)                       ;;write excelrow to blackboard
  (if @excel_file                                      ;;if excel file was chosen, write it to blackboard, else give the pointer a value of nil
  (vl-bb-set 'excel_file @excel_file)
  (vl-bb-set 'excel_file nil)
  );if

(cond                                                          ;;snippet to determine which subfunction to use, to me this is "modular"
((= return# 0)(exit))                                    ;;so-return#/(start_dialog/done_dialog counterpart) if 0 just exit and close program
((= return# 1)(checktype))                           ;;if done_dialog was 1 go to checktype subfunction
((= return# 4)(getexcelblocks))                     ;;if done_dialog was 4 goto subfunction getexcelblocks
((= return# 5)(C:putex))                               ;;if done_dialog was 5 do main putex function
);cond

 

Hopefully you can see how this code works with the keys and keeping in mind that it's from a DCL similar to yours may be able to find it helpful. Cheers

Link to comment
Share on other sites

Also!

The CASE for the KEYS is sensitive!

The two expressions

(set_tile "Dir" @excel_file);;for my tile "Dir" which is a directory selection I've got it defaulted to the global variable for the excel file in use

  (set_tile "dir" @excel_file);;redundant code that should be removed immediately, thanks for assisting me to catch this 

are different! because my key is "Dir" I must use the first, and the second although looks correct would not work and would do nothing

Link to comment
Share on other sites

wesleyaqua,

 

Try these change o the dcl part.

 

You will still need the action tile for all these image_button.

 

//------------------------------------------------------------------------------
// Dwg_Blks [Drawing Blocks] - View and select drawing blocks
//------------------------------------------------------------------------------
Dwg_Blks : dialog {
 label = "User_Lib Block Selector";
 key = "title";
 initial_focus = "cancel";
 spacer;
 : row {
   : column {
     : list_box {
       label ="Block Selector";
       key = "blocknameslist";
       height = 50;
       width = 25;
       multiple_select = false;
       fixed_width_font = true;
       allow_accept = true;
     }
   }
   : column {
     : row {
       : image_button {
         key = "sld1";
         color = graphics_background ;
         width = 25.92;
         height = 7.97;
         aspect_ratio = 1;
   }  
       : image_button {
         key = "sld2";
         color = graphics_background ;
         width = 25.92;
         height = 7.97;
         aspect_ratio = 1;
       }
       : image_button {
         key = "sld3";
         color = graphics_background ;
         width = 25.92;
         height = 7.97;
         aspect_ratio = 1;
       }
       : image_button {
         key = "sld4";
         color = graphics_background ;
         width = 25.92;
         height = 7.97;
         aspect_ratio = 1;
       }
       : image_button {
         key = "sld5";
         color = graphics_background ;
         width = 25.92;
         height = 7.97;
         aspect_ratio = 1;
       }
     }
     : row {
       : column {
         : text {
           key = "sld1text";
           label = "";
           width = 25.92;
           fixed_width = true;
           alignment = centered;
         }
       }
       : column {
         : text {
           key = "sld2text";
           label = "";
           width = 25.92;
           fixed_width = true;
           alignment = centered;
         }
       }
       : column {
         : text {
           key = "sld3text";
           label = "";
           width = 25.92;
           fixed_width = true;
           alignment = centered;
         }
       }
       : column {
         : text {
           key = "sld4text";
           label = "";
           width = 25.92;
           fixed_width = true;
           alignment = centered;
         }
       }
       : column {
         : text {
           key = "sld5text";
           label = "";
           width = 25.92;
           fixed_width = true;
           alignment = centered;
         }
       }
     }
     : row {
       : image_button {
         key = "sld6";
         color = graphics_background ;
         width = 25.92;
         height = 7.97;
         aspect_ratio = 1;
       }
       : image_button {
         key = "sld7";
         color = graphics_background ;
         width = 25.92;
         height = 7.97;
         aspect_ratio = 1;
       }
       : image_button {
         key = "sld8";
         color = graphics_background ;
         width = 25.92;
         height = 7.97;
         aspect_ratio = 1;
       }
       : image_button {
         key = "sld9";
         color = graphics_background ;
         width = 25.92;
         height = 7.97;
         aspect_ratio = 1;
       }
       : image_button {
         key = "sld10";
         color = graphics_background ;
         width = 25.92;
         height = 7.97;
         aspect_ratio = 1;
       }
     }
     : row {
       : column {
         : text {
           key = "sld6text";
           label = "";
           width = 25.92;
           fixed_width = true;
           alignment = centered;
         }
       }
       : column {
         : text {
           key = "sld7text";
           label = "";
           width = 25.92;
           fixed_width = true;
           alignment = centered;
         }
       }
       : column {
         : text {
           key = "sld8text";
           label = "";
           width = 25.92;
           fixed_width = true;
           alignment = centered;
         }
       }
       : column {
         : text {
           key = "sld9text";
           label = "";
           width = 25.92;
           fixed_width = true;
           alignment = centered;
         }
       }
       : column {
         : text {
           key = "sld10text";
           label = "";
           width = 25.92;
           fixed_width = true;
           alignment = centered;
         }
       }
     }
     : row {
       : image_button {
         key = "sld11";
         color = graphics_background ;
         width = 25.92;
         height = 7.97;
         aspect_ratio = 1;
       }
       : image_button {
         key = "sld12";
         color = graphics_background ;
         width = 25.92;
         height = 7.97;
         aspect_ratio = 1;
       }
       : image_button {
         key = "sld13";
         color = graphics_background ;
         width = 25.92;
         height = 7.97;
         aspect_ratio = 1;
       }
       : image_button {
         key = "sld14";
         color = graphics_background ;
         width = 25.92;
         height = 7.97;
         aspect_ratio = 1;
       }
       : image_button {
         key = "sld15";
         color = graphics_background ;
         width = 25.92;
         height = 7.97;
         aspect_ratio = 1;
       }
     }
     : row {
       : column {
         : text {
           key = "sld11text";
           label = "";
           width = 25.92;
           fixed_width = true;
           alignment = centered;
         }
       }
       : column {
         : text {
           key = "sld12text";
           label = "";
           width = 25.92;
           fixed_width = true;
           alignment = centered;
         }
       }
       : column {
         : text {
           key = "sld13text";
           label = "";
           width = 25.92;
           fixed_width = true;
           alignment = centered;
         }
       }
       : column {
         : text {
           key = "sld14text";
           label = "";
           width = 25.92;
           fixed_width = true;
           alignment = centered;
         }
       }
       : column {
         : text {
           key = "sld15text";
           label = "";
           width = 25.92;
           fixed_width = true;
           alignment = centered;
         }
       }
     }
     : row {
       : image_button {
         key = "sld16";
         color = graphics_background ;
         width = 25.92;
         height = 7.97;
         aspect_ratio = 1;
       }
       : image_button {
         key = "sld17";
         color = graphics_background ;
         width = 25.92;
         height = 7.97;
         aspect_ratio = 1;
       }
       : image_button {
         key = "sld18";
         color = graphics_background ;
         width = 25.92;
         height = 7.97;
         aspect_ratio = 1;
       }
       : image_button {
         key = "sld19";
         color = graphics_background ;
         width = 25.92;
         height = 7.97;
         aspect_ratio = 1;
       } 
       : image_button {
         key = "sld20";
         color = graphics_background ;
         width = 25.92;
         height = 7.97;
         aspect_ratio = 1;
       }
     }
     : row {
       : column {
         : text {
           key = "sld16text";
           label = "";
           width = 25.92;
           fixed_width = true;
           alignment = centered;
         }
       }
       : column {
         : text {
           key = "sld17text";
           label = "";
           width = 25.92;
           fixed_width = true;
           alignment = centered;
         }
       }
       : column {
         : text {
           key = "sld18text";
           label = "";
           width = 25.92;
           fixed_width = true;
           alignment = centered;
         }
       }
       : column {
         : text {
           key = "sld19text";
           label = "";
           width = 25.92;
           fixed_width = true;
           alignment = centered;
         }
       }
       : column {
         : text {
           key = "sld20text";
           label = "";
           width = 25.92;
           fixed_width = true;
           alignment = centered;
         } 
       }
     }
   }
 }
 : row {
   : column {
     : button {
       key   = "previous";
       label = "< Previous";
       mnemonic = "P";
       width = 70;
       fixed_width = true;
       alignment = centered;
     }
     : ok_button {
       mnemonic = "O";
       alignment = right;
       width = 11;
     }
   }
   : column {
     : button {
       key   = "next";
       label = "Next >";
       mnemonic = "N";
       width = 70;
       fixed_width = true;
       alignment = centered;
     }
     : cancel_button {
       mnemonic = "C";
       alignment = left;
       width = 11;
     }
   }
 }
}//Dwg_Blks

user_lib.jpg

Link to comment
Share on other sites

wesleyaqua,

 

Try these change o the dcl part.

 

You will still need the action tile for all these image_button.

 

//------------------------------------------------------------------------------
// Dwg_Blks [Drawing Blocks] - View and select drawing blocks
//------------------------------------------------------------------------------
Dwg_Blks : dialog {
 label = "User_Lib Block Selector";
 key = "title";
 initial_focus = "cancel";
 spacer;
 : row {
   : column {
     : list_box {
       label ="Block Selector";
       key = "blocknameslist";
       height = 50;
       width = 25;
       multiple_select = false;
       fixed_width_font = true;
       allow_accept = true;
     }
   }
   : column {
     : row {
       : image_button {
         key = "sld1";
         color = graphics_background ;
         width = 25.92;
         height = 7.97;
         aspect_ratio = 1;
   }  
       : image_button {
         key = "sld2";
         color = graphics_background ;
         width = 25.92;
         height = 7.97;
         aspect_ratio = 1;
       }
       : image_button {
         key = "sld3";
         color = graphics_background ;
         width = 25.92;
         height = 7.97;
         aspect_ratio = 1;
       }
       : image_button {
         key = "sld4";
         color = graphics_background ;
         width = 25.92;
         height = 7.97;
         aspect_ratio = 1;
       }
       : image_button {
         key = "sld5";
         color = graphics_background ;
         width = 25.92;
         height = 7.97;
         aspect_ratio = 1;
       }
     }
     : row {
       : column {
         : text {
           key = "sld1text";
           label = "";
           width = 25.92;
           fixed_width = true;
           alignment = centered;
         }
       }
       : column {
         : text {
           key = "sld2text";
           label = "";
           width = 25.92;
           fixed_width = true;
           alignment = centered;
         }
       }
       : column {
         : text {
           key = "sld3text";
           label = "";
           width = 25.92;
           fixed_width = true;
           alignment = centered;
         }
       }
       : column {
         : text {
           key = "sld4text";
           label = "";
           width = 25.92;
           fixed_width = true;
           alignment = centered;
         }
       }
       : column {
         : text {
           key = "sld5text";
           label = "";
           width = 25.92;
           fixed_width = true;
           alignment = centered;
         }
       }
     }
     : row {
       : image_button {
         key = "sld6";
         color = graphics_background ;
         width = 25.92;
         height = 7.97;
         aspect_ratio = 1;
       }
       : image_button {
         key = "sld7";
         color = graphics_background ;
         width = 25.92;
         height = 7.97;
         aspect_ratio = 1;
       }
       : image_button {
         key = "sld8";
         color = graphics_background ;
         width = 25.92;
         height = 7.97;
         aspect_ratio = 1;
       }
       : image_button {
         key = "sld9";
         color = graphics_background ;
         width = 25.92;
         height = 7.97;
         aspect_ratio = 1;
       }
       : image_button {
         key = "sld10";
         color = graphics_background ;
         width = 25.92;
         height = 7.97;
         aspect_ratio = 1;
       }
     }
     : row {
       : column {
         : text {
           key = "sld6text";
           label = "";
           width = 25.92;
           fixed_width = true;
           alignment = centered;
         }
       }
       : column {
         : text {
           key = "sld7text";
           label = "";
           width = 25.92;
           fixed_width = true;
           alignment = centered;
         }
       }
       : column {
         : text {
           key = "sld8text";
           label = "";
           width = 25.92;
           fixed_width = true;
           alignment = centered;
         }
       }
       : column {
         : text {
           key = "sld9text";
           label = "";
           width = 25.92;
           fixed_width = true;
           alignment = centered;
         }
       }
       : column {
         : text {
           key = "sld10text";
           label = "";
           width = 25.92;
           fixed_width = true;
           alignment = centered;
         }
       }
     }
     : row {
       : image_button {
         key = "sld11";
         color = graphics_background ;
         width = 25.92;
         height = 7.97;
         aspect_ratio = 1;
       }
       : image_button {
         key = "sld12";
         color = graphics_background ;
         width = 25.92;
         height = 7.97;
         aspect_ratio = 1;
       }
       : image_button {
         key = "sld13";
         color = graphics_background ;
         width = 25.92;
         height = 7.97;
         aspect_ratio = 1;
       }
       : image_button {
         key = "sld14";
         color = graphics_background ;
         width = 25.92;
         height = 7.97;
         aspect_ratio = 1;
       }
       : image_button {
         key = "sld15";
         color = graphics_background ;
         width = 25.92;
         height = 7.97;
         aspect_ratio = 1;
       }
     }
     : row {
       : column {
         : text {
           key = "sld11text";
           label = "";
           width = 25.92;
           fixed_width = true;
           alignment = centered;
         }
       }
       : column {
         : text {
           key = "sld12text";
           label = "";
           width = 25.92;
           fixed_width = true;
           alignment = centered;
         }
       }
       : column {
         : text {
           key = "sld13text";
           label = "";
           width = 25.92;
           fixed_width = true;
           alignment = centered;
         }
       }
       : column {
         : text {
           key = "sld14text";
           label = "";
           width = 25.92;
           fixed_width = true;
           alignment = centered;
         }
       }
       : column {
         : text {
           key = "sld15text";
           label = "";
           width = 25.92;
           fixed_width = true;
           alignment = centered;
         }
       }
     }
     : row {
       : image_button {
         key = "sld16";
         color = graphics_background ;
         width = 25.92;
         height = 7.97;
         aspect_ratio = 1;
       }
       : image_button {
         key = "sld17";
         color = graphics_background ;
         width = 25.92;
         height = 7.97;
         aspect_ratio = 1;
       }
       : image_button {
         key = "sld18";
         color = graphics_background ;
         width = 25.92;
         height = 7.97;
         aspect_ratio = 1;
       }
       : image_button {
         key = "sld19";
         color = graphics_background ;
         width = 25.92;
         height = 7.97;
         aspect_ratio = 1;
       } 
       : image_button {
         key = "sld20";
         color = graphics_background ;
         width = 25.92;
         height = 7.97;
         aspect_ratio = 1;
       }
     }
     : row {
       : column {
         : text {
           key = "sld16text";
           label = "";
           width = 25.92;
           fixed_width = true;
           alignment = centered;
         }
       }
       : column {
         : text {
           key = "sld17text";
           label = "";
           width = 25.92;
           fixed_width = true;
           alignment = centered;
         }
       }
       : column {
         : text {
           key = "sld18text";
           label = "";
           width = 25.92;
           fixed_width = true;
           alignment = centered;
         }
       }
       : column {
         : text {
           key = "sld19text";
           label = "";
           width = 25.92;
           fixed_width = true;
           alignment = centered;
         }
       }
       : column {
         : text {
           key = "sld20text";
           label = "";
           width = 25.92;
           fixed_width = true;
           alignment = centered;
         } 
       }
     }
   }
 }
 : row {
   : column {
     : button {
       key   = "previous";
       label = "< Previous";
       mnemonic = "P";
       width = 70;
       fixed_width = true;
       alignment = centered;
     }
     : ok_button {
       mnemonic = "O";
       alignment = right;
       width = 11;
     }
   }
   : column {
     : button {
       key   = "next";
       label = "Next >";
       mnemonic = "N";
       width = 70;
       fixed_width = true;
       alignment = centered;
     }
     : cancel_button {
       mnemonic = "C";
       alignment = left;
       width = 11;
     }
   }
 }
}//Dwg_Blks

 

i just copyed your code i got an error

if i click on the listbox i get this => "bad argument type: consp 1"

if i click on the image_button it works. but is there a way to double click on the image button that it also opens cause now i need to click on okay.

 

i think the problem is with the key in the action tile. i'll try to understand bhull1985 detailed info its a bit late to read that stuf

Link to comment
Share on other sites

A little tip, if you place this line as the 1st line in your DCL code...(prior to the Dwg_Blks... line)

 

imlst : image_button {color = graphics_background; width = 25.92; height= 7.97; aspect_ratio = 1; }

 

 

 

You can reduce every image_button call to this (just modify the key as appropriate);

 

: imlst { key = "sld2"; }

 

Then to make adjustments to you window size or color you can easily adjust with one adjustment.

 

You can then apply the same method to all the "text" lines, this will reduce your DCL file size dramatically.

Link to comment
Share on other sites

Tharwat,

 

nice example.

ymg

 

Thank you :)

 

But I believe the OP wants to click on the image and at that

point have the text Highlighted.

ymg

 

Easy one :

another.gif

Link to comment
Share on other sites

Thank you :)

 

 

 

Easy one :

 

indeed thats what i would like to have does it still works the other way also?

could you show me the dcl en lsp part of that.

would make it easyer to understand i think to intigrate it in my lsp

Link to comment
Share on other sites

indeed thats what i would like to have does it still works the other way also?

could you show me the dcl en lsp part of that.

would make it easyer to understand i think to intigrate it in my lsp

 

As I have mentioned my first ignored post by you , here is a sample test of what I indicated to .

 

NOTE : Don not forget to add two slide images with their path .

 

(defun c:Test (/ f d id)
 ;;    Tharwat 02. Apr. 2014        ;;
 (if (and (setq d (vl-filename-mktemp nil nil ".dcl")) (setq f (open d "w")))
   (progn (write-line
            (strcat
              "test : dialog { label = \"Example\"; width = 42;" ": row {" ": list_box { key = \"l\"; width = 5;}"
              ": column { " ": image_button { key = \"a\"; height = 4; width = 4; } "
              ": image_button { key = \"b\"; height = 4; width = 4; } }}"
              ": boxed_row { label = \"Action\"; fixed_width = true; alignment = centered;"
              ": button { label = \"Okay\"; key = \"oki\"; is_default = true; height = 1.75; width = 12;}"
              ": button { label = \"Exit\"; key = \"esc\"; is_cancel = true; height = 1.75; width = 12;}" "}}"
             )
            f
          )
          (close f)
   )
   (alert "Can't load the temporary file <!>")
 )
 (if (or (not d) (> 0 (setq id (load_dialog d))) (not (new_dialog "test" id)))
   (progn (if (> id 0)
            (unload_dialog id)
          )
          (if (and d (setq d (findfile d)))
            (vl-file-delete d)
          )
   )
   (progn (mapcar '(lambda (s k)
                     (start_image k)
                     (fill_image 0 0 (dimx_tile k) (dimy_tile k) 0)
                     (slide_image 0 0 (dimx_tile k) (dimy_tile k) s)
                     (end_image)
                   )
                  (list [color=magenta]"C:\\*****.sld" "C:\\******.sld"[/color]) [color=red]; Change these paths as per yours .[/color]
                  (list "a" "b")
          )
          (start_list "l")
          (mapcar 'add_list '("One" "Two"))
          (end_list)
          (mode_tile "a" 2)
          (set_tile "l" "0")
          (action_tile "a" "(set_tile \"l\" \"0\")")
          (action_tile "b" "(set_tile \"l\" \"1\")")
          (action_tile "oki" "(done_dialog)")
          (action_tile "esc" "(done_dialog)")
          (start_dialog)
          (unload_dialog id)
   )
 )
 (princ)
)

Link to comment
Share on other sites

Here's your dcl compressed as per Snownut's suggestion:

//------------------------------------------------------------------------------
// Dwg_Blks [Drawing Blocks] - View and select drawing blocks                   
//------------------------------------------------------------------------------
imlst : image_button {color = graphics_background; width = 25.92; height= 7.97; aspect_ratio = 1; }
txlst : text {label = ""; width = 25.92; fixed_width = true; alignment = centered; }
Dwg_Blks : dialog {
 label = "User_Lib Block Selector";
 key = "title";
 initial_focus = "cancel";
 spacer;
 : row {
   : column {
     : list_box {
       label ="Block Selector";
       key = "blocknameslist";
       height = 50;
       width = 25;
       multiple_select = false;
       fixed_width_font = true;
       allow_accept = true;
     }
   }
   : column {
     : row {
       : imlst { key = "sld1"; }
       : imlst { key = "sld2"; }
       : imlst { key = "sld3"; }
       : imlst { key = "sld4"; }
       : imlst { key = "sld5"; }
     }
     : row {
       : column {: txlst {key = "sld1text"; }}
       : column {: txlst {key = "sld2text"; }}
       : column {: txlst {key = "sld3text"; }}
       : column {: txlst {key = "sld4text"; }}
       : column {: txlst {key = "sld5text"; }}
     }
     : row {
       : imlst { key = "sld6"; }
       : imlst { key = "sld7"; }
       : imlst { key = "sld8"; }
       : imlst { key = "sld9"; }
       : imlst { key = "sld10"; }
     }
     : row {
       : column {: txlst {key = "sld6text"; }}
       : column {: txlst {key = "sld7text"; }}
       : column {: txlst {key = "sld8text"; }}
       : column {: txlst {key = "sld9text"; }}
       : column {: txlst {key = "sld10text"; }}
     }
     : row {
       : imlst { key = "sld11"; }
       : imlst { key = "sld12"; }
       : imlst { key = "sld13"; }
       : imlst { key = "sld14"; }
       : imlst { key = "sld15"; }
     }
     : row {
       : column {: txlst {key = "sld11text"; }}
       : column {: txlst {key = "sld12text"; }}
       : column {: txlst {key = "sld13text"; }}
       : column {: txlst {key = "sld14text"; }}
       : column {: txlst {key = "sld15text"; }}
     }
     : row {
       : imlst { key = "sld16"; }
       : imlst { key = "sld17"; }
       : imlst { key = "sld18"; }
       : imlst { key = "sld19"; }
       : imlst { key = "sld20"; }
     }
     : row {
       : column {: txlst {key = "sld16text"; }}
       : column {: txlst {key = "sld17text"; }}
       : column {: txlst {key = "sld18text"; }}
       : column {: txlst {key = "sld19text"; }}
       : column {: txlst {key = "sld20text"; }}
     }
   }
 }
 : row {
   : column {
     : button {
       key   = "previous";
       label = "< Previous";
       mnemonic = "P";
       width = 70;
       fixed_width = true;
       alignment = centered;
     }
     : ok_button {
       mnemonic = "O";
       alignment = right;
       width = 11;
     }
   }
   : column {
     : button {
       key   = "next";
       label = "Next >";
       mnemonic = "N";
       width = 70;
       fixed_width = true;
       alignment = centered;
     }
     : cancel_button {
       mnemonic = "C";
       alignment = left;
       width = 11;
     }
   }
 }
}//Dwg_Blks

Link to comment
Share on other sites

As I have mentioned my first ignored post by you , here is a sample test of what I indicated to .

 

NOTE : Don not forget to add two slide images with their path .

 

hi

 

i didn't ignore your 1ste post i just didn't understand it :) still a noob on lsp

i think i understand how you play with this lsp a bit now.

but i have a problem i can't make

=>action_tile "a" "set_tile \"1\" \"0\")")

for every sld.

i load a def file and he makes al the sld i also let the listbox read those words i think.

my start list is

 

(start_list "blocknameslist")(mapcar 'add_list blklist@)(end_list) 

 

how comes their aint a mode tile b ?

(mode_tile "a" 2)            (set_tile "l" "0")            (action_tile "a" "(set_tile \"l\" \"0\")")            (action_tile "b" "(set_tile \"l\" \"1\")")

 

i'll try to follow p all the commands but the understanding is a bit slow :)

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