Community Tip - Stay updated on what is happening on the PTC Community by subscribing to PTC Community Announcements. X
Hello
I am a newbie with regards to MathCAD in general and the Checkbox functionality in particular.
Running MathCAD prime 11.0.0.0
I just wonder if there is a convenient way of generating an array of checkboxes so that one make it simple to can "click on all that apply".
Hope this is not too trivial..
Regards
Hallvard
Solved! Go to Solution.
It should be trivial and it may be convenient, but check boxes in Prime are only isolated.
But you can assign the output to vector elements and so have all values available in one variable if that's needed.
You may also hide the left hand sides
It should be trivial and it may be convenient, but check boxes in Prime are only isolated.
But you can assign the output to vector elements and so have all values available in one variable if that's needed.
You may also hide the left hand sides
Thank you Werner_E
Good to learn that what I am failing to achieve in principle is not possible. 😉
I guess what is confusing me is the apparent MathCAD flexibility of defining variables and functions on scalar, vector, or matrix forms in kind of a seamless way.
What I was hoping for was some kind of way to pass an array of text labels to the Checkbox control, which the control would displayed as shown in your second figure, and get an array of boolean showing which of the labels were checked.
Anyway I will try to work around it.
Regards
Hallvard
So your actual goal was to provide the label texts for the checkboxes via a matrix of strings?
Here is a way to do it, even though it may be not that straightforward as it would be desired.
The checkbox script is the same for all
They use an input which is the string to be displayed and are assigned vector elements. So the indices have to be changed individually for each check box:
It would be nice if the number of checkboxes could be controlled by the number of entries in the OptionYText vector, but thats not possible with this approach - you have to create the number of check boxes needed in advance.
Prime 11 sheet attached
Thank you very much @Werner_E
This works as advertised. 🙂
A bit of caution may be required though, as I experienced a MathCAD crash when trying to paste the code into an existing MathCAD document.
I think this was related to the fact that I had ORIGIN set to 1, and that the green border of the "redefined variable" warning created a "challenging display formatting" that MathCAD could not resolve. But that's just an assumption from my side.
I am considering trying to make a "generic function/program" based on this. Is there a reason this would not work?
(Basically I would input an array of n strings, check the length of the array, make a for loop to populate the n dimensional Boolean array, and return this to the calling document.)
Regards
Hallvard
When PTC adds features to Prime, they usually no longer respect the spirit and intention of Mathcad. This is the case with the implementation of Solve Blocks, which seem like foreign bodies, with the terribly amateurishly implemented Chart component, and unfortunately also with the advanced controls, which, for example, cannot be part of a Prime function (as we are used to from old Mathcad) and cannot be placed in text areas like other math regions.
When copying controls, but also areas, I have experienced the strangest unwanted effects (but no crash so far). For example, the height of a checkbox suddenly spanned several pages after copying, or collapsed areas, when expanded, no longer pushed the areas below them down, but overlapped them. Copy & paste is generally extremely poor and unusable in Prime in various respects.
Regarding your intention to automate the creation of a checkbox field using a function, I am not sure how exactly you intend to achieve this.
I could well imagine that it is possible to create a complete Prime file with an external program (possibly a C++ program or a Python script), even if that would require a lot of work reverse engineering with regard to the file format.
However, I cannot imagine creating a field with a variable number of checkboxes using a Prime function. After all, checkboxes must be created via the menu, and there is no command that could be used in a program to provide this functionality.
Anyway - good luck for your project!
Hello again @Werner_E
Thank you for the explanation. Good to know that Advanced control cannot be part of a Prime function (which was the idea I was considering).
I discover that I am spending quite some effort in trying to make the "MathCAD document" look good. If it is necessary to turn to external programming languages, I wonder if it I may just as well use Python with some markup and math modules in stead..
Regards
Hallvard
You sure will have to chose the tool that fits you and your task best.
Strength of Prime sure are the ability to handle units in a fairly natural way, to use and display math expressions in a way which is very similar to the usual natural math notation and to be able to place math expression at any position (unique whiteboard interface) which makes Prime a mathematical scratch pad, which is particularly advantageous during the design phase, but also when creating reports for people who are not familiar with the software.
But Prime sure has a lot of drawbacks and disadvantages in functionality or when it comes to present results in a nice way.
Advanced Controls were only introduced in version 10 (again, we already had them in the old Mathcad, and they were more flexible and powerful there), and they are clearly still in their infancy. Let's hope they grow up at some point (which could take a long time given Prime's development rate).
The latest improvement in version 11 for advanced controls was not the ability to use them wherever mathematical expressions are possible and to use them as functions or create them via functions, but rather the addition of Python as a scripting language. What is missing here is an automatic fallback to JScript if the user calling up the worksheet does not have Python installed. Instead, the control simply does not work in this case. It is also not even possible to store scripts in two scripting languages. So everything is still quite immature.
Hello again
Trying the “reply via email” this time. Not sure if it will end up in the forum.
I guess this is turning into more of a “philosophical discussion” than what I intended initially. 😉
In my organization we been using MathCAD 15 for a long time as a “General engineering scratchpad”.
The primary reason to use MathCAD is the ability to perform and document engineering calculations in a single operation (“quick and dirty”).
As version 15 is no longer supported by our IM infrastructure, we have had to switch to Prime, and I am currently on the latest 11.0.0.0 release.
(BTW, it seems very challenging to make any MathCAD version installable as a package via MS “Company Portal” or “Intune??”, do you not know if that is a known issue?)
Our industry is within ship propulsion, and some calculations occur more frequently than others. I am therefore attempting to make more professional looking “templates” for some calculations that are frequently requested by Ship Classification Societies based on their (different) rules. Currently these calculations easily can become messy documents where parts get copied from previous projects (based on the specific of the individual project and classification options of the costumer) in a way which is difficult to control.
Since not all calculations are needed for every project, my decision to make an array of Boolean values to select which of the calculations to perform/display.
But this may be an approach which is not as easily implemented in MathCAD prime compared to a “traditional programming language”?
With regards to MathCAD handling of Units: I see this as a unique and useful feature, but unfortunately the “Class rules” which often governs our calculations are not necessarily true to units. So this must be handled in an alternative manner (text prompts just as with traditional programming languages).
Regards
Hallvard
You (might) be able handle it within Mathcad using scripting to edit or create a worksheet and then populate it with the required checkboxes.
Possibly a scripting guru could comment on this or give an example?
Stuart
Hello @StuartBruff
I managed to implement the suggestions from @Werner_E which solved the immediate issue I had at the time.
It was not as elegant as I was hoping for, but still works quite well in the finished worksheet.
Regards
Hallvard
No worries, Hallvard.
Bedre med en fugl i hånden enn ti på taket!
Stuart
