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

Community Tip - Want the oppurtunity to discuss enhancements to PTC products? Join a working group! X

how to save graphs using VB code.?

RamkrishnaShira
1-Visitor

how to save graphs using VB code.?

Hi Please help.

ACCEPTED SOLUTION

Accepted Solutions

I think it can be done. Steps might be this:

1. Calculate the document.

2. Save it in xmcd format.

3. Parse it and find the plot tag with region-id.

4. Save document in html format.

5. Find png file using region-id.

That's all.

View solution in original post

13 REPLIES 13

First of all, a better description of your problem might be required. Just simply saying "help please" and letting the thread title ask the question isn't the best way to go about things.

Why do you want to only save the graph?

Can't you copy/save the graph as an image?

Can't you print the graph to pdf?

Mike

Hi Mike,

Thanks for the response and i apologize for not giving proper description of my query.

I ve developed an application in visual basic 6.0 (VB/MathCAD interface using OLE automation ). I pass the input parameters from VB screen to Mathcad sheet through OLE. (using "SetComplex" method) and retrive the output using "GetComplex" method.

My problem is how do i save the graph generated in mathcad using the VB code?? I ve been searching for the solution since so many days.

Regards,

Ram

To be honest I don't know too much on this topic. I would have thought you can save the graph as an image and and retrieve it using the 'GetComplex method'.

I will have a hunt round and see what I can find.

Mike

thanks Mike.

Thanks for sparing ur time.I ve been hunting this since 6 months.MathCAD has absolutely no support to save graphs using VB program.Currently i m using print screen method but its not the proffessional approach.

Do let me know if u find anything.

Regards,

Ram

Just to confirm.

You want the graph saved as an image automatically using VB? Or am I missing the point?

Mike

yup u got it right.I want to save the graph as an image automatically using VB.

Thanks,

Ram

I think it can be done. Steps might be this:

1. Calculate the document.

2. Save it in xmcd format.

3. Parse it and find the plot tag with region-id.

4. Save document in html format.

5. Find png file using region-id.

That's all.

Hi Viacheslav,

Thank you so much for the help.

I am doing it in the same way right now as explained in the above steps.

I think Mathcad has not provided any builtin VB functions / API to extract the graphs. This is the only way to do it.

I have few more questions for you. Can we extract the values from a matrix using VB Automation API?

I would like to know the code for both embeded as well as using VB OLE automation .

Regads,

Ram

As for MC15 automation API, you can do it like this:

GetElement.png

See the Developer's Reference, Automation Interfaces, The Mathcad Automation API, MatrixValue class:

The GetElement method retrieves the value of a specified matrix element

With OLE you can simulate this:

GetElement2.png

Hi,

Thanks for the code.

Can we achive the same thing using MathCAD embedding API?

Embedding API supports only 4 methdos

How can we retrive the Matrix values in this method?

Can we retrieve the Matrix values using GetComplex Method?

Regards,

Ram

Ram, no we can't (but I haven't tried).

Where is your imagination? You can solve this problem in two ways:

1. Simulate GetElement() in your document and then get the value with GetComplex() method like I showed above.

2. You can use WRITEBIN() in worksheet to save the matrix and then work with a binary file as you usually do this in vb6.

We still do not know the goal you want to achieve by using MC in this way.

Viacheslav,

We have complex MC sheets which contain all sorts of Inputs, Outputs, Matrix, Graphs..etc.

Main goal is to retrive all the output values including graphs from MC sheets uisng VB MathCAD automation and pass these values to word and excel (As an output to the user) . The user will see only VB form to input the parameters and all the process wil run in background. The user will only get to see the output in Word/ Excel format. Also, The user inputs will be stores in SQL server for re-use if required.

Thanks for the help. I will test using your code.

Regards,

Ram

The user will see only VB form to input the parameters and all the process wil run in background. The user will only get to see the output in Word/ Excel format.

If so why do you need to embed mathcad in your vb application (embedding api)? Furthermore, the use of this interface is not recommended (from MC15 The Developer's Reference):

Note: This interface is deprecated. New code should use the Worksheet class, documented in the Automation API.

And I was wrong, it can be done:

vb6mathcad.PNG

You must use another object: Set MathcadWorksheet = OLEMathcad.object.Worksheet

Announcements

Top Tags