Add automatic rendering at open file. Add dist() function to script API.