I ran into this issue a while back.
I added a little to your code to try to flesh out the problem:
#command("object");
file $file;
string $output;
shape $shape[0];
int $i;
project.curObject.GetShapes($shape);
$output = PrintToString("edges: %d", $shape[0].GetNumEdges());
$file.open("$console", "w");
$file.print("-------\n\n"+$output+"\n\n-------\n");
for $i=1 to $shape[0].GetNumEdges() do
{
$file.print("Edge: %d Point1: %d Point2: %d\n",$i,$shape[0].GetEdgeIndex0($i),$shape[0].GetEdgeIndex1($i));
}
$file.close;
I just drew a cube and converted to mesh for a test shape. The output:
begin script "F:\anim8or_v097b_preview\scripts\edgecounttest.txt
-------
edges: 13
-------
Edge: 1 Point1: 0 Point2: 4
Edge: 2 Point1: 4 Point2: 6
Edge: 3 Point1: 2 Point2: 6
Edge: 4 Point1: 0 Point2: 2
Edge: 5 Point1: 1 Point2: 3
Edge: 6 Point1: 3 Point2: 7
Edge: 7 Point1: 5 Point2: 7
Edge: 8 Point1: 1 Point2: 5
Edge: 9 Point1: 2 Point2: 3
Edge: 10 Point1: 0 Point2: 1
Edge: 11 Point1: 4 Point2: 5
Edge: 12 Point1: 6 Point2: 7
Edge: 13 Point1: 0 Point2: 0
exit script "F:\anim8or_v097b_preview\scripts\edgecounttest.txt"
It appears that the last edge is from point 0 to point 0. You can probably work around this by just using GetNumEdges()-1. That is what I have done.