79703548

Date: 2025-07-16 14:13:16
Score: 0.5
Natty:
Report link

Right. After all last night and most of today investigating this problem, I believe I've got to the bottom of it and felt it may be useful to record the answer here for anyone else (and my own future reference), in case they might encounter the same problem.

TLDR: It appears the code is/was correct as shown above, but that the solve state of the top-level model file is pretty crucial.

The key difference between my 'test' and 'production' models that was throwing up the problem, was that I had initially solved my 'test' model outside of Load Case Manager, using the Right-click study name => Run command. So there was a 'default' result set sitting there in the 'CWStudy.Results' slot.

In my 'production' model, I hadn't first solved via the same route. I'd just gone straight to Load Case Manager (LCM) and set that running. So in that case, even though there were results sets stored in the Load Case Manager, there was nothing in the 'default' result slot.

It appears that the API's CWStudy.Results property doesn't successfully initialise if there isn't at least a set of solved 'default' study results. So even though there are LCM result sets available, and even though the command LoadCaseManager.LoadResultsOfPrimaryLoadCase(x) apparently loads said results and returns a boolean true assuring that, when you try and access CWStudy.Results it is just 'Nothing'.

Reasons:
  • Long answer (-1):
  • No code block (0.5):
  • Self-answer (0.5):
  • Low reputation (0.5):
Posted by: FrugalTPH