cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
Showing results for 
Search instead for 
Did you mean: 

Community Tip - Have a PTC product question you need answered fast? Chances are someone has asked it before. Learn about the community search. X

Create a new listbox from another listbox's script

Matthurin-disab
1-Newbie

Create a new listbox from another listbox's script

Hi all,

I'm starting to use the script editor and I've been looking for one thing that would be really useful to me.
No doubt that it might be obvious for some people, but I would like to know if it is possible to create a new listbox from an existing listbox by programming it, and if yes, how to do it.
Indeed, I would like to have one or several listbox to appear when I select one item in a previous one.

Thanks!

Matthieu.
5 REPLIES 5

You cannot create a listbox (or any region, for that matter) programmatically. Just not included in the automation interface (yes, it should be, argue that one with Mathsoft/PTC). But you can pass parameters to listboxes, and listboxes can change their contents based on the passed data. So you can have cascaded listboxes where the available values in one box depend on the choice(s) in previous box(es). An example of cascaded listboxes is in the AISC steel shapes sheet, where the first box allows you to select a file and the second one then shows the shapes that are to be found in that file.
__________________
� � � � Tom Gutman

Thank you very much for that!
I spent a whole afternoon trying to do it this way, good to see that i doesn't just come from me...
I guess I'll opt for the cascades listboxes then!

Matthurin.

Hi there,

Well I'm sorry but now I have another question regarding the cascade listboxes...
Indeed, it works pretty well, but now I'm stuck on one other thing.
Is it possible, for a listbox having one input and one or several output, to define the name of the outputs regarding the input value/string?
Since I'm using empirical equations, it is full of conditions, and thus sometimes I just need 2 listboxes for one kind of structure as I can need 5 listboxes for another kind of structure.

Thanks!

Matthurin

I don't really understand the question.

Unless a list box accesses additional data (such as a data file, as done in the AISC steel shapes), there is not much point in multiple outputs. All that is needed is the index of the selection in the input value, Mathcad can use that index to access any additional data associated with the selection. If the information is kept in separate data files (rather than being hard coded in the MC work sheets) you have the option of reading and processing the data in Mathcad, using the list boxes just for selection, or having the list boxes access the external data directly.

Listbox outputs do not have names -- just values. Those values are assigned to variables as specified in Mathcad. Those variable names are not accessible or changeable by the list box code -- it has access only to the input and output values. The only way I know to have a component specify a Mathcad name is to use the code from the define variables sheet, as is done in the AISC steel shapes to assign values to variables whose names are in the Excel data files.

If you will need a variable number of choices you have to define list boxes for the maximum number. Any listboxes that are not needed will just display an empty list, and not allow a selection. If you need to tell the user what he is selecting, you can use a text box above (or along side or below) the list box and have it disply explanatory text.
__________________
� � � � Tom Gutman

Thanks for this complete answer!

My question was not so well formulated indeed...
Actually I did it the way you propose it at the end of your message, and it seems to work good so far, with good results as well!
So one more time, thank you!

Matthurin
Top Tags