Visual LISP, AutoLISP and General Customization
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

DCL Using radio buttons to control what list is in the popup_list column

8 REPLIES 8
Reply
Message 1 of 9
chasedowdeswell
3021 Views, 8 Replies

DCL Using radio buttons to control what list is in the popup_list column

So, I am now trying to work with DCL to make my program much more user friendly and I have come into a little bit of a problem.

 

I have set up a dcl code with the autolisp code to give me this:

Dialog Box.png

 

And in "Sheet Units" box where the user selects either Metric or Imperial I want the popup list below to switch between the Metric size lists of sheets or to the Imperial size lists of sheets. Right now no mattter what I pick the list is always the Imperial selection.

 

If anyone has any hints or ideas on how to have the list change based on which radio button is picked I would be extremely grateful!

 

Below is the DCL code followed the Lisp code:

//--------------------------------------------------------------------------
// PlanTemplate.LSP       CREATE GRID AND PLACE COORDINATE NORTHING AND EASTINGS
//==========================================================================
//DESCRIPTION:  This program will ask the user to outline the two corners of
//              the grid as well as the grid spacing and then proceed to 
//              create the grid based on those inputs. The program also works
//              to create Northing and Easting labels along the grid based on
//              the paper size and coordinates of the grid.            
//                
//
//START COMMAND........   GridCL GRIDCT
//
//WRITTEN BY:   Chase Dowdeswell           May 2014
//
////////////////////////////////////////////////////////////////////////////

//--------------------------- DCL ------------------------------

////////////////////////////////////////////////////////////////////////////

Sheet_Parameters : dialog 	{				//Dialog Name
	label = "Sheet Parameters" ;
	

	: row	{

	: column	{

	: boxed_radio_column 	{				//Define the column
		label = "Offset Top Right Corner" ;		//Name
		
			: radio_button	{
			key = "rb1" ; 
			label = "&Yes" ;
			value = "1" ;				//switch it on
					}
			: radio_button	{
			key = "rb2" ;
			label = "No" ;
					}		
				}				//End Boxed Radio Column

	: boxed_radio_column	{
		label = "Grid Lines" ;				//Name
			
			: radio_button	{
			key = "rb3" ;
			label = "&Yes" ;
					}
			: radio_button	{
			key = "rb4" ;
			label = "No" ;
					}	
				}				//End Boxed radio Column

	: boxed_radio_column	{
		label = "Lines or Ticks" ;			//Name
			
			: radio_button	{
			key = "rb5" ;
			label = "&Lines" ;
					}
			: radio_button	{
			key = "rb6" ;
			label = "Tick" ;
					}	
				}				//End Boxed radio Column
			
			}					//End Column

	: column 	{
	
	: boxed_radio_column	{
		label = "Sheet Units" ;
			
			: row	{
			
			: radio_button	{
			key = "rb7" ;
			label = "Metric" ;
					}
			: radio_button	{
			key = "rb8" ;
			label = "&Imperial" ;
			value = "1" ;
					}
				}				//End Row
				}				//End Boxed radio column

	: boxed_column 	{					//Start list
		label = "Sheet Type" ; 

		: popup_list	{
			key = "Selections" ; 			//Name
			value = "5" ;				//Initial Value
				}				//End List
			}					//End Boxed Column

	: edit_box {key = "eb1"; label = "Northing Spacing";	//Northing
			edit_width = 12; value = "000";}
	: edit_box {key = "eb2"; label = "Easting Spacing";	//Easting
			edit_width = 12; value = "000";}
	: edit_box {key = "eb3"; label = "Text Orientation";	//Text Orientation
			edit_width = 12; value = "00";}
	: edit_box {key = "eb4"; label = "Scale Factor (1000s)";//Scale Factor
			edit_width = 12; value = "0";}
			
			}					//End Column

		}						//End Row


	
	

	: image		{
			key = "im" ;				//Image name
			height = 1.0 ;				//Height
			width = 1.0 ;				//Wdith
			}					//End Image
	
	: paragraph 	{
			: text_part 	{			//End Text
			label = "Please Select All Sheet Parameters" ;
					}
			: text_part	{
			label = "By Chase Dowdeswell" ;
					}			//End Text
			}					//End Paragraph


								//End Row

	ok_cancel ;

}								//End Dialog

 

(defun c:Dialog ()


 (setq dcl_id (load_dialog "Sheet_Parameters.dcl"))

			;Load Dialog
 (if (not (new_dialog "Sheet_Parameters" dcl_id) )
 	(exit)
 );if


 (setq 	Dw (dimx_tile "im")					;get image tile width
	Hw (dimy_tile "im")					;get image tile height
 );setq


 (start_image "im")						;start the image
 (fill_image 0 0 Dw Hw 5)					;fill it with blue
 (end_image)							;end image


 (start_list "Selections")					;start the list_box
 (mapcar 'add_list SheetList)					;fill the list box
 (end_list)							;end list


 (mode_tile "rb5" 1)
 (mode_tile "rb6" 1)


 (action_tile "rb1" 	"(setq EvenOdd \"Yes\")")
 (action_tile "rb2" 	"(setq EvenOdd \"No\")")
 (action_tile "rb3" 	"(setq GRDYN \"Yes\")
			 (mode_tile \"rb5\" 0)
			 (mode_tile \"rb6\" 0)")
 (action_tile "rb4" 	"(setq GRDYN \"No\")
			 (mode_tile \"rb5\" 1)
			 (mode_tile \"rb6\" 1)")
 (action_tile "rb5" 	"(setq GRDTCK \"Lines\")")
 (action_tile "rb6" 	"(setq GRDTCK \"Tick\d")")	
 (action_tile "rb7" 	"(setq Units \"Metric\")")						
 (action_tile "rb8" 	"(setq Units \"Imperial\")")
 

  (setq Choice1 (atoi (get_tile "rb7")))  ; 0 = not chosen    1 = chosen   
  (setq choice2 (atoi (get_tile "rb8")))  ; 0 = not chosen    1 = chosen
  (if (= Choice1 1)
	(setq Units "Metric")
	(setq Units "Imperial")
  );if


 (if (= Units "Imperial")
 (progn
 (setq SheetType "ANSI_A_BASIC_LAND")
 	  (setq SheetList '("ANSI_A_BASIC_LAND" "ANSI_A_BASIC_LAND_STACK" "ANSI_A_BASIC_PORT" "ANSI_A_BASIC_PORT_STACK" "ANSI_A_BASIC_LAND_VERT" 
			"ANSI_B_BASIC_LAND" "ANSI_B_BASIC_LAND_STACK" "ANSI_B_BASIC_PORT" "ANSI_B_BASIC_PORT_STACK" "ANSI_B_BASIC_LAND_VERT" 
			"ANSI_C_BASIC_LAND" "ANSI_C_BASIC_LAND_STACK" "ANSI_C_BASIC_PORT" "ANSI_C_BASIC_PORT_STACK" "ANSI_C_BASIC_LAND_VERT" 
			"ANSI_D_BASIC_LAND" "ANSI_D_BASIC_LAND_STACK" "ANSI_D_BASIC_PORT" "ANSI_D_BASIC_PORT_STACK" "ANSI_D_BASIC_LAND_VERT" 
			"ANSI_E_BASIC_LAND" "ANSI_E_BASIC_LAND_STACK" "ANSI_E_BASIC_PORT" "ANSI_E_BASIC_PORT_STACK" "ANSI_E_BASIC_LAND_VERT")
 	  );setq
 );progn
 (progn
 (setq SheetType "A4_BASIC_LAND")
 	  (setq SheetList '("A4_BASIC_LAND" "A4_BASIC_LAND_STACK" "A4_BASIC_PORT" "A4_BASIC_PORT_STACK" "A4_BASIC_LAND_VERT" 
			"A3_BASIC_LAND" "A3_BASIC_LAND_STACK" "A3_BASIC_PORT" "A3_BASIC_PORT_STACK" "A3_BASIC_LAND_VERT" 
			"A2_BASIC_LAND" "A2_BASIC_LAND_STACK" "A2_BASIC_PORT" "A2_BASIC_PORT_STACK" "A2_BASIC_LAND_VERT" 
			"A1_BASIC_LAND" "A1_BASIC_LAND_STACK" "A1_BASIC_PORT" "A1_BASIC_PORT_STACK" "A1_BASIC_LAND_VERT" 
			"A0_BASIC_LAND" "A0_BASIC_LAND_STACK" "A0_BASIC_PORT" "A0_BASIC_PORT_STACK" "A0_BASIC_LAND_VERT")
 	  );setq
 );progn
 );if


 (start_list "Selections")					
 (mapcar 'add_list SheetList)					
 (end_list)


 (action_tile
	"cancel"						;If cancel button pressed
	"(done_dialog) (setq userclick nil)"			;Close dialog
 );action_tile


  (action_tile
	"accept"						;If cancel button pressed
	(strcat							;string list together
	 "(progn
	  (setq SHEETTYPE (atof (get_tile \"Selections\")))"	;get list selection
	 "(setq MajGridN (get_tile \"eb1\"))"			;Get Northing Spacing
	 "(setq MajGridE (get_tile \"eb2\"))"			;Get Easting Spacing
	 "(setq TextOr (get_tile \"eb3\"))"			;Get Text Orientation
	 "(setq SheetScale (get_tile \"eb4\"))"			;get Scale
	" (done_dialog) (setq userclick T))"			;Close dialog
  	);strcat
  );action_tile


 (start_dialog)							;start dialog



 (unload_dialog dcl_id)						;unload


 (if userclick							;check O.K. was selected
	(progn
	 (setq SHEETTYPE (fix SHEETTYPE))
	 (setq SHEETTYPE (nth SHEETTYPE SheetList))
	);progn
 );if


 (princ)


);defun

(princ)

 

8 REPLIES 8
Message 2 of 9
scot-65
in reply to: chasedowdeswell

Concentrate on these lines:

 

(action_tile "rb7" "(setq Units \"Metric\")")
(action_tile "rb8" "(setq Units \"Imperial\")")

 

Now look at the following for hints:

   ;*** ACTION TILE ***
   (action_tile "Rad101" "(RNLT_mode stn)")
   (action_tile "Rad102" "(RNLT_mode f1n)")

Where:

 (defun RNLT_mode ( a / )
  (start_list "Pop302")(mapcar 'add_list a)(end_list)
 );end RNLT_mode

And:

   (setq stn (list "ST""SG"))
   (setq f1n (list "F1""F2""F3""F4""F5""F6"))

 

I have attached a "template" file I use when beginning a DCL type project.

Look at it's architecture and see if you can structure your program the same way...

 

As a hint, gather all user input when "accept" is called, then go into the main program with this information.

I have slightly modified what you have as an example:

:radio_row {key="rb78";
 :radio_button {key="rb7"; label="Metric";}
 :radio_button {key="rb8"; label="&Imperial"; value = "1";}
}

Now, in the "GET" section, see what is rb78:

(get_tile "rb78")

You will find that it is either "rb7" or "rb8".

No need to setq in each action_tile.

 

Hope this helps.

 


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


Message 3 of 9
smaher12
in reply to: chasedowdeswell

Maybe this will help...

 

test : dialog {
	 label = "Sheet Parameters";

   spacer;       
    :column {
	: boxed_radio_row {
	  label = "Sheet Units";
	  key = "radrow";

	  : radio_button {
	    label = "&Metric";
	    key = "rb01";
	  }
	  : radio_button {
	    label = "&Imperial";
	    key = "rb02";
	  }
  	} // end boxed_radio_row

  spacer;
    :row {
	: boxed_column {
	  label = "Sheet Type";
	  width = 30;

        :  popup_list {
	  key = "sht_typ";
	}
	} // end boxed_column

    } // end row

    } // end column
    ok_cancel;
} // end test dialog

 

(defun c:test ()
  (setq dcl_id (load_dialog "test.dcl"))
  (if (not (new_dialog "test" dcl_id)) (exit))

  ;radio buttons
  (if radio_option
    (set_tile "radrow" radio_option)
    (set_tile "radrow" "rb01")
  )

  ;list_box
  (setq mylist (list "AA" "BB" "CC"))
  (cond
    ((= radio_option "rb01") (setq mylist (list "AA" "BB" "CC")))
    ((= radio_option "rb02") (setq mylist (list "XX" "YY" "ZZ")))
  )
  (start_list "sht_typ")
  (mapcar 'add_list mylist)
  (end_list)

  (action_tile "radrow" "(dcl_radio_01)")
  (setq test_dialog (start_dialog))
  (unload_dialog dcl_id)
)

;column radio
(defun dcl_radio_01 ()
  (setq radio_option $value)
  (cond
    ((= radio_option "rb01") (setq mylist (list "AA" "BB" "CC")))
    ((= radio_option "rb02") (setq mylist (list "XX" "YY" "ZZ")))
  )
  (start_list "sht_typ")
  (mapcar 'add_list mylist)
  (end_list)
)

 

 

Message 4 of 9
CSM_MAI
in reply to: smaher12

Smaher12, is there a way to attach a command to each of the list selections? i.e. Choosing "AA" runs the line command, and "BB" runs the circle command? Thanks

Message 5 of 9
scot-65
in reply to: CSM_MAI

I think you will want to add allow_accept for the tile.

For list_box and popup_list:
Get the tile's position (an integer that is a string: "2"),
close the dialog (commands not allowed while dialog is open),
subject the tile's value in a COND, and run the command.

???

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


Message 6 of 9
smaher12
in reply to: CSM_MAI

Give this a shot....

 

(defun c:test ()

 (initiate)
  (setq p1 (getpoint "\nSpecify point: "))

  (if (= radio_option "rb01")
    (cond
      ((= sht_typ "0") (command "_.line" p1 pause ""))
      ((= sht_typ "1") (command "_.circle" p1 pause ""))
    )
  )
  (if (= radio_option "rb02")
    (cond
      ((= sht_typ "0") (command "_.rectangle" p1 pause ""))
      ((= sht_typ "1") (command "_.donut" "0" "2" p1 ""))
    )
  )
 ); test

(defun initiate ()
  (setq dcl_id (load_dialog "test.dcl"))
    (if (not (new_dialog "test" dcl_id)) 
      (exit)
    )

  ;radio buttons defaults
  (if radio_option
    (set_tile "radrow" radio_option)
    (set_tile "radrow" "rb01")
  )

  ;list_box defaults
  (setq mylist (list "AA" "BB" "CC"))
  (cond
    ((= radio_option "rb01") (setq mylist (list "AA" "BB" "CC")))
    ((= radio_option "rb02") (setq mylist (list "XX" "YY" "ZZ")))
  )
  (start_list "sht_typ")
  (mapcar 'add_list mylist)
  (end_list)

  (set_tile "sht_typ" (if sht_typ sht_typ (setq sht_typ "0")))

  (action_tile "radrow" "(dcl_radio_01)")
  (action_tile "sht_typ" "(setq sht_typ $value)")
  (action_tile "accept" "(done_dialog)")
  (action_tile "cancel" "(exit)")
    (start_dialog)
      (unload_dialog dcl_id)
        (princ)
); initiate

;column radio
(defun dcl_radio_01 ()
  (setq radio_option $value)
  (cond
    ((= radio_option "rb01") (setq mylist (list "AA" "BB" "CC")))
    ((= radio_option "rb02") (setq mylist (list "XX" "YY" "ZZ")))
  )
  (start_list "sht_typ")
  (mapcar 'add_list mylist)
  (end_list)
)

 

Message 7 of 9
CSM_MAI
in reply to: smaher12

The lisp worked great. I did some modifications to it, and now when the dialog pops up, I have to choose a ratio button and then select an item from the drop down list. Even though it has a default value in there, if I click on, it returns nil. If I select the already selected ratio button, and then select an option from the pop-up list that is already selected, it will work. It's as though it doesn't recognize the default value for the list. Any ideas?  Thanks.

Message 8 of 9
scot-65
in reply to: CSM_MAI

Popup lists return a integer as a string - "2".
Sounds like the associated setq value of what represents "2" is not initialized.
???

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


Message 9 of 9
smaher12
in reply to: CSM_MAI

Replace the following in the code

 

;radio buttons defaults
(if radio_option
  (set_tile "radrow" radio_option)
  (set_tile "radrow" "rb01")
)

 

With this

 

;radio buttons defaults
(if (= radio_option nil)
  (setq radio_option "rb01")
)
(set_tile "radrow" radio_option)

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report

”Boost