This paper is discussing about optimal synthesis of mechanisms for rectilinear motion. The synthesis of the mechanisms for rectilinear motion belongs to path generation. It has great importance in industrial application. The proposed mechanisms are based on Hoeken linkage and have some improvements. The optimal size proportions for linkages are obtained by genetic algorithms. Genetic algorithms revolve the size proportions to optimum by natural selection, selection, mating and mutation. The precision of rectilinearness in the result of the research is better than others for similar researches. The size proportions of linkages obtained in the paper can be directly applied to practical design. Genetic algorithm is a robust and efficient approach for optimal design of mechanisms.