Tutorial - Mating HerringBone gear in SolidWorks?
Here is the tutorial.
Open the attached file. Click Mate.
Under mechanical mates click Gearmate.
Select the faces of the teeth.
We can see that SW has automatically analysed the teeth/diameter.
Click OK and the mate is generated.