Code Red > AutoLISP (Vanilla / Visual)

multiple radio buttons working together?

<< < (2/8) > >>

roy_043:
Here is how I would approach this:


--- Code - Auto/Visual Lisp: ---(defun c:Samp4 (  / N_ActionAccept N_ActionCancel N_SetImage N_SetValues dcl_id fnm ret)   (defun N_ActionAccept ()    (setq fnm      (strcat        (substr (get_tile "flange") 5) ; "flange" is key of radio column, get_tile returns key of selected radio button.        "_"        (substr (get_tile "face") 5)        "_"        (get_tile "schedule")        "_"        "#"        (substr (get_tile "class") 5)        "_"        ".dim"      )    )    (done_dialog 1)  )   (defun N_ActionCancel ()    (done_dialog 0)  )   (defun N_SetImage ()    (start_image "img")    (fill_image 0 0 (dimx_tile "img") (dimy_tile "img") 5) ; fill image with blue.    (end_image)  )   (defun N_SetValues ()            ; sets default values.    (set_tile "flange"   "fla_sw") ; "flange" is key of radio column, "fla_sw" is key of radio button.    (set_tile "face"     "fac_ff")    (set_tile "schedule" "sch_20")    (set_tile "class"    "cla_150")  )   (if    (and      (< 0 (setq dcl_id (load_dialog "samp4.dcl")))      (new_dialog "samp4" dcl_id)    )    (progn      (N_SetImage)      (N_SetValues)      (action_tile "accept" "(N_ActionAccept)")      (action_tile "cancel" "(N_ActionCancel)")      (setq ret (start_dialog)) ; ret will receive done_dialog value.      (unload_dialog dcl_id)    )  )  (if (= 1 ret)    (progn      (princ "\nUser has pressed OK. ")      (princ (strcat "\nFilename = " fnm " "))      ; etc.    )    (progn      (princ "\nUser cancelled. ")    )  )  (princ)) 

--- Code: ---samp4 : dialog {
  label = "Structural Holes";
  : row {
    : radio_column {
      key = "flange";
      label = "Flange";
      : radio_button {key = "fla_wn";  label = "Welding Neck";}
      : radio_button {key = "fla_sw";  label = "Socket Weld";}
      : radio_button {key = "fla_so";  label = "Slip-on";}
      : radio_button {key = "fla_scr"; label = "Screwed";}
      : radio_button {key = "fla_bl";  label = "Blind";}
    }
    : boxed_radio_column {
      key = "face";
      label = "Face";
      : radio_button {key = "fac_rjt"; label = "RTJ";}
      : radio_button {key = "fac_rf";  label = "RF";}
      : radio_button {key = "fac_ff";  label = "Flat Face";}
    }
    : boxed_radio_column {
      key = "schedule";
      label = "Schedule";
      : radio_button {key = "sch_5";  label = "5";}
      : radio_button {key = "sch_10"; label = "10";}
      : radio_button {key = "sch_20"; label = "20";}
      : radio_button {key = "sch_30"; label = "30";}
      : radio_button {key = "sch_40"; label = "40";}
    }
    : boxed_radio_column {
      key = "class";
      label = "Class";
      : radio_button {key = "cla_150"; label = "150";}
      : radio_button {key = "cla_300"; label = "300";}
      : radio_button {key = "cla_400"; label = "400";}
      : radio_button {key = "cla_600"; label = "600";}
      : radio_button {key = "cla_900"; label = "900";}
    }
  }
  ok_cancel;
  : row {
    : image {key = "img"; aspect_ratio = 1.0; fixed_height = true; fixed_width = true; height = 2.0;}
    : paragraph {
      : text_part {value = "Designed and Created by Kenny Ramage";}
      : text_part {value = "Revised and updated by Roy_043";}
    }
  }
}

--- End code ---

sln8458:
Hi All and thanks for the replies.

@DEVITG.
I do this for the challenge, not to make my working life simpler. However that may be a consequence of my actions.  :2funny:
As for re-inventing the wheel, been there & done that. I use these people now www.traceparts.com
For info, my first contact with a supplier for CAD files was in 1986,  :rip:

@ROY_043
Thanks for your help
I found reference to a 'radio_cluster' here -> https://www.theswamp.org/index.php?topic=50977.0 <-
but could not find any further info, I forget who posted it.

I see in your lisp that you have used (done_dialog 0) for the Cancel button and (done_dialog 1) for the OK button.
Can you explain the reasoning  behind this please, to help the novice - me  :uglystupid2:

Oh, I found where I went wrong with my attempt,  I had misplaced this statement  (setq fname (strcat flg face sch class ".dim"))

My next 'test' is to pass the concatenated file name into this:

--- Code: ---  ;Find and open data file, *.dim
(defun OPEN_DIM_FILE ()
  (if (= NEWTILE "wnrf")
    (setq DIM_FILE (open (findfile "wnrf.dim") "r"))
  ) ;_ end of if
 ) ;end OPEN_DIM_FILE
--- End code ---

atm, (wnrf) is a key in my dcl

I received a tender request yesterday, and as I've had no work since April I need to spend time with that so I will be 'awol' for a while.

roy_043:

--- Quote from: sln8458 on August 11, 2020, 04:10:39 AM ---I see in your lisp that you have used (done_dialog 0) for the Cancel button and (done_dialog 1) for the OK button.
Can you explain the reasoning  behind this please

--- End quote ---
See this line in the code:

--- Code - Auto/Visual Lisp: ---(setq ret (start_dialog)) ; ret will receive done_dialog value.

Dape:
I see you mentioned PARTcommunity (PARTcloud) where you downloaded 3D models/parts.
They have new 3D portal called 3DfindIT.com, also free download (no your own upload, only download), excellent search engine, because you can find wanted models by shape, drawing, color, term, etc.
Here it is, maybe you can find more models you need there:

https://www.3dfindit.com/

sln8458:
I have tried to incorporate  roy_43 suggestion, which I prefer to my original code. However I am struggling a bit.

I've attached the dcl & lsp files.

After selecting each of the 4 options, when I press the OK button I get this:-
Filename = __0_#_.dim "

When I'm expecting this:-
Filename = wn_rtj_sch_20_#300.dim

some of this code appears to work as I'm getting these "_"   "#"  ".dim" but none of the (get_tile) values. Oh and a rouge '0'

--- Code: ---(setq fnm
      (strcat
        (substr (get_tile "flange") 5) ; "flange" is key of radio column, get_tile returns key of selected radio button.
        "_"
        (substr (get_tile "face") 5)
        "_"
         (get_tile "schedule")
        "_"
        "#"
        (substr (get_tile "class") 5)
        "_"
        ".dim"
      )
    ); end setq
--- End code ---

Can anyone see where I'm going wrong please?

Steve

Navigation

[0] Message Index

[#] Next page

[*] Previous page

Go to full version