OpenDCL Forums

OpenDCL => Runtime/AutoLISP => Topic started by: william17051 on March 17, 2009, 09:24:19 AM

Title: Checkbox value change
Post by: william17051 on March 17, 2009, 09:24:19 AM
Hello again,
I am trying to get my check boxes to work now and I am getting a "nil value not allowed" when using a getValue command.
I have 4 checkboxes in which 3 are set to 0-unchecked and one is set to 1-checked.
When using an onclicked function I want the one picked to be set to 1 and the others to 0.

Code (autolisp) Select
(defun c:BillsShopDrawing_form1_CheckBox2_OnClicked (Value /)
 (if (= 1 (dcl_Control_GetValue BillsShopDrawing_form1_CheckBox3))(dcl_Control_SetValue BillsShopDrawing_form1_CheckBox3 0))
 (if (= 1 (dcl_Control_GetValue BillsShopDrawing_form1_CheckBox4))(dcl_Control_SetValue BillsShopDrawing_form1_CheckBox4 0))
 (if (= 1 (dcl_Control_GetValue BillsShopDrawing_form1_CheckBox1))(dcl_Control_SetValue BillsShopDrawing_form1_CheckBox1 0))
 (dcl_Control_SetValue BillsShopDrawing_form1_CheckBox2 1)
 (dcl_Control_Redraw BillsShopDrawing_form1_CheckBox1)
 (dcl_Control_Redraw BillsShopDrawing_form1_CheckBox2)
 (dcl_Control_Redraw BillsShopDrawing_form1_CheckBox3)
 (dcl_Control_Redraw BillsShopDrawing_form1_CheckBox4)
 )
(defun c:BillsShopDrawing_form1_CheckBox3_OnClicked (Value /)
 (if (= 1 (dcl_Control_GetValue BillsShopDrawing_form1_CheckBox2))(dcl_Control_SetValue BillsShopDrawing_form1_CheckBox2 0))  
 (if (= 1 (dcl_Control_GetValue BillsShopDrawing_form1_CheckBox4))(dcl_Control_SetValue BillsShopDrawing_form1_CheckBox4 0))
 (if (= 1 (dcl_Control_GetValue BillsShopDrawing_form1_CheckBox1))(dcl_Control_SetValue BillsShopDrawing_form1_CheckBox1 0))
 (dcl_Control_SetValue BillsShopDrawing_form1_CheckBox3 1)
 (dcl_Control_Redraw BillsShopDrawing_form1_CheckBox1)
 (dcl_Control_Redraw BillsShopDrawing_form1_CheckBox2)
 (dcl_Control_Redraw BillsShopDrawing_form1_CheckBox3)
 (dcl_Control_Redraw BillsShopDrawing_form1_CheckBox4)
)
(defun c:BillsShopDrawing_form1_CheckBox4_OnClicked (Value /)
 (if (= 1 (dcl_Control_GetValue BillsShopDrawing_form1_CheckBox3))(dcl_Control_SetValue BillsShopDrawing_form1_CheckBox3 0))  
 (if (= 1 (dcl_Control_GetValue BillsShopDrawing_form1_CheckBox2))(dcl_Control_SetValue BillsShopDrawing_form1_CheckBox2 0))
 (if (= 1 (dcl_Control_GetValue BillsShopDrawing_form1_CheckBox1))(dcl_Control_SetValue BillsShopDrawing_form1_CheckBox1 0))
 (dcl_Control_SetValue BillsShopDrawing_form1_CheckBox4 1)
 (dcl_Control_Redraw BillsShopDrawing_form1_CheckBox1)
 (dcl_Control_Redraw BillsShopDrawing_form1_CheckBox2)
 (dcl_Control_Redraw BillsShopDrawing_form1_CheckBox3)
 (dcl_Control_Redraw BillsShopDrawing_form1_CheckBox4)
)
(defun c:BillsShopDrawing_form1_CheckBox1_OnClicked (Value /)
 (if (= 1 (dcl_Control_GetValue BillsShopDrawing_form1_CheckBox3))(dcl_Control_SetValue BillsShopDrawing_form1_CheckBox3 0))
 (if (= 1 (dcl_Control_GetValue BillsShopDrawing_form1_CheckBox4))(dcl_Control_SetValue BillsShopDrawing_form1_CheckBox4 0))
 (if (= 1 (dcl_Control_GetValue BillsShopDrawing_form1_CheckBox2))(dcl_Control_SetValue BillsShopDrawing_form1_CheckBox2 0))
 (dcl_Control_SetValue BillsShopDrawing_form1_CheckBox1 1)
 (dcl_Control_Redraw BillsShopDrawing_form1_CheckBox1)
 (dcl_Control_Redraw BillsShopDrawing_form1_CheckBox2)
 (dcl_Control_Redraw BillsShopDrawing_form1_CheckBox3)
 (dcl_Control_Redraw BillsShopDrawing_form1_CheckBox4)
)


I thought this would work, but it gives me an error and does not redraw the checkboxes with the new value.

Thanks for any input,
Bill
Title: Re: Checkbox value change
Post by: owenwengerd on March 17, 2009, 09:45:20 AM
I think you should scrap the checkboxes and use option buttons (or an option list) instead, as this is exactly what those are designed for.
Title: Re: Checkbox value change
Post by: william17051 on March 17, 2009, 10:20:45 AM
OK, I'll try that instead. :)
Thanks
Title: Re: Checkbox value change
Post by: william17051 on March 17, 2009, 11:24:59 AM
OK, the option button works great in the form for what i needed.
I am still getting an error when trying to use the Value of each button.
The GetValue statement gives me an error saying that nil value not allowed-argument 0. :(

Code (autolisp) Select
(setq doorfront(dcl_Control_GetValue BillsShopDrawing_form1_OptionButton3))
  (setq doorback(dcl_Control_GetValue BillsShopDrawing_form1_OptionButton1))
  (setq doorright(dcl_Control_GetValue BillsShopDrawing_form1_OptionButton2))
  (setq doorleft(dcl_Control_GetValue BillsShopDrawing_form1_OptionButton4))
  (cond
    ((= 1 doorfront)
     (setq doorpt1(list(+(car pt4)(/(-(car pt4)(car pt3))2))(+(cadr pt4)4)(caddr pt4)))
     (command "insert" "c:\\bills blocks\\MACHINING STANDARD LAYOUT BLOCKS\\STANDARD MAN DOOR LEFT HINGE.dwg" doorpt1 1 1 0)
     )
    ((= 1 doorright)
     (setq doorpt1(list(-(car pt3)4)(+(car pt4)(/(-(cadr pt3)(cadr pt4))2))(caddr pt4)))
     (command "insert" "c:\\bills blocks\\MACHINING STANDARD LAYOUT BLOCKS\\STANDARD MAN DOOR LEFT HINGE.dwg" doorpt1 1 1 90)
     )
    ((= 1 doorleft)
     (setq doorpt1(list(+(car pt4)4)(+(car pt4)(/(-(cadr pt1)(cadr pt4))2))(caddr pt4)))
     (command "insert" "c:\\bills blocks\\MACHINING STANDARD LAYOUT BLOCKS\\STANDARD MAN DOOR LEFT HINGE.dwg" doorpt1 1 1 270)
     )
    ((= 1 doorback)
     (setq doorpt1(list(+(car pt1)(/(-(car pt2)(car pt1))2))(-(cadr pt1)4)(caddr pt1)))
     (command "insert" "c:\\bills blocks\\MACHINING STANDARD LAYOUT BLOCKS\\STANDARD MAN DOOR LEFT HINGE.dwg" doorpt1 1 1 180)
     )
    );end cond


Please help once again,
Bill
Title: Re: Checkbox value change
Post by: owenwengerd on March 17, 2009, 11:47:27 AM
The symbol names look correct, so I'll bet you're calling these functions after the dialog has been closed. Put that code inside your c:BillsShopDrawing_form1_GraphicButton1_OnClicked event handler before the call to (dcl_form_close), and it should work.
Title: Re: Checkbox value change
Post by: william17051 on March 17, 2009, 11:58:21 AM
Yep! That did it!
So the form values can only be set while it is open and are not accessible when closed?
Thanks a lot ;D
Bill