How to ask the court to DISMISS complaint by filing an answer

Rule 16, Sec. 6 governs the rule on pleading grounds as affirmative defenses. What happens when grounds for a motion to dismiss are pleaded as affirmative defenses?

If no motion to dismiss has been filed, any of the grounds for dismissal provided for in this Rule may be pleaded as an affirmative defense in the answer and, in the discretion of the court, a preliminary hearing may be had thereon as if a motion to dismiss had been filed.

The dismissal of the complaint under Sec. 6 shall be without prejudice to the prosecution in the same or separate action of a counterclaim pleaded in the answer.