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

Community Tip - Learn all about PTC Community Badges. Engage with PTC and see how many you can earn! X

A different set of input variables depending on a logical switch (MathCAD 15)

ClaudioPedrazzi
12-Amethyst

A different set of input variables depending on a logical switch (MathCAD 15)

Hi everyone

I am trying to automate a task, where the user has to select a sketch (that will be graphically shown using a GIF-Image stored somewhere), then provide certain inputs (namely dimensions) that will be shown on the sketch and then my worksheet will compute the results. 

 

To provide an example, I could say:

Sketch:= Square / Rectangle / Circle

for "Square" the input variable could be: a (the side of the square)

for "Rectangle" the input variables could be: a,b (the two sides of the rectangle)

for "Circle" the input variable could be: r (the radius).

then MathCAD would take the input variable(s) and compute, as an example, the perimeter and the area.

 

The computation is no problem at all, I can manage it with some ifs.  But the input variables, I do not know how to "force" the user to input all and only the variables that are needed for the chosen sketch (the number of this variables is around 8-10 in my real application, the geometrical sketches being slightly more complex than square and circles).

 

At the moment I have no better idea than to provide a group of input statements for every sketch, all inside the same worksheet, all deactivated, and tell the user to manually activate the group of inputs he needs. 

 

Like:

Inputs for "square"

a:= 30 mm

Inputs for "rectangle"

a:= 40 mm

b:= 50 mm

Inputs for "circle"

r:=20 mm

 

Somehow this method is not user-friendly at all, and not satisfying.  

 

For information,this question is related to this other one. 

 

Thanks a lot for every insight or idea!

Best regards

Claudio

 

PS: the sketches could look like this (only the appropriate one will be shown):

Unbenannt.GIF

ACCEPTED SOLUTION

Accepted Solutions

Some scripted components may do the job.

In Richards collection of extra components and controls

https://community.ptc.com/t5/PTC-Mathcad/Extra-Components-and-Controls/m-p/450450

you find a function "fCreate" which creates real valued variables given the variable names as a string and the variable values.

Furthermore you find there a a function "PopUp" which opens a popup window prompting for an input.

Combining the methods in the scripts of those to component functions and using a decent list box (maybe an enhanced one from Richards collection which can be dynamically changed) my be a suitable solution for your probem.

 

 

 

 

 

 

View solution in original post

6 REPLIES 6

Hi,

Simplest way is to use a combo box to allow the user to pick one.

Capture.JPG

Cheers

Terry

If you're using Mathcad 15, then the easiest way would be to use a programmable control.

 

However, if you're using Mathcad Prime 7 or Mathcad Prime 8 (full versions), then you could try a Combo-Box.

 

2022 05 05 a.png

 

Making a selection ...

2022 05 05 b.png

 

The left side of the Combo-box is hidden.  However, it doesn't hide the space that the left hand would use; consequently, the combo-box is offset to the right of where I wanted it.

 

2022 05 05 c.png

 

Stuart

 

Edited to add: That's odd - I didn't see Terry's reply when I started to answer your question.

Hi Terry and Stuart

thanks a lot! unfortunately I am using MathCAD 15, Prime is momentarily no option.

My problem would be to define different variables for each figure.  I am not familiar with Prime, but it seems to me that you defined the variables as "a" and "b" for all figures.

I would like to name the variables differently (at least some of them) for each figure (I do not want, in my example, to call the radius "a", or the angle for the "pizza slice" "b"). 

A little more abstractly:

Figure A should have input variables A1, A2.

Figure B input variables B1, B2, B3, B4.

Figure C input variables C1, C2, C3, C4, C5

and so on... (about 8-10 figures, a dozen input variables each)

 

Ciao!

Claudio


@ClaudioPedrazzi wrote:

Hi Terry and Stuart

thanks a lot! unfortunately I am using MathCAD 15, Prime is momentarily no option.

My problem would be to define different variables for each figure.  I am not familiar with Prime, but it seems to me that you defined the variables as "a" and "b" for all figures.

I would like to name the variables differently (at least some of them) for each figure (I do not want, in my example, to call the radius "a", or the angle for the "pizza slice" "b"). 

A little more abstractly:

FigureA should have input variables A1, A2.

Figure B input variables B1, B2, B3, B4.

Figure C input variables C1, C2, C3, C4, C5

 

Ciao

Claudio


The intrinsic ability to create variables automatically has been on my Mathcad wishlist for longer than wishlists have existed (ie, before some poor tyrannosaur thought "Yeah, it looked spectacular, but I wish that big bit of rock from space had missed the Earth" and the sharks had thought "Not again")

 

Mathcad Prime 1..8 don't have any effective automation capability so that rules out Prime as a suitable medium, anyway.

 

In Mathcad 15, you could try playing around with scriptable-control automation.   I vaguely recall writing and deleting Math Regions, but I can't remember what the process is.  Nor can I remember if you can actively collapse and expand Areas.   Hopefully, somebody with M15 can help out here.

 

On the other hand, you might also be able to circumvent the need for actual variable names if you merely need the names for the user.

 

In M15 and Prime, one way might be to create a matrix of equivalent names and display the appropriate ones besides a and b.   For example, 

 

2022 05 05 d.png

 

In M15, you might be able to do something similar using scripted TextBoxes, even disguising the variable names by hiding the left-hand side of the assignments.

 

Stuart

Some scripted components may do the job.

In Richards collection of extra components and controls

https://community.ptc.com/t5/PTC-Mathcad/Extra-Components-and-Controls/m-p/450450

you find a function "fCreate" which creates real valued variables given the variable names as a string and the variable values.

Furthermore you find there a a function "PopUp" which opens a popup window prompting for an input.

Combining the methods in the scripts of those to component functions and using a decent list box (maybe an enhanced one from Richards collection which can be dynamically changed) my be a suitable solution for your probem.

 

 

 

 

 

 

Re: Image in Prime - PTC Community

Now Perez show the answer for Prime 9. Excel component can show only selected image and corresponding data.

Ofcourse it can show multi images to select.  

image.png

Announcements

Top Tags