A PTC Mathcad Prime XML Writer in C++
- June 28, 2026
- 0 replies
- 0 views
A PTC Mathcad Prime XML Writer in C++
File created with PrimeWriter v1.1 Alpha, an Embracadero RAD Studio 12 C++ Builder program. Program creates a rudimentary worksheet as a starting point. It is intended for further enhancement to create more elaborate worksheets
Started with a simple request of ChatGPT
"create a PTC Mathcad Prime file that creates variables a and b of 3 and 5 respectively and adds them together for variable c."
This started a week long Monday to Sunday, long hours each day focused chat with chatGPT and has produced a simple programmable worksheet generator in C++. It has some functions already defined; operators +,-,/,* sqrt, sin, cos, tan, exp, pow, nthroot, max, min, atan2, lsolve, concat, det, trace, rank, eigenvals, augment, and submatrix. Adding a new Prime function type only takes two lines of code. So more will be added over time. Greek symbols can be used.
It is intended as a quick visual report writing method for my C++ FEM work.
The new advantage is C++ program flow can create Prime worksheets with variable content based on that C++ program flow.
C++ statements to create a worksheet are simple once a worksheet ws; variable is established in C++
ws.Define(), ws.Evaluate(), ws.Function(), ws.AddText(), ws.AddHeading(), ws.BlankLine()
Internally within Define() and Function() as parameters to create Prime Equations
Id(), Call(), Paren(), Real(), Str()
Names of Prime mathematical functions capitalised. e.g. Sin() & Operators +, -, *, /.
Matrix library eigen-5.0.0 is linked so Define() can initalise a Prime variable with an Eigen::MatrixXd& directly.
Only XML text is created during the Prime file creation. Prime does the calculations when file is loaded in Prime.
Willing to share this work. Also working on a Visual C++ version that is not working fully yet.
The file enclosed was generated by the C++ program. Still needs work on positioning of matrices in the resulting file.
Cheers
Terry

