Author Topic: multiple radio buttons working together?  (Read 7516 times)

0 Members and 2 Guests are viewing this topic.

sln8458

  • Newt
  • Posts: 91
  • CMS Intellicad 9.0/10.0
multiple radio buttons working together?
« on: August 04, 2020, 08:52:49 AM »
I have started a new project.

A DCL/LSP to insert 3D piping components. sorry for the poor image quality.


Following the same general direction as my previous post, in that I have a 'dim' text file that contains the list box info, the file name of the drawing to be inserted, followed by the values for the dimensions.

Concentrating on the flanges,
there is the box for selecting the flange 'type'
then radio buttons for RF or RJF
then 'schedule' and finally 'class'

example: WN + RF + sch60 + #300 = dim file.

All of these are required before selecting the specific flange size followed by OK
That will mean
5 options for type
2 options for face
10 options for schedule
7 options for class
total 700 permutations, if my maths is correct?  which also means 700 'dim' files! (the easy bit for me)

Before I attempt any further code, what is the simplest way to achieve the end result?

Steve
There is no such  thing as a 'silly question' to those who do not know!

Lee Mac

  • Seagull
  • Posts: 12912
  • London, England
Re: multiple radio buttons working together?
« Reply #1 on: August 05, 2020, 02:09:53 PM »
sorry for the poor image quality.

I would suggest using a lossless compression format such as PNG when taking screenshots, rather than lossy compression formats such as JPG which are more suited to photographs.

sln8458

  • Newt
  • Posts: 91
  • CMS Intellicad 9.0/10.0
Re: multiple radio buttons working together?
« Reply #2 on: August 07, 2020, 04:40:55 AM »
I scanned the internet for help on this and the nearest I came to was here
https://www.afralisp.net/dialog-control-language/tutorials/dialog-boxes-and-autolisp-part-2.php

I downloaded the code and set about modifying to trial some code.

This is what I have,




For each column I have set a variable.
I have then concatenated the results for each variable.

The goal for this section of the dialogue is to set the file name that will be loaded to fill the list box in the full dialogue.

I have set a (princ fname) to display the concatenation results.
The code appears to work,BUT
on the command line the concatenation appears to be one selection behind??

See attached files

Is it me?
Steve
« Last Edit: August 07, 2020, 08:12:48 AM by sln8458 »
There is no such  thing as a 'silly question' to those who do not know!

DEVITG

  • Bull Frog
  • Posts: 479
Re: multiple radio buttons working together?
« Reply #3 on: August 07, 2020, 07:02:00 PM »
Once upon a time , about 2005 , I had asked to do all "allen" screw , cylindrical head the user can find at his vendor. 
There was no nothing at the web .
So I ask him to ask his vendor for all his each unit at stock .

Get the ISO standard , we use millimeters, and suit a csv file , from xls with all the relative measures .

With such csv I did a lisp to draw , each screw, in 3d , and to be a block inside the dwg . Them by design center CTRL+2 , then user chose what he wants and insert it at is dwg .

So as flanges are one and unique for each use , there is no need to draw it each time.

Of course by this day you can have anything from vendors websites. Or from CADENAS cad dwgs or

https://b2b.partcommunity.com/community/members/home

No dialog box no typing error.   


The concept is the same the piping constructor will do for a work to do , get what he need with no error, the self.
 

And last but not least

DO NOT REINVENT THE WHEEL




Location @ Córdoba Argentina Using ACAD 2019  at Window 10

BIGAL

  • Swamp Rat
  • Posts: 1407
  • 40 + years of using Autocad
Re: multiple radio buttons working together?
« Reply #4 on: August 08, 2020, 01:10:58 AM »
Dynamic blocks are the way to go for bolts and screws etc.
A man who never made a mistake never made anything

roy_043

  • Water Moccasin
  • Posts: 1895
  • BricsCAD 18
Re: multiple radio buttons working together?
« Reply #5 on: August 08, 2020, 06:48:05 AM »
Here is how I would approach this:

Code - Auto/Visual Lisp: [Select]
  1. (defun c:Samp4 (  / N_ActionAccept N_ActionCancel N_SetImage N_SetValues dcl_id fnm ret)
  2.  
  3.   (defun N_ActionAccept ()
  4.     (setq fnm
  5.       (strcat
  6.         (substr (get_tile "flange") 5) ; "flange" is key of radio column, get_tile returns key of selected radio button.
  7.         "_"
  8.         (substr (get_tile "face") 5)
  9.         "_"
  10.         (get_tile "schedule")
  11.         "_"
  12.         "#"
  13.         (substr (get_tile "class") 5)
  14.         "_"
  15.         ".dim"
  16.       )
  17.     )
  18.     (done_dialog 1)
  19.   )
  20.  
  21.   (defun N_ActionCancel ()
  22.     (done_dialog 0)
  23.   )
  24.  
  25.   (defun N_SetImage ()
  26.     (start_image "img")
  27.     (fill_image 0 0 (dimx_tile "img") (dimy_tile "img") 5) ; fill image with blue.
  28.     (end_image)
  29.   )
  30.  
  31.   (defun N_SetValues ()            ; sets default values.
  32.     (set_tile "flange"   "fla_sw") ; "flange" is key of radio column, "fla_sw" is key of radio button.
  33.     (set_tile "face"     "fac_ff")
  34.     (set_tile "schedule" "sch_20")
  35.     (set_tile "class"    "cla_150")
  36.   )
  37.  
  38.   (if
  39.     (and
  40.       (< 0 (setq dcl_id (load_dialog "samp4.dcl")))
  41.       (new_dialog "samp4" dcl_id)
  42.     )
  43.     (progn
  44.       (N_SetImage)
  45.       (N_SetValues)
  46.       (action_tile "accept" "(N_ActionAccept)")
  47.       (action_tile "cancel" "(N_ActionCancel)")
  48.       (setq ret (start_dialog)) ; ret will receive done_dialog value.
  49.       (unload_dialog dcl_id)
  50.     )
  51.   )
  52.   (if (= 1 ret)
  53.     (progn
  54.       (princ "\nUser has pressed OK. ")
  55.       (princ (strcat "\nFilename = " fnm " "))
  56.       ; etc.
  57.     )
  58.     (progn
  59.       (princ "\nUser cancelled. ")
  60.     )
  61.   )
  62.   (princ)
  63. )
  64.  

Code: [Select]
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";}
    }
  }
}

sln8458

  • Newt
  • Posts: 91
  • CMS Intellicad 9.0/10.0
Re: multiple radio buttons working together?
« Reply #6 on: August 11, 2020, 04:10:39 AM »
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: [Select]
  ;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

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.
There is no such  thing as a 'silly question' to those who do not know!

roy_043

  • Water Moccasin
  • Posts: 1895
  • BricsCAD 18
Re: multiple radio buttons working together?
« Reply #7 on: August 11, 2020, 04:18:15 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
See this line in the code:
Code - Auto/Visual Lisp: [Select]
  1. (setq ret (start_dialog)) ; ret will receive done_dialog value.

Dape

  • Mosquito
  • Posts: 3
Re: multiple radio buttons working together?
« Reply #8 on: August 31, 2020, 03:43:16 AM »
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

  • Newt
  • Posts: 91
  • CMS Intellicad 9.0/10.0
Re: multiple radio buttons working together?
« Reply #9 on: September 01, 2020, 11:15:17 AM »
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: [Select]
(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

Can anyone see where I'm going wrong please?

Steve
There is no such  thing as a 'silly question' to those who do not know!

sln8458

  • Newt
  • Posts: 91
  • CMS Intellicad 9.0/10.0
Re: multiple radio buttons working together?
« Reply #10 on: September 03, 2020, 10:10:13 AM »
Well, I have moved on with other areas of the project.

But now I would like forum members thoughts please.

Which option do you think is better?
With the image on the left, both LH columns are selectable, and once an initial selection has been made only the relevant remaining options are available.
Whereas with the RH image you are forced to make an initial selection to gain access to the relevant options for your selection.
Does that even make sense?? :thinking:



S.
There is no such  thing as a 'silly question' to those who do not know!

roy_043

  • Water Moccasin
  • Posts: 1895
  • BricsCAD 18
Re: multiple radio buttons working together?
« Reply #11 on: September 03, 2020, 10:16:55 AM »
Let's also look at a different issue:
In the Fittings and Flanges column, and also in the Select column, you are using buttons, when it would be more logical to use radios.

sln8458

  • Newt
  • Posts: 91
  • CMS Intellicad 9.0/10.0
Re: multiple radio buttons working together?
« Reply #12 on: September 03, 2020, 10:22:32 AM »
Thanks Roy,

That is purely cosmetic really, also easily changed, but YES any comments appreciated.

S.
There is no such  thing as a 'silly question' to those who do not know!

sln8458

  • Newt
  • Posts: 91
  • CMS Intellicad 9.0/10.0
Re: multiple radio buttons working together?
« Reply #13 on: September 03, 2020, 12:17:43 PM »
Following Roys comments:



S.
There is no such  thing as a 'silly question' to those who do not know!

sln8458

  • Newt
  • Posts: 91
  • CMS Intellicad 9.0/10.0
Re: multiple radio buttons working together?
« Reply #14 on: September 04, 2020, 11:49:48 AM »
This is how the dialogue currently stands,

Any comments appreciated.

One question regarding the DCL, how can I evenly space the buttons in the FACE column?



But now onto the part I've been putting off, using the contents of my variable 'fname' to populate the list box

S.
There is no such  thing as a 'silly question' to those who do not know!