The above problem has just appeared when running a script for the first time (on my machine) in DIAdem 2021, having worked perfectly in 2020.
The offending line of code (not the one in the error message but the one at which the problem actually occurs) is:
Call View.Sheets("Sheet 1").Areas("Area : 1").DisplayObj.Curves.Add("/","/")
...but this is only the problem line because of what takes place just prior. Having started with two groups of channels, the code deletes the first group as it is not needed any more. The second group becomes the first group and channels 1 and 6 are to be plotted using the above line.
However, what seems to be happening is at the point of deleting the first group the data file is not updated so that the above line tries to add channels 1 and 6 from the first group. These are now empty and not available, although the group and channels still appear to be listed in the portal.
As I write this I've also discovered that previous channel deletions also fail in the same manner. The two 'Time' channels in the following image should have been removed before any of the above takes place. I've shown the 'Latac' channel in the first group as highlighted but you can see in the boxes below there are no details for that channel.
In short, it seems that using the Remove method is not working properly.
Solved! Go to Solution.
I have tested the behavior which you described in DIAdem 2021 SP1. It works fine. Here is my script and attached, also all other data. Can you please check the problem with these data?
all Data.Root.Clear call DataFileLoad(CurrentScriptPath & "Test Data.TDM") call View.LoadLayout(CurrentScriptPath & "Test Data.TDV") call Data.Root.ChannelGroups.Remove(1) call View.Sheets("Sheet 1").Areas("Area : 1").DisplayObj.Curves2D.Add("/", "/") call WndShow("VIEW", "maximize")
Your code works perfectly.
Separately, I have engaged NI technical support to look at the problem so I will report back here with their findings.
Interestingly, if I run the problem script on its own (without being called using ScriptStart) then the same problem occurs. However, if I run it in debug mode then the Remove method works. But, when it comes to the line to add the 2D curve I get a slightly different error message stating that "The server threw an exception". What server, I wonder??
Thanks for your help and I'll let you know what they find.
We need to reproduce the problem so that we can find a solution. I think this is best done with your script code (at least the relevant code).
Do you work with DIAdem 2021 SP1?
I have submitted my code to NI tech support and they have confirmed that the problem is not with my code or installation - they have been able to replicate the problem themselves.
It's been escalated and I await their response.
Yes, I am using DIAdem 2021 SP1.
This is a bug with deleting a VIEW area. It is independent of the data. You can reproduce it with this small script below. Luckily there is a workaround by only setting the area to be deleted as active area. The bug will be fixed in DIAdem 2022 SP1.
Call Data.Root.Clear() call DataFileLoad("Example.TDM") Call View.NewLayout() dim oSheet_1 : set oSheet_1 = View.ActiveSheet dim oArea_1 : set oArea_1 = oSheet_1.Areas(1) dim oArea_2 : set oArea_2 = oArea_1.SplitBottom("Area : 2",0.5) oArea_1.DisplayObjType = "CurveChart2D" oArea_2.DisplayObjType = "CurveChart2D" ' workaround begin oArea_2.Active = true ' workaround end oSheet_1.Areas.Remove(oArea_2.Name)