Thread cutting script - WIP

 From:  Martin (MARTIN3D)
5451.22 In reply to 5451.20 
Sorry for asking again but here's another obstacle:

This script
code:
script: 
/*draw cylinder*/
var factory = moi.command.createFactory( 'cylinder' );
factory.setInput( 1, moi.vectorMath.createFrame() );
factory.setInput( 3, 20 );
factory.setInput( 4, moi.vectorMath.createPoint( 0, 0, 40 ) );
factory.commit();

moi.geometryDatabase.selectAll();

/*chamfer edges*/
factory = moi.command.createFactory( 'chamfer' );
factory.setInput( 0, moi.geometryDatabase.getSelectedObjects() );
factory.setInput( 3, 1 );
factory.setInput( 4, 1 );
factory.commit();

chamfers both ends of the cylinder.

How do I persuade the above script to chamfer just one end?
Input 2 of the factory is a corners list according to the Morrill documentation. You showed me how to select vertex points and that this list actually contains boolean switches. Here I have to select surfaces or Breps, correct?