Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

ListBox with multiple parameters 2

Status
Not open for further replies.

dansuciu

Structural
Jun 26, 2015
4
0
0
RO
Hi there,
I am trying to optimize my work as a structural engineer, and create a file that has reduced input on my behalf.
I am currently looking for a solution to the following problem :
-I want to select the concrete class used (figured using a listbox ) ex: C12/15 , C16/20 , C20/25 etc
-class parameters should change based on selection.

Problem there are 14 parameters i need to include, and the listbox only allows for 1.

I was thinking of defining them in another mathcad file as vectors, and calling them out based on selection.

Is there any way i can do this?I'm using Mathcad 14.
Any suggestions would be greatly appreciated.I'm not that good at programming.

Thank you.
Best regards,
Dan
 
Replies continue below

Recommended for you

?? Which version of MC? MC15's listbox is VBscript, which you edit to add entries. The default entries are "One", "Two", and "Three"

TTFN
faq731-376
7ofakss

Need help writing a question or understanding a reply? forum1529


Of course I can. I can do anything. I can do absolutely anything. I'm an expert!
There is a homework forum hosted by engineering.com:
 
I think you should be able to add items to the listbox in M14. Right-click on the listbox, choose Edit Script from the various options. At the top of the code, as IRStuff says, you should see a few lines of VBScript along the lines of:

Rem Add Strings here as needed
ListBox.AddString("One")
ListBox.AddString("Two")

Just copy and paste one (or both) of the ListBox.AddString("xxx") lines as many times as you want and replace "One" and "Two" with what you want.

It's also possible to modify the code the read in a vector of strings from the Mathcad worksheet, but that takes a little more effort and the above should do what you want.
 
From what I recall, as already indicated, you can add as many as 256 items to the List. But is that really what you wanted? I may be wrong, reading your post I got the impression that you wanted for every input an output of up to 14 parameters.
 
Occupant said:
From what I recall, as already indicated, you can add as many as 256 items to the List. But is that really what you wanted? I may be wrong, reading your post I got the impression that you wanted for every input an output of up to 14 parameters.

If that's the case (and it makes sense upon a re-reading of the question) and the 14-parameter set is uniquely defined by the (one of < 256) concrete class, then there are several ways to skin the cat.

One way is to define the characteristics inside the listbox (script) as an array (or 14 separate arrays). The listbox index could then choose the appropriate set of parameters corresponding to the concrete class and return them as a vector. The listbox could be exported as a component, which would give the advantage of being updateable for every worksheet that used it.

Another way would be to just return concrete class index and, as the OP suggested, use that to index the parameter arrays in the worksheet. There are several ways to get the values into the worksheet without using up large amounts of visible worksheet in the process, eg:

a. Put all of the arrays in an Area and collapse it to hide the definitions. Has the advantage of encapsulating the parameters within the worksheet so that its provenance is readily established. The cloud in the silver lining is that, should the parameter values change, the values would need updating in each worksheet that had them ... not too bad for a couple of sheets but a right pain for many sheets and a possible configuration issue - although one way round this might be to use a scripting language (or even Mathcad) to change the values in the worksheet xmcd (xml) files (not sure if this can be done in Prime, though).

b. Put the values in a text/Excel file and read that in to the worksheet.

c. Define the values in a worksheet and directly link it using a Mathcad Reference (the 'parameter value' worksheet could also be used to create and update a data file.
 
Thank you all for the replies.
excognito said:
a. Put all of the arrays in an Area and collapse it to hide the definitions.
This is what i was doing until now, but the parameters never change.

As for option b), i'm currently experimenting with CSV files, and what i've learned is that i would need to define a csv for each class (not a problem), however excel or csv, i seem to have the same problem.
I can't figure out how to tell the dropdown when i select a class to return a row from that matrix/table/specific csv.After that i can manage. :)

Thank you all again for you're help.

Dan
 
If the parameters never change, then you're probably best off leaving them in the worksheet and making a Template of your "minimal" worksheet.

Your listbox should return an integer. In which case the easiest way in M14 to get a row from an array is to transpose it and use the column operator. Alternatively, use the submatrix function, eg if k is your index and the parameters are in array P, then submatrix(P,k,k,0,cols(P)-1) will return row k (assuming your using 0 as your array index base, drop the -1 if you're using base 1)
 
Well,after some thought weather it's worth a more complicated solution at this moment, i've chosen to do exactly how IRstuff has shown.
Basically , every column represents a class with it's coresponding parameters. This is enclosed in a region i hide.
Edited the script for the ListBox just so i can add as many classes as i need.Didn't even bother with the fact that it will start showing results from the second row, since matrix col/row numbering starts from 0 in mathcad.I added an empty row for that. Since it's hidden, it doesn't have to be pretty, it just has to work.
call out the selected column (ctrl+6) and that's it.

I literally just gave a written explanation on what he shown with that example.

This was the best solution for me at the moment.

Thanks again to both of you for you're help.

Dan
 
Status
Not open for further replies.
Back
Top