Top players position (32 for Grand Slam Tournaments) are determined by official rankings then other players who enter directly in the main draw are drawn.
So is it possible that the 33rd players (if all the first 32 take part to the Grand Slam) is raffled to play the first round versus draw numer 1.
Here the video of the draw of Australian Open 2016
This rule applies to every tournaments, Grand Slam and minor ones.
In the main draw there are also free slot assigned by tournaments directors (Wild Cards) and for qualifing. Tennis players that do not enter directly in the main draw for rankings can play the qualification. The qualification draws are managed in the same way.
In Auckland 2016 draw you can see that the "last" tennis player direct acceptance (no qualification needed) in Mariana Duque-Marino (ranking 78th), there are 4 slot for qualification players and 2 Wild Cards.
In the past was the ranking rules was not followed so closely: maybe there are players strong on grass and weak on clay so there where a bit of adjustments, but this way generate many controversy so now it is followed the "rankings rules".