For your first question, this list comprehension works:
pc = chunk.point_cloud
nselected = len([p for p in pc.points if p.selected])
Also, I'm pretty sure a neater way of accomplishing what you want is to use this:
chunk.buildPoints(error=threshold)
chunk.optimizeCameras()
And repeat it until the result is better. The perk of using this, apart from that it's shorter, is that statistical 'outliers' that were removed in previous stages could be reinstated if their errors are reduced to within the threshold.
This however raises a question of mine, which is what these iterations really accomplish? If my knowledge in the bundle adjustment (Camera Optimization) is correct, a similar thresholding is applied and only the points considered valid are used for deciding the orientation. Thus, by removing statistical outliers before, we're just doing the bundle adjustment's job.
Or am I wrong about that? I would love a word from the Agisoft team!
EDIT: Fixed the first script