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

Community Tip - When posting, your subject should be specific and summarize your question. Here are some additional tips on asking a great question. X

Outputting variables from mathcad with specific formatting into .txt or .exp filetype

ptc-6721944
1-Newbie

Outputting variables from mathcad with specific formatting into .txt or .exp filetype

Hi all,

I am needing to output calculated variables from my mathcad calculation sheet, into either a .txt or a .exp file. I have first tried using a matrix to do this, but the formatting is not exactly what I am needing.

I have attached my mathcad approach, and the resulting format. The problem with the format shown is the space between the =, and the value of the variable.

The reason I am needing to do this is so that I can output calculated variables into a file that will be read by siemens NX. Perhaps anyone knows of a script that has already been built that can do this? I found an example built by Mike Armstrong from a few years ago, but I could not get it to work with MathCad 15. It probably did not help that I have no experience writing scripts in MathCad.

Thanks guys.

textsegment.PNGmathcadsegment.PNG

-jw

1 ACCEPTED SOLUTION

Accepted Solutions

I have attached my mathcad approach,

No, you seem to have forgotten to attach the sheet. You just had inserted a screenshot.

Justin Wollmann wrote:

Hi all,

I am needing to output calculated variables from my mathcad calculation sheet, into either a .txt or a .exp file. I have first tried using a matrix to do this, but the formatting is not exactly what I am needing.

I have attached my mathcad approach, and the resulting format. The problem with the format shown is the space between the =, and the value of the variable.

The reason I am needing to do this is so that I can output calculated variables into a file that will be read by siemens NX. Perhaps anyone knows of a script that has already been built that can do this?

Two methods come in mind at first.

1) You could use num2str() and concat() to turn the number into a string and concatenete it with the text in front, Then just output the vector consisting of those strings

2) similar as above but use WRITEBIN for more flexibility. You can get rid of the quotes here using str2vec as shown in this thread: http://communities.ptc.com/message/233148#233148

View solution in original post

3 REPLIES 3

I have attached my mathcad approach,

No, you seem to have forgotten to attach the sheet. You just had inserted a screenshot.

Justin Wollmann wrote:

Hi all,

I am needing to output calculated variables from my mathcad calculation sheet, into either a .txt or a .exp file. I have first tried using a matrix to do this, but the formatting is not exactly what I am needing.

I have attached my mathcad approach, and the resulting format. The problem with the format shown is the space between the =, and the value of the variable.

The reason I am needing to do this is so that I can output calculated variables into a file that will be read by siemens NX. Perhaps anyone knows of a script that has already been built that can do this?

Two methods come in mind at first.

1) You could use num2str() and concat() to turn the number into a string and concatenete it with the text in front, Then just output the vector consisting of those strings

2) similar as above but use WRITEBIN for more flexibility. You can get rid of the quotes here using str2vec as shown in this thread: http://communities.ptc.com/message/233148#233148

JUST tried your first suggestion and it worked EXACTLY as I needed it. Formatting is perfect! Thank you.

-jw

Justin Wollmann wrote:

JUST tried your first suggestion and it worked EXACTLY as I needed it. Formatting is perfect! Thank you.

-jw

Fine - here is the second approach which in my opinion is more versatile compared to the inserted component.

Top Tags