The research was carried out in order to identify the optimal structural schemes of three-dimensional five- and six-link mechanisms with rotational pairs, which reproduce with the required accuracy a linear function during oscillatory and rotational motion of the output link. Spatial mechanisms, which are used as transmission and base mechanisms, make it possible to recreate the movement of the output or any working link with a given accuracy and provide the necessary rigidity, reliability and compactness of the structure. The synthesis of spatial mechanisms was carried out according to the given law of the output link. To implement oscillatory motion with working sections on the forward and reverse stroke, you can use crank-rocker five-links, in which the angles of crossing of the geometric axes of the hinges of adjacent links 4 and 5 are equal to . In a similar way, the synthesis of a spatial five-link was carried out, in which the angles of crossing the axes of the hinges of the output link α_4 and the rack α_5 are related by the dependence α_4= , by reproducing the oscillatory motion of the output balancer with the working stroke in a straight section. Optimal structural schemes of three-dimensional five- and six-link mechanisms are revealed, which reproduce with the required accuracy a linear function during the oscillatory and rotational motion of the output link. The resulting dependencies will be used to automate the optimization synthesis for the objective function of the six-link mechanism (or its five-link modification), which reproduces a linear function on a certain part of the turn of the output link with its full cranking