Hey Jeff,
First, I would STRONGLY recommend using C# rather than C++ for ZOS-API applications. C# directly uses .NET while C++ has to use COM to communicate with the ZOS-API. C# is easier to use (especially considering COM) and there are more Zemax users that can help with C#.
// C#
// Add your custom code here...
// open new POP window
var win = TheSystem.Analyses.New_Analysis_SettingsFirst(ZOSAPI.Analysis.AnalysisIDM.PhysicalOpticsPropagation);
// change POP settings here
var settings = win.GetSettings() as ZOSAPI.Analysis.PhysicalOptics.IAS_PhysicalOpticsPropagation;
// run POP analysis
win.ApplyAndWaitForCompletion();
// get the results
var results = win.GetResults();
foreach(var line in results.HeaderData.Lines)
{
Console.WriteLine(line);
}
If you remember trying to use Python prior to 2018, it was an absolute nightmare; before 2018 Python used COM to connect to the ZOS-API so I researched and created the current Python template using PythonNET. Now C#, Mathematica, Matlab and Python all use .NET to directly connect to the ZOS-API and C++ is the only outlier.
If you have to use C++, here is how you can get the header data:
// C++
// Add your custom code here...
// open new POP window
auto win = TheSystem->Analyses->New_Analysis(AnalysisIDM::AnalysisIDM_PhysicalOpticsPropagation);
// change POP settings here
IAS_PhysicalOpticsPropagationPtr settings = win->GetSettings();
// run POP analysis
win->ApplyAndWaitForCompletion();
// get the results
auto results = win->GetResults();
SAFEARRAY* psa = results->HeaderData->Lines;
// Get a pointer to the elements of the array.
BSTR HUGEP* pbstr;
HRESULT hr = SafeArrayAccessData(psa, (void HUGEP**) & pbstr);
// make sure we can actually get data from the safearray
if (SUCCEEDED(hr)) {
// sizeof is off-by-1 to account for NUL terminater at end of array
for (long i = 0; i < sizeof(pbstr) - 1; i++)
wcout << pbstr[i] << endl;
}
SafeArrayUnaccessData(psa);
If you need help writing a compiled C# UDOC, you can DM me and I’d be glad to help.