Skip to main content
3-Newcomer
June 11, 2024
Solved

Autogeneration of MathCAD Prime Files using the API or changing XML data

  • June 11, 2024
  • 3 replies
  • 1709 views

Hi,

I am attempting to create a program that will autogenerate several MathCAD file templates based on variables that will be taken from an excel sheet that contains a list of parts. 

 

I am using MathCAD Prime 9.0

 

Some things I've looked into are using the API or changing the XML data directly. 

 

The API doesn't seem to support a way to add in new inputs and outputs to a blank worksheet.

 

Changing the XML data directly seems like it could be a good option. From other posts I've read it sounds like you can change the file extension to a zip, unzip the file, change some data in one of the files, then rezip and change the extension back. However when I have tried this the process of unzipping and rezipping changes how it is compressed which causes it to be unreadable by mathcad, even if I don't change any of the internal files.

 

Is there a way I can inputs and outputs to a blank worksheet with the API that I am missing? Is there a way to unzip and rezip the mcdx file that will maintain the readability of the file in MathCAD?

 

Thanks

Best answer by Werner_E

Renaming the .mcdx file to .zip, unzipping its contents to a subdirectory and then rezipping this directory again maintaining the directory/subdirectory structure and renaming the .zip file back to .mcdx should work OK. At least I never had any problem doing so.

Maybe you try a different archive program and take care to maintain the very same directory structure and really use zip format and not rar or anything else when you rezip.

3 replies

Werner_E25-Diamond IAnswer
25-Diamond I
June 11, 2024

Renaming the .mcdx file to .zip, unzipping its contents to a subdirectory and then rezipping this directory again maintaining the directory/subdirectory structure and renaming the .zip file back to .mcdx should work OK. At least I never had any problem doing so.

Maybe you try a different archive program and take care to maintain the very same directory structure and really use zip format and not rar or anything else when you rezip.

Community Moderator
June 24, 2024

Hi @JE_11147360,

 

I wanted to follow up with you on your post to see if your question has been answered. 
If so, please mark the appropriate reply as the Accepted Solution. 
Of course, if you have more to share on your issue, please let the Community know so that we can continue to help you. 

 

Thanks,
Anurag
 

16-Pearl
June 26, 2024

@JE_11147360 

 

This is an interesting thing. 

 

In worksheet.xml, I see any math regions and can probably figure out the formatting to modify or construct new ones programmatically.

 

However, text regions, while present, give an Item-idref instead of actual text.  In the xaml folder, there ends up being a xamlpackage file for each and every text field.  These too are compressed and can be uncompressed (unzipped).  The resulting xaml sub-folder for each one contains a Document.xaml file which is editable and contains the actual text of the text field.

 

Some interesting possibilities going through my head right now.  This info might help someone else out.

12-Amethyst
August 14, 2024

This is interesting.  There are some good things here,  It is still like we are working with a black box.  If the api would give us more control it would be direct.

 

I see my results in the results.xml file but would still want to verify it is for my variable MYVAR_Yield:=8.66 for example.

 

<resultData result-id="20" calculation-status="Synchronized"><ml:result><ml:real>8.6698971036686263</ml:real></ml:result></resultData><resultData