Skip to main content
Best answer by DJNewman

You can't directly put units on any advanced control...

...But what you will see on PTC's own worksheets would be something like

 

x: [slider] and then x2 or xunits: x*cm.

And then you use xunits for any further calculation or input.

 

 

 

Edit: If the unit varies but you want to use the same slider every time, then... you can be a little more creative. I came up with something like this...

 

DJNewman_0-1731462794312.png

 

1 reply

DJNewman
DJNewman18-OpalAnswer
18-Opal
November 13, 2024

You can't directly put units on any advanced control...

...But what you will see on PTC's own worksheets would be something like

 

x: [slider] and then x2 or xunits: x*cm.

And then you use xunits for any further calculation or input.

 

 

 

Edit: If the unit varies but you want to use the same slider every time, then... you can be a little more creative. I came up with something like this...

 

DJNewman_0-1731462794312.png

 

PTC Marketer Creo and Mathcad. I run their YouTube channels, some Creo campaigns, and all Mathcad campaigns and communications.
23-Emerald V
November 14, 2024

Not that I wish to be contrary, but after pondering this matter for a few milliseconds (or thereabouts) 🤔. an obvious (for values of "obvious") solution occurs to me ... ðŸ˜ˆ

 

2024 11 14 C.png

 

I'm not a huge user of units, but this was a requirement that I've had on occasion.  Before Mathcad Prime 10, I went with a traditional lookup approach (see postscript).  Now that Mathcad Prime 10 is here, I slotted in an advanced control to choose the unit (as did you) before passing it to the lookup function.  However, a few minutes ago I spotted something in the advanced control Help that gave me an idea.  And voilà (or whatever French for "look there" is).

 

The clue is there in the image ...

 

Stuart

 

What?  Why, the very thought.  Of course, I've suggested adding the Potrzebie System of Weights and Measures.

 

Hmm.  I suspect the original request is hidden in deep time within the old Mathsoft Collaboratory, but an honourable mention goes to ...  

 

https://community.ptc.com/t5/Mathcad/Programmatically-create-variable-names-and-assign-values-from/m-p/667321/highlight/true#M190290

 

How true.  I'm surprised that no maintenance subscriber has asked for a modified version of str2num that converts quantified numeric strings (eg, "3.14159 mp" or 2.7Fb" (where mp = millipotrzebie and Fb = furschlugginer blintz )), so that we'd have:

str2num("3.14159 mp") = 7.111 Î¼m

str2num("2.71828mp") = 99.014 t

 

I suppose some enterprising individual could probably write one ... (I think I may have one hidden deep in my M15 archive)

Yes, I did have such a variant of str2num, but it requires maintenance to make it more generally useful, so I'll wait for the revised str2num to appear as a priority upgrade in Mathcad Prime 11.

25-Diamond I
November 15, 2024

So you were kind enough to have the button "Show in Worksheet" pressed 😉

Clever idea and sure looks better than using 'lookup'. After all the vector unitsL isn't needed in your approach anyway.

Werner_E_0-1731634711456.png

I would rather use a listbox to choose the unit instead of using a slider (even if it would take up more vertical space or requires scrolling), but that may be just a matter of personal preference.

If the number of units to choose from is not too large, radio buttons may be an option as well. Unfortunately they can only be arranged in a column or in a row but not in matrix formation.

It may also be an option to define the value in front of the unit selector and use it as its second input

Werner_E_1-1731637126620.png

 


Yes, I did have such a variant of str2num, but it requires maintenance to make it more generally useful, so I'll wait for the revised str2num to appear as a priority upgrade in Mathcad Prime 11.


I am full of admiration for your unshakeable optimism!

Don't you think that MDAs, empty arrays, list data structure are further up the priority list?

But once advanced controls can be assigned to Prime functions and get implemented a way to return units as well similar to the API, it should be not that difficult to write your improved str2num yourself 😉