Auto Dimension Columns & Grids+ Tagging

I have a requirement to create an exactly similar script to automate dims to the column centre from the nearest grid line. Also dimension the length and width of each column. These happen without considerable overlap. Being a novice, I am unable to crack from this YouTube video. Looking for guidelines to start and get me going.