Create plane by dragging in viewport
So, are you wanting to draw a diagonal line and it generate a rectangle? You'll have to write a script for that by using the Pythagorean theorem. But you can't determine a rectangle knowing it's diagonal length only. You must also know the width to length ratio because one diagonal length can have infinite variations of a rectangle. So, unless you want a hard coded width to length ratio, every time you draw your line you'll have to employ the extra step of determining the ratio by determining the slope of the line on an XY coordinate.

Example:

(X,Y)+(X౽,Y౽)= diagonal line

(X౽,Y౽-Y) = Other X vertex

(X౽-X,Y౽)= Other Y vertex

(X,Y)+(X౽,Y౽)+(X౽,Y౽-Y)+(X౽-X,Y౽)= rectangle