I have modified your code a little bit. fixo started you off pretty well though.
Code:
(defun c:foo (/ pt1 box boxangle offset X_val Y_val Z_val New_X_Val pt1 pt2 )
(setq box (entsel "\nSelect box: "))
(if (/= box nil); <---- added only do something if an object is selected, otherwise do nothing
(progn
(setq pt1 (getpoint "\n Base: "));This gets the basepoint of the object
(setq boxangle 10);next box rotation<---------;"angle" changed to "boxangle" ("angle" is a function in lisp)
(setq offset (getreal "\n Offset: ")); distance to place second box
(setq X_val (car pt1))
(setq Y_val (cadr pt1))
(setq Z_val 0.0)
(setq New_X_Val (+ X_val offset))
(setq pt2 (list New_X_val Y_val Z_val))
(command ".COPY" box "" pt1 pt1 ""); This copies the entity (box);<-------------added destination for copy
(command "ROTATE" (entlast) "" pt1 boxangle ""); This rotates the object (entlast)
(command ".MOVE" (entlast) "" pt1 pt2); This moves the object<--- added end of selection ""
));end of if statement
(princ)
);end of defun boxcopyrot