Dialogue box

Dialogue box

Anonymous
Not applicable
927 Views
6 Replies
Message 1 of 7

Dialogue box

Anonymous
Not applicable

i need an idea about appearing dialogue box by lisp

 any one help me

eg: insersion of box different size

     50 x 50

     60 x60

     70 x 70

0 Likes
928 Views
6 Replies
Replies (6)
Message 2 of 7

Anonymous
Not applicable

DIAOGUE WINDOW

0 Likes
Message 3 of 7

scot-65
Advisor
Advisor
I typically do not download and view an attached DWG file.
Could you perhaps explain in more detail what it is you are
trying to design and provide a screen capture as well?

Edit box and slider combination to establish box sizes?
List of blocks that are different box sizes?

???

Scot-65
A gift of extraordinary Common Sense does not require an Acronym Suffix to be added to my given name.

0 Likes
Message 4 of 7

Anonymous
Not applicable

if i type command BOX  a dialogue should appear and i can select the different size of box.

when i click on the required size it should be inserted



 

0 Likes
Message 5 of 7

Anonymous
Not applicable

give me an example program of dialogue box

0 Likes
Message 6 of 7

Sea-Haven
Mentor
Mentor

You have 3 options 

A dcl with L & W see below

A dcl with a list of preset sizes see www.Lee-mac.com list box dcl

A dcl with both options you have to write

 

For you use example below for getval2

; Input  Dialog box with variable title
; multiple lines of dcl input supported
; add extra lines if required by copying code defun
; By Alan H 2015
(vl-load-com)

; 1 line dcl
; sample code (ah:getval1 "Line 1" 5 4 "-")
(defun AH:getval1 (title width limit def1 / fo fname)
; you can hard code a directory if you like for dcl file
(setq fo (open (setq fname (vl-filename-mktemp "" "" ".dcl")) "w"))
;(setq fo (open (setq fname "c:\\acadtemp\\getval.dcl") "w"))
(write-line "ddgetval : dialog {" fo)
(write-line " : row {" fo)
(write-line ": edit_box {" fo)
(write-line (strcat "    key = "  (chr 34) "key1" (chr 34) ";") fo)
(write-line  (strcat " label = "  (chr 34) title (chr 34) ";"  )   fo)
; these can be replaced with shorter value etc
(write-line (strcat "     edit_width = " (rtos width 2 0) ";" ) fo)
(write-line (strcat "     edit_limit = " (rtos limit 2 0) ";" ) fo)
(write-line "   is_enabled = true;" fo)
(write-line "    }" fo)
(write-line "  }" fo)
(write-line "ok_only;}" fo)
(close fo)

(setq dcl_id (load_dialog  fname))
; pt is a list 2 numbs -1 -1 centre ('(20 20))
;(not (new_dialog "test" dch "" *screenpoint*)) 
(if (not (new_dialog "ddgetval" dcl_id))
(exit))
(set_tile "key1" (setq val1 def1))
(action_tile "key1" "(setq val1 $value)")
(mode_tile "key1" 3)
(start_dialog)
(done_dialog)
(unload_dialog dcl_id)
; returns the value of val1 as a string
(vl-file-delete fname)
) ; defungetval1

; 2 line dcl
; sample code (ah:getval2 "Length" 5 4 "100" "Width" 8 7 "50")
(defun AH:getval2 (title1 width1 limit1 def1 title2 width2 limit2 def2 / fo fname)
(setq fo (open (setq fname (vl-filename-mktemp "" "" ".dcl")) "w"))
;(setq fo (open (setq fname "c:\\acadtemp\\getval.dcl") "w"))
(write-line "ddgetval2 : dialog {" fo)
(write-line " : column {" fo)
(write-line ": edit_box {" fo)
(write-line (strcat "    key = " (chr 34) "key1" (chr 34) ";") fo)
(write-line  (strcat " label = "  (chr 34) title1 (chr 34) ";" ) fo)
(write-line (strcat "     edit_width = " (rtos width1 2 0) ";" ) fo)
(write-line (strcat "     edit_limit = " (rtos limit1 2 0) ";" ) fo)
(write-line "   is_enabled = true ;" fo)
(write-line "    }" fo)
(write-line "spacer_1 ;" fo)
(write-line ": edit_box {" fo)
(write-line (strcat "    key = " (chr 34) "key2" (chr 34) ";") fo)
(write-line (strcat " label = "  (chr 34) title2 (chr 34) ";"  ) fo)
(write-line (strcat "     edit_width = " (rtos width2 2 0) ";" ) fo)
(write-line (strcat "     edit_limit = " (rtos limit2 2 0) ";" ) fo)
(write-line "   is_enabled = true ;" fo)
(write-line "    }" fo)
(write-line "    }" fo)
(write-line "spacer_1 ;" fo)
(write-line "ok_only;}" fo)
(close fo)

; code part
(setq dcl_id (load_dialog  fname))
(if (not (new_dialog "ddgetval2" dcl_id))
(exit))
(mode_tile "key1" 3)
(set_tile "key1" (setq val1 def1))
(action_tile "key1" "(setq val1 $value)")
(mode_tile "key2" 3)
(set_tile "key2" (setq val2 def2))
(action_tile "key2" "(setq val2 $value)")
(start_dialog)
(done_dialog)
(unload_dialog dcl_id)
; returns the value of val1 and val2 as strings
(vl-file-delete fname)
) ; defungetval2

; 3 line dcl
; sample code (ah:getval3 "Line 1" 5 4 "0.9" "Line 2" 8 7 "wow" "Line 3" 6 4 "123")

(defun AH:getval3 (title1 width1 limit1 def1 title2 width2 limit2 def2 title3 width3 limit3 def3 / fo fname)
(setq fo (open (setq fname (vl-filename-mktemp "" "" ".dcl")) "w"))
;(setq fo (open (setq fname "c:\\acadtemp\\getval.dcl") "w"))
(write-line "ddgetval3 : dialog {" fo)
(write-line " : column {" fo)
(write-line ": edit_box {" fo)
(write-line (strcat "    key = " (chr 34) "key1" (chr 34) ";") fo)
(write-line  (strcat " label = "  (chr 34) title1 (chr 34) ";" ) fo)
(write-line (strcat "     edit_width = " (rtos width1 2 0) ";" ) fo)
(write-line (strcat "     edit_limit = " (rtos limit1 2 0) ";" ) fo)
(write-line "   is_enabled = true ;" fo)
(write-line "    }" fo)
(write-line "spacer_1 ;" fo)
(write-line ": edit_box {" fo)
(write-line (strcat "    key = " (chr 34) "key2" (chr 34) ";") fo)
(write-line (strcat " label = "  (chr 34) title2 (chr 34) ";"  ) fo)
(write-line (strcat "     edit_width = " (rtos width2 2 0) ";" ) fo)
(write-line (strcat "     edit_limit = " (rtos limit2 2 0) ";" ) fo)
(write-line "   is_enabled = true ;" fo)
(write-line "    }" fo)
(write-line "spacer_1 ;" fo)
(write-line ": edit_box {" fo)
(write-line (strcat "    key = " (chr 34) "key3" (chr 34) ";") fo)
(write-line (strcat " label = "  (chr 34) title3 (chr 34) ";"  ) fo)
(write-line (strcat "     edit_width = " (rtos width3 2 0) ";" ) fo)
(write-line (strcat "     edit_limit = " (rtos limit3 2 0) ";" ) fo)
(write-line "   is_enabled = true ;" fo)
(write-line "    }" fo)
(write-line "    }" fo)
(write-line "spacer_1 ;" fo)
(write-line "ok_only;}" fo)
(close fo)

; code part
(setq dcl_id (load_dialog  fname))
(if (not (new_dialog "ddgetval3" dcl_id))
(exit))
(mode_tile "key1" 3)
(set_tile "key1" (setq val1 def1))
(action_tile "key1" "(setq val1 $value)")
(mode_tile "key2" 3)
(set_tile "key2" (setq val2 def2))
(action_tile "key2" "(setq val2 $value)")
(mode_tile "key3" 3)
(set_tile "key3" (setq val3 def3))
(action_tile "key3" "(setq val3 $value)")
(start_dialog)
(done_dialog)
(unload_dialog dcl_id)
; returns the value of val1 val2 and val3 as strings
(vl-file-delete fname)
) ; defungetval3


 

 

 

0 Likes
Message 7 of 7

smaher12
Advocate
Advocate

Based on the dwg that was attached, here is modified version from a AfraLISP.net example.

 

bb   : dialog {				//dialog name			
       label = "Box Insert";		//dialog label
spacer;

     : list_box {			//list box
        label = "&Select Size:";	//list box label
        key = "selections";		//key to list
        height = 8;			//height
        allow_accept = true ;	        //allow double clicking
     }				        //end list_box
spacer;
     ok_cancel ;			//OK and Cancel Buttons
     }

 

(defun C:BB (/)
  (setvar 'cmdecho 0)
  (setq	NAMES '("50x50" "60x60" "70x70"))
  (setq dialogshow T)				;set flag
  (setq dcl_id (load_dialog "bb.dcl"))		;initialise dialog box
  (if (not 					;check dcl exists
        (new_dialog "bb" dcl_id)		;load into memory
      );not
    (setq dialogshow nil)			;if not exit
  );if
(if dialogshow					;if dialog
(progn  					;continue with programme
(start_list "selections")			;start list box
  (mapcar 'add_list NAMES)			;add names from list
  (end_list)					;end list box
  (action_tile					
    "cancel"					;if cancel selected
    "(done_dialog) (setq userclick1 nil)"	;close dialog, set flag
  );action tile
  (action_tile
    "accept"					;if OK or double click
    (strcat
      "(progn (setq SIZA (atof (get_tile \"selections\")))" ;get size of box
      "(done_dialog) (setq userclick1 T))"	;close dialog and set flag
    );strcat
  );action tile
  (start_dialog)				;display dialog
  (unload_dialog dcl_id)			;unload dialog
  (if userclick1				;if OK or double click
    (progn					;continue with programme
      (setq SIZA (fix SIZA))			;convert index to integer

      (setq BXSZ				;block size name
        (cond
          ((= siza 0) "50")			;index no. 0 block name 50
          ((= siza 1) "60")			;index no. 1 block name 60
          ((= siza 2) "70")			;index no. 2 block name 70
         )
       )
      (command "-INSERT" BXSZ pause "" "" "")
    );progn
  );if userclick1
);progn
);if dialogshow
  (princ)
)

 

0 Likes