Help with getting my polyline script to use osnaps

hi I’m very new to scripting so ill be short. after about all night and into the morning I finally found a way to script the poly line tool just like in the program… because its the example that was given by rhino team… but the point is it works and it does use osnaps just not on the lines that are being generated from start of script use until you end the script. how ever running the script again lets you osnap to the prior polyline created from it but not during its creation any help would be appreciated.

import scriptcontext 
import rhinoscriptsyntax as rs
import math 
import System.Guid, System.Array, System.Enum 
#this is the code that the actuall tool in rhino acesses from but its not entirely the same
def AddPolyline(points, replace_id=None): 
     points = rs.coerce3dpointlist(points, True) 
     if replace_id: replace_id = rs.coerceguid(replace_id, True) 
     rc = System.Guid.Empty 
     pl = Rhino.Geometry.Polyline(points) 
     if replace_id: 
         if scriptcontext.doc.Objects.Replace(replace_id, pl): 
             rc = replace_id 
         rc = scriptcontext.doc.Objects.AddPolyline(pl) 
     if rc==System.Guid.Empty: raise Exception("Unable to add polyline to document") 
     return rc        
#And this is what draws the poly line
pointes = rs.GetPoints(True)
if pointes: rs.AddPolyline(pointes)

Never mind lol Figured it out… Got to love the command function in rhino function huh…