Start here …
Then study examples provided by the Trimble Development team and posted in their Extension Warehouse Store (Example Scripts, Shapes, Utilities Tools, etc.)
Also study open source extension by community members.
@thomthom (who now works for Trimble) created a vertex quantizer example some years ago, that may be beneficial for you to study. (It may have been posted over at the SketchUcation forums. Membership is free there.)