cross component with cut-out

How to cross component with cut-out

Exemple in an Assembly with mortise and tenon, I would like to cut automatically the table legs according to the tenon size and location. It looks that in Solidworks, there is a cavity function to to that.