User Operand
When using a ZOSAPI-based user operand, a "Prog#" of 0 performs the calculation, while any other value retrieves the specified value from the result vector.
double Hx = TheApplication.OperandArgument1; // Hx double Hy = TheApplication.OperandArgument2; // Hy double Px = TheApplication.OperandArgument3; // Px double Py = TheApplication.OperandArgument4; // Py int dataLength = TheApplication.OperandResults.Length; double[] results = new double[dataLength]; for (int i = 0; i < results.Length; ++i) { double x = i; double x2 = x * x; double x3 = x * x * x; results[i] = Hx * x3 + Hy * x2 + Px * x + Py; } // // Now assign the locally calculated resule back to the Application. // TheApplication.OperandResults.Data = results;
NOTE: that the interface allows an arbitrarily large vector, however only the first 100 values will be stored and accessible by OpticStudio.
Next: