MattWoodhead / MathcadPy

A Python wrapper for the Mathcad Prime automation API
GNU General Public License v3.0
24 stars 1 forks source link

Copy existing mathcad pages in a new mathcad file? #9

Open maimor10 opened 2 weeks ago

maimor10 commented 2 weeks ago

Is there a way to copy the pages of an entire mathcad file into a newly created mathcad file from Python? I would need this to copy files I selected from a folder to a newly created mathcad file. E.g. I say file 4 and 6 from folder xy (with 10 Mathcad files) should be copied together in a new empty mathcad file.

MattWoodhead commented 2 weeks ago

This is not currently functionality that is possible using this module, as select/copy/paste functions etc. are not exposed in the automation API by PTC.

This does not mean it is impossible though, two methods seem feasible to me:

  1. Automating Mathcad copy/position/paste operations using a tool such as pyautogui, in conjuction with the Mathcadpy library to automate other facets of interacting with Mathcad (e.g. loading and switching worksheets.
  2. Extracting the mcdx files (they are just zipfiles) and directly manipulating the internal xml files to get the content of one document and append it to another (region ID numbers etc. would need renumbering to get this to work). e.g. see https://github.com/BEF-BEF/MathCAD-Prime-XML-Builder/tree/main

Option 1 is probably the easiest one to try first.

andcoder321 commented 2 weeks ago

Interesting @MattWoodhead

  1. I'll have to look into this, def could be useful.
  2. I have dug through the xml files before, not for this case, but to try to change the version # to be able to, say, convert a MCP 10 file into a MCP 9 one. I found one place were the version # was listed, changed it, but the conversion did not work. Has anyone else had luck with this?