A few things I notice....
Your checks on the dimensions where they are first entered are really not needed, since their value is checked again later to decide whether to draw and Rotate the rectangle. [And I would avoid using the word "plot" for the drawing of it, since that has a specific and different meaning in AutoCAD.] But even if you have reason to check them initially, the checks don't do anything differently if the tests are satisfied than if they are not -- the W1 and H1 values remain whatever was entered, regardless. You could structure them differently, e.g.:
(setq W1 (if (<= W1 15) W1))
That will wipe W1 out [set it to nil] if it's too big, because the (if) function will return nil. Then, to verify valid values later, it would need to check merely whether both values exist at all, rather than whether they're within range:
(if (and W1 H1)
(progn
(command .....
But I would suggest a different approach: check whether the value is within range, and if not, ask the User again to enter a valid value, and keep asking until they do:
(while
(not
(and
(setq W1 (getdist "\n Enter the width of the rectangle: "))
(<= W1 15)
); and
); not
(prompt "\nValue must be no greater than 15.")
); while
Other possibilities: you could make it forbid the specifying of 0 or a negative value [read about (initget)], but maybe you want the possibility of negative values to build the rectangle from upper right instead of from lower left.
For the angle of Rotation, I would suggest using (getangle) rather than (getreal), because the User has several additional options for specifying it that (getreal) won't accept. They can pick two points on-screen, or they can type in something like 125d32'11", or (atan 0.5) [look into the (atan) function]. However, that will mean the value in A1 will be in radians, so that will need to be converted to degrees in the Rotate command.
For the drawing of the rectangle, you can use the RECTANGLE [or just RECTANG] command with two opposite corners, rather than calculating all four corners and using PLINE. The result will be a Polyline anyway. [It can be done with only the PT1 variable, not needing pt2/pt3/pt4, but I'll show it below using pt3, which can be calculated from PT1 without the intermediary of pt2, but another time....] Also, you can combine more than one command into one (command) function.
And if you're not going to turn running Object Snap off, it's good to put None Osnap before given points.
So, for example [untested]:
(if (and W1 H1 A1)
(command ; then
"_.rectang" "_none" PT1 "_none" pt3
"_,Rotate" "Last" "" "_none" PT1 (* (/ A1 pi) 180)
); command
); if
But in reality, if you force the User to give valid values, there should be no need to test whether they're there, because it won't get that far without them.
Kent Cooper, AIA