What does nullCAE_xxxx do?

To all

I am looking at a recorded journal as I am trying to "extract" the keywords for a specific user action (create results in this case). One of the line is the following;

Dim nullCAE_ResponseSimulation_PeakValueEvaluationSetting As CAE.ResponseSimulation.PeakValueEvaluationSetting = Nothing

which is then use a bit later in the journal as follows;

Dim peakValueEvaluationSettingBuilder1 As CAE.ResponseSimulation.PeakValueEvaluationSettingBuilder
peakValueEvaluationSettingBuilder1 = simSimulation1.ResponseSimulationManager.EvaluationSettingManager. _
CreatePeakValueEvaluationSettingBuilder(nullCAE_ResponseSimulation_PeakValueEvaluationSetting)

What does this "null_CAE_xxxx" do? Trying to replay the journal crashes with an NX exception "Null pointer found"

any ideas? Is is it actually required?

Thanks

Regards

JXB

In the NXOpen API, there are what is known as "builder objects". These builders are used to create or edit certain types of objects. To edit an existing object, you would pass in a reference to the object you want to edit when you initialize the builder object. If you pass in a null value (keyword "Nothing" in VB), this tells the builder that you want to create a new object as opposed to editing an existing one. You could shorten the code above to this:

Dim peakValueEvaluationSettingBuilder1 As CAE.ResponseSimulation.PeakValueEvaluationSettingBuilder
peakValueEvaluationSettingBuilder1 = simSimulation1.ResponseSimulationManager.EvaluationSettingManager. _
CreatePeakValueEvaluationSettingBuilder(Nothing)

Creating a variable to hold the value "Nothing" (as was done in the recorded journal) is a verbose way of saying "I'm intentionally passing in a value of 'Nothing' to this method". It isn't strictly necessary, but it may help you or another programmer when maintaining the code in the future.

Now, with that said, I doubt that the code you posted is the cause of the error you describe. Did the operation successfully complete when you recorded the journal? Did you run the journal on the same file where it was recorded? Did you modify the part file and/or the journal file between the times that you recorded the journal and the time that you replayed the journal?

For the pedants among us ...
Actually, passing just plain "Nothing" to your CreateBuilder function is not quite the same as passing a specifically typed variable (like the nullCAE_xxx thing) with the value "Nothing". Because of the way function overload resolution is done, there are a few cases where the latter will work, but the former will not. But these cases are very rare (and I can't think of any specific examples), and personally I always use just plain "Nothing", as in NXJournaling's answer above.

As the other answer indicated, your real problems lie elsewhere. Look at the traceback info in the System Log, find out where (in which line of code) you are tryin to use a null pointer, and go from there.

thanks to both NXjournaling and ciao for the input/clarification. I am back on my problem albeit part-time
I have modified the code as suggested by getting rid of the "dummy" declaration but my test code still fails with a 'null pointer' at the line where peakValueEvaluationSettingBuilder1 is created/set to nothing

Dim peakValueEvaluationSettingBuilder1 As CAE.ResponseSimulation.PeakValueEvaluationSettingBuilder
peakValueEvaluationSettingBuilder1 = simSimulation1.ResponseSimulationManager.EvaluationSettingManager. _ CreatePeakValueEvaluationSettingBuilder(Nothing)

the aim of the code is to create peak results (force for bar elements) for a given list of events in a response simulation solution
The element list is obviously the same for all events. I am hoping to automate the creation of the peak results when a "large" number of events exist.

Regards

JXB

Thanks
Regards