Here's a way to do it in which:
1. A single default distance is available in all commands -- if you want to go left by a distance you just went right, so the default is positive X, you don't need to re-enter the same distance with a preceding minus sign, but can just use the leftward command and the same default distance.
2. You don't even need to know that X values are in the left-right direction and Y in the up-down directions, nor which way is positive and which negative in each direction -- it uses [abbreviations for] Up/Down/Left/Right as directions you want to Move or Copy things.
3. They work with pre-selection [noun-verb mode] if there is one; otherwise they ask you to select objects.
4. The "heavy lifting" is spelled out only once, instead of most of it repeatedly within multiple command definitions. The different commands just feed a couple of arguments to the one sub-routine.
5. [I don't see any reason it should be restricted to whole-number values -- these accept decimals, fractions, feet-and-inches.]
(defun MorCO (MorC dir / dirs ss) ; = Move or Copy Orthogonally
(initget 2); no zero
(setq
dirs '((0.5 "up") (1.5 "down") (1 "left") (0 "right")); directions as multiples of pi
*MorCdisp* ; global variable [Move or Copy displacement, in drawing units]
(cond
( (getdist
(strcat
"\nDistance to " MorC " object(s) " (cadr (assoc dir dirs)) " <"
(rtos (cond (*MorCdisp*) (100))); in current mode/precision <--EDIT desired initial default
">: "
); strcat
); getdist
); User-entry condition
(*MorCdisp*); prior value if present, on Enter
(100); default on Enter at first use <--EDIT desired initial default
); cond
); setq
(cond
((setq ss (ssget "_:L-I")); pre-selection of object(s) not on locked Layer(s)
(sssetfirst nil); un-select [now in ss variable]
); pre-selection condition
((setq ss (ssget "_:L"))); no pre-selection -- ask User
); cond
(command (strcat "_." MorC) ss "" "_displacement" (polar '(0 0) (* pi dir) *MorCdisp*))
(prin1)
)
(defun C:MMU () (MorCO "Move" 0.5)); = Move Up
(defun C:MMD () (MorCO "Move" 1.5)); = Move Down
(defun C:MML () (MorCO "Move" 1)); = Move Left
(defun C:MMR () (MorCO "Move" 0)); = Move Right
(defun C:CCU () (MorCO "Copy" 0.5)); = Copy Up
(defun C:CCD () (MorCO "Copy" 1.5)); = Copy Down
(defun C:CCL () (MorCO "Copy" 1)); = Copy Left
(defun C:CCR () (MorCO "Copy" 0)); = Copy Right
I used command names with double M's or C's before the directional letters, because ML is already AutoCAD's default command alias for MLINE, and I use CL and CR for other things. But you can use whatever command names make sense for you.
Kent Cooper, AIA