BestFitPlane normal vector by time

Dear Material Studio users,

I have a system that includes several 6-rings. Following MD simulations, I aimed to conduct post-processing analyses, one of which requires obtaining the normal vectors of each 6-ring plane versus time.


So, I made BestFitPlane out of all 6-rings (please see the attached figure) and then wrote the following code:


#!perl

use strict;
use Getopt::Long;
use MaterialsScript qw(:all);

my \\\$doc = \\\$Documents{"new0.xtd"};
my \\\$std = Documents->New("NormaleVectors.std");
\\\$std->ColumnHeading(0) = "Nx";
\\\$std->ColumnHeading(1) = "Ny";
\\\$std->ColumnHeading(2) = "Nz"
my \\\$bestFitPlane = \\\$doc->DisplayRange->BestFitPlane;
my \\\$planes = \\\$bestFitPlane->BestFitPlane;
for (my \\\$frame=1; \\\$frame<=\\\$doc->Trajectory->NumFrames; ++\\\$frame){
\\\$doc->Trajectory->CurrentFrame = \\\$frame;
my \\\$BFPCounter = 0;
my \\\$i=0
foreach my \\\$plane (@{\\\$doc->DisplayRange->BestFitPlane}){{++\\\$BFPCounter}  
\\\$std->Cell(\\\$i,0+(\\\$frame-1)*3) = \\\$plane->UnitNormalVector->X;
\\\$std->Cell(\\\$i,1+(\\\$frame-1)*3) = \\\$plane->UnitNormalVector->Y;
\\\$std->Cell(\\\$i,2+(\\\$frame-1)*3) = \\\$plane->UnitNormalVector->Z;
\\\$i++;} 
}

However, upon running the code, I got this error:

"There is more than one object in the "BestFitPlane"s collection (function/property "BestFitPlane") at -e line 13."

Would you be able to kindly advise me on what I have missed in the code? Thank you, SJ