Community Tip - New to the community? Learn how to post a question and get help from PTC and industry experts! X
Hi, I am using the API, and have a working code. However, for generality, when getting output results I cannot tell what type is it. For example, if I use
....
Outputs = WS.Outputs
For i = 0 To WS.Outputs.Count - 2
var = Outputs.GetAliasByIndex(i)
varval = WS.OutputGetRealValue(var)
varvalstr = WS.OutputGetRealValue(var).RealResult.ToString
varunitstr = varval.Units
imsg = imsg + "Index=" + Str(i) + " , Name= " + var.ToString + " , Value= " + varvalstr + " , Units= " + varunitstr + vbCrLf
Next
...
How can I tell before calling OutputGetRealValue that my output is a real number not a string or matrix?
Cody
Hi,
Examine the following code snippet located in attached text file.:
How to tell if value is a string, scalar, or matrix.
Cheers
Terry
Hi terryhendicott,
I was able to follow your snippet, modify, and it worked for the real and string. Thank you for taking the time to answer me. I appologize i did not know it was answered until this week.
The part of the matrix, I was left with this,
hereResult = WS.OutputGetMatrixValueAs(WS.Outputs.GetAliasByIndex(a), "")
rowCount = hereResult.MatrixResult.Rows
colCount = hereResult.MatrixResult.Columns
Dim Start As String
Start = "L7"
For inrow = 0 To rowCount - 1
For incol = 0 To colCount - 1
Dim b As Integer
b = hereResult.MatrixResult.GetMatrixElement(inrow, incol, dblhere)
Debug.Print(b)
'Worksheets(WorksheetName).Range("L7:L7").Offset(inrow, incol).Value = dblhere
Next incol
Next inrow
---
I am trying to test it but cannot seem to set a matrix as an output variable in mathcad prime 9. I've tried tables and matrices. Also, how do i know the matrix item will be a double value?
Much appreciated!
Hi,
The good news
There are four equals signs in mathcad. The assignment equals which is acolon and an equals sign, the comparison equals which is a bold equals sign, the global equals sign that is three horizontal short lines, and the one that concerns us the display equals sign that is an equals sign. to get a matrix as an output value use the equals sign to display the matrix, select all of this equation and then use menu Input/Output | Integration | Assign Outputs
The bad news
The API does not work for matrices that contain any element is a string, nested matrix, or complex variable. The API assumes all matrices have real numbers only hence no methods to check this assumption.
Cheers
Terry
HI terry, I thought i had this working and now i cannot get a simple test file working. Do you think you can send an mcad that would work with this? With one matrix like you say. Maybe complete the snippet. Please.
Hi @CG_9625485,
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