Author Topic: DCL radiobutton alignment  (Read 21168 times)

0 Members and 1 Guest are viewing this topic.

ymg

  • Guest
Re: DCL radiobutton alignment
« Reply #15 on: January 03, 2014, 11:43:43 AM »
Try with this,

Code: [Select]
(defun c:tmplsp ()
     
  (if (not (setq dcl_id (load_dialog "testcluster.dcl")))
    (progn  (alert "The file could not be loaded.") (exit))
    (progn
      (if (not (new_dialog "tcluster" dcl_id))
        (progn
          (alert "The DCL definition could not be found inside the DCL file.")
          (exit)
        )
       
        (progn         
          (setq col0 '("eb0" "eb1" "eb2" "eb3")
                col1 '("eb10" "eb11" "eb12" "eb13")
                 zer '("0" "0" "0" "0")
          )     
          (defun togcol (button / rtn)
             (cond
                ((member button col1) (mapcar 'set_tile col0 zer))
                ((member button col0) (mapcar 'set_tile col1 zer))         
             )
             button
          )
          (action_tile "col0" "(setq choice (togcol (get_tile \"col0\")))")
          (action_tile "col1" "(setq choice (togcol (get_tile \"col1\")))") 
          (action_tile "accept" "(done_dialog 2)")
          (action_tile "cancel" "(done_dialog 1)")

          (setq ddiag (start_dialog))

          (unload_dialog dcl_id)

          (if (= ddiag 1) (princ "\n \n ...DCL_LSP Cancelled. \n "))
          (if (= ddiag 2)
             (cond
                 ((= choice  "eb0")  (setq PL_WEIGHT "0.56"     PL_UTILITY "Single Hung 1/2 in"))
                 ((= choice  "eb1")  (setq PL_WEIGHT "1.79"     PL_UTILITY "Single Hung 3/4 in"))
                 ((= choice  "eb2")  (setq PL_WEIGHT "2.67"     PL_UTILITY "Single Hung 1 in"))
                 ((= choice  "eb3")  (setq PL_WEIGHT "4.24"     PL_UTILITY "Single Hung 1-1/2 in"))
                 ((= choice  "eb10") (setq PL_WEIGHT "80.95"    PL_UTILITY "Single Hung 10 in"))
                 ((= choice  "eb11") (setq PL_WEIGHT "105.53"   PL_UTILITY "Single Hung 12 in"))
                 ((= choice  "eb12") (setq PL_WEIGHT "120.62"   PL_UTILITY "Single Hung 14 in"))
                 ((= choice  "eb13") (setq PL_WEIGHT "147.54"   PL_UTILITY "Single Hung 16 in"))
             )
          )
          (princ (strcat "\n You Selected: " pl_utility " , Weight: " pl_weight))

        )
      )
    )
  )
  (princ)
)

and the dcl:

Code: [Select]
tcluster : dialog { label = "2007 OPA - Mechancical Pipe - SCD 40  STD";     
           : row {   
                        : radio_column {
                             key = "col0";
                : radio_button {key = "eb0"; label = "1/2 in";  }
: radio_button {key = "eb1"; label = "3/4 in";  }
: radio_button {key = "eb2"; label = "1 in";    }
: radio_button {key = "eb3"; label = "1-1/2 in";}
}
: radio_column {
     key = "col1";
: radio_button {key = "eb10"; label = "10 in";   }
: radio_button {key = "eb11"; label = "12 in";   }
: radio_button {key = "eb12"; label = "14 in";   }
: radio_button {key = "eb13"; label = "16 in";   }
}
   }
   :boxed_row {
        ok_cancel;
   }     
         }

snownut2

  • Swamp Rat
  • Posts: 971
  • Bricscad 22 Ultimate
Re: DCL radiobutton alignment
« Reply #16 on: January 03, 2014, 03:19:06 PM »
Whats wrong with this, works in both ACAD & BricsCAD without issue.

Code - Auto/Visual Lisp: [Select]
  1.  
  2.     : boxed_row {
  3.       label = "Select Force Main Pipe Size " ;
  4.        : radio_row {
  5.          : column {
  6.            : radio_button {
  7.              label = "1-1/4in. Plastic Pipe";
  8.              key = "125pp";
  9.            }
  10.            : radio_button {
  11.              label = "1-1/2in. Plastic Pipe";
  12.              key = "150pp";
  13.            }
  14.          }
  15.          : column {
  16.            : radio_button {
  17.              label = "2in. Plastic Pipe";
  18.              key = "200pp";
  19.            }
  20.            : radio_button {
  21.              label = "2-1/2in. Plastic Pipe";
  22.              key = "250pp";
  23.            }
  24.          }
  25.          : column {
  26.            : radio_button {
  27.              label = "3in. Plastic Pipe";
  28.              key = "300pp";
  29.            }
  30.          }
  31.        }
  32.      }
  33.  

You can have as many columns as you like, no trick LISP function needed.  I will typically use the same variable for the action_tile on radio buttons,

ie;

(action_tile "125pp" "(setq pipesize 1.25)")
(action_tile "150pp" "(setq pipesize 1.50)")

Pretty straight forward.

Using this method it does not matter what the $value of the button is, the last radio button selected sets the pipesize variable.  Eliminates the need for a cond function later to sort out the values, you can select all the radio buttons and the last one wins.....

Bruce
« Last Edit: January 03, 2014, 03:41:35 PM by snownut2 »

ymg

  • Guest
Re: DCL radiobutton alignment
« Reply #17 on: January 03, 2014, 04:41:13 PM »
Snownut,

Do the button act as a single cluster ?

By that I mean say I select 2 in., then change my mind and select 3 in.
Does the 2in. button goes blank?

ymg

snownut2

  • Swamp Rat
  • Posts: 971
  • Bricscad 22 Ultimate
Re: DCL radiobutton alignment
« Reply #18 on: January 03, 2014, 04:47:42 PM »
Yes, they act as a cluster, only one radio button will display as selected.  The one thing you need to look out for is regarding BricsCAD, they have what I would call a bug in their Radio Button feature, when a Dialog box opens the 1st button of the cluster appears as if it has been selected.  The way I work around this is to (setq pipesize) to the value of the 1st button prior to starting the dialog.  That way if the user just accepts (what appears to be a default value) all is well.

ymg

  • Guest
Re: DCL radiobutton alignment
« Reply #19 on: January 03, 2014, 04:56:31 PM »
Bruce,

That would be good news, because every way I try I dont get it to act a single cluster.

ymg

ymg

  • Guest
Re: DCL radiobutton alignment
« Reply #20 on: January 03, 2014, 05:07:51 PM »
Bruce,

Does not work as a single cluster in Autocad.

ymg
« Last Edit: January 03, 2014, 05:18:01 PM by ymg »

snownut2

  • Swamp Rat
  • Posts: 971
  • Bricscad 22 Ultimate
Re: DCL radiobutton alignment
« Reply #21 on: January 03, 2014, 05:30:25 PM »
ymg,

I looked at my lsp code, it appears that I forced all other tiles to "0" ie (set_tile... "0")following the (setq....) on the (action_tile ) line.  I know this is not what you where looking for, but it is not impossible to do (make it appear that the other radio buttons are non-selected)

(action_tile "125pp" "(setq pipesize 1.25)(set_tile \"150pp\" \"0\")(set_tile \"200pp\" \"0\")(set_tile \"250pp\" \"0\")(set_tile \"300pp\" \"0\")")

Additionally it is still substantially quicker then creating multiple lines of code to accomplish the same task.

Sorry for the bum information.

Bruce
« Last Edit: January 03, 2014, 05:36:18 PM by snownut2 »

ymg

  • Guest
Re: DCL radiobutton alignment
« Reply #22 on: January 03, 2014, 05:57:53 PM »
Bruce,

This is essentially the same method except that I go through a small routine to reset the button
and I divided them in column.

I do not think that there is any way around toggling the radio button through Lisp.

ymg

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
Re: DCL radiobutton alignment
« Reply #23 on: January 03, 2014, 06:18:42 PM »
My take:
Code: [Select]
(defun c:tmplsp (/ choice)
  (defun ClearCol1() (mapcar '(lambda(x) (set_tile x "0")) '("eb10""eb11""eb12""eb13")))
  (defun ClearCol0() (mapcar '(lambda(x) (set_tile x "0")) '("eb0""eb1""eb2""eb3")))
  (if (not (setq dcl_id (load_dialog "testcluster.dcl")))
    (progn  (alert "The file could not be loaded.") (exit))
    (progn
      (if (not (new_dialog "tcluster" dcl_id))
        (alert "The DCL definition could not be found inside the DCL file.")
       
        (progn         
          (action_tile "col0" "(setq choice $value)(clearCol1)")
          (action_tile "col1" "(setq choice $value)(clearCol0)")
          (action_tile "accept" "(done_dialog 2)")
          (action_tile "cancel" "(done_dialog 1)")

          (setq ddiag (start_dialog))

          (unload_dialog dcl_id)

          (cond
            ((= ddiag 1) (princ "\n \n ...DCL_LSP Cancelled. \n "))
            ((/= ddiag 2)(princ "\n \n ...DCL_LSP Cancelled. \n "))
           
                 ((= choice  "eb0")  (setq PL_WEIGHT "0.56"     PL_UTILITY "Single Hung 1/2 in"))
                 ((= choice  "eb1")  (setq PL_WEIGHT "1.79"     PL_UTILITY "Single Hung 3/4 in"))
                 ((= choice  "eb2")  (setq PL_WEIGHT "2.67"     PL_UTILITY "Single Hung 1 in"))
                 ((= choice  "eb3")  (setq PL_WEIGHT "4.24"     PL_UTILITY "Single Hung 1-1/2 in"))
                 ((= choice  "eb10") (setq PL_WEIGHT "80.95"    PL_UTILITY "Single Hung 10 in"))
                 ((= choice  "eb11") (setq PL_WEIGHT "105.53"   PL_UTILITY "Single Hung 12 in"))
                 ((= choice  "eb12") (setq PL_WEIGHT "120.62"   PL_UTILITY "Single Hung 14 in"))
                 ((= choice  "eb13") (setq PL_WEIGHT "147.54"   PL_UTILITY "Single Hung 16 in"))
             )
          (if choice (princ (strcat "\n You Selected: " pl_utility " , Weight: " pl_weight)))

        )
      )
    )
  )
  (princ)
)
Code: [Select]
tcluster : dialog { label = "2007 OPA - Mechancical Pipe - SCD 40  STD";     
                  : row {   
                        : radio_column { key = "col0";
                        : radio_button {key = "eb0"; label = "1/2 in";  }
                : radio_button {key = "eb1"; label = "3/4 in";  }
                : radio_button {key = "eb2"; label = "1 in";    }
                : radio_button {key = "eb3"; label = "1-1/2 in";}
                }
                        : radio_column { key = "col1";
                : radio_button {key = "eb10"; label = "10 in";   }
                : radio_button {key = "eb11"; label = "12 in";   }
                : radio_button {key = "eb12"; label = "14 in";   }
                : radio_button {key = "eb13"; label = "16 in";   }
                }
           }
           :boxed_row {
                ok_cancel;
           }     
         }
I've reached the age where the happy hour is a nap. (°¿°)
Windows 10 core i7 4790k 4Ghz 32GB GTX 970
Please support this web site.

ymg

  • Guest
Re: DCL radiobutton alignment
« Reply #24 on: January 03, 2014, 07:57:12 PM »
CAB,

This is cleaner and thus clearer.

But we still need to toggle the radio button.

I've tried with the radio_clusters describe by Keith but to no avail.

ymg

snownut2

  • Swamp Rat
  • Posts: 971
  • Bricscad 22 Ultimate
Re: DCL radiobutton alignment
« Reply #25 on: January 03, 2014, 08:17:54 PM »
The "clearcol.." functions clear all radio buttons..

how about this..

Code - Auto/Visual Lisp: [Select]
  1. (action_tile "col0" "(setq choice $value)(clearCol1)(set_tile choice \"1\")")
  2.  

Haven't tried it.


ymg

  • Guest
Re: DCL radiobutton alignment
« Reply #26 on: January 04, 2014, 02:28:47 AM »
Bruce,

Code: [Select]
(defun clrbut (choice)
     (setq cluster '("eb0" "eb1" "eb2" "eb3" "eb10" "eb11" "eb12" "eb13"))           
     (mapcar '(lambda(x) (set_tile x "0")) cluster)
     (set_tile choice "1")
)         
(action_tile "col0" "(clrbut (setq choice $value))")
(action_tile "col1" "(clrbut (setq choice $value))") 

Would work!

snownut2

  • Swamp Rat
  • Posts: 971
  • Bricscad 22 Ultimate
Re: DCL radiobutton alignment
« Reply #27 on: January 04, 2014, 08:14:18 AM »
ymg,

Good to hear, it is also interesting how "key" for the columns works.  I had read some time ago that you could assign a "key" to columns & rows but until now I wasn't sure how to apply it. 

This code seems about as concise as it can be, just need to localize the "cluster" variable in the clrbut function, or it could be eliminated altogether by replacing the cluster variable in the mapcar line with the actual list.

Bruce

hmspe

  • Bull Frog
  • Posts: 362
Re: DCL radiobutton alignment
« Reply #28 on: January 04, 2014, 10:08:27 AM »
I don't know if this will add anything to the discussion, but attached is a function I put together several years ago that uses a multi-column radio box and which calculates available fault current for electrical circuits.  If you select more than one set of conductors in the dialog it deactivates one column in the multi-column radio box.  If you select a point in open space in the drawing as the first step you will need to enter enter all required values for the OK button to be enabled.  If you click on the "F1" of an existing calculation it will fill the boxes from the data in the existing calculation.  I checked this in Bricscad 14.

I have converted this to OpenDCL so I no longer use this version.  OpenDCL provides much better formatting capability.
"Science is the belief in the ignorance of experts." - Richard Feynman

ymg

  • Guest
Re: DCL radiobutton alignment
« Reply #29 on: January 04, 2014, 11:30:54 AM »
Yet another,

Code: [Select]
(defun clrbut (col / but cluster)
       (setq cluster '("col0" "col1"))           
       (foreach cl (vl-remove col cluster)
            (if (setq but (get_tile cl))(set_tile but "0"))             
      )

(action_tile "col0" "(setq choice $value)(clrbut \"col0\")")
(action_tile "col1" "(setq choice $value)(clrbut \"col1\")")