cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
Showing results for 
Search instead for 
Did you mean: 

Community Tip - Help us improve the PTC Community by taking this short Community Survey! X

MathCad and c#

ptc-2540485
1-Newbie

MathCad and c#

Hello, I am investigating connecting my companys Mathcad worksheets together with our Cad software. The cad part is already in place but when I started translating an example found in your helpfiles to c# regarding checking out setting/getting values from a worksheet i ran into some problems. I added the source(below) for the test i am running. Any hints to as what I am doing wrong here would be very much appriciated. Best regards, Tobias Svenberg ---------- Source code public partial class mathcadTest : Form { Mathcad.Application mc = new Mathcad.Application(); Mathcad.Worksheets wk; Mathcad.Worksheet ws = new Mathcad.Worksheet(); public mathcadTest() { InitializeComponent(); } private void doMathCadTest() { wk = mc.Worksheets; ws = wk.Open(@"c:\temp\mathcadtest1.xmcd"); ws.SetValue("a", "10"); ws.Recalculate(); try { string b = ws.GetValue("b") as string; MessageBox.Show(b); } catch (Exception e) { MessageBox.Show(e.ToString()); } ws.Close(Mathcad.MCSaveOption.mcDiscardChanges); System.Runtime.InteropServices.Marshal.ReleaseComObject(wk); System.Runtime.InteropServices.Marshal.ReleaseComObject(ws); System.Runtime.InteropServices.Marshal.ReleaseComObject(mc); } private void button1_Click(object sender, EventArgs e) { doMathCadTest(); } }
0 REPLIES 0
Top Tags