@pallen9JA6T wrote:
... when you repeat the command, it remembers the previously entered "max. dist", but will allow you to change if needed (similar to how the offset and the circle command works)?
Here's how I'd do that. I stayed with the Circles in the original image, and you can do the same kind of prompt and default for the radius of those if you want. Or if you really want them to be Points, or Blocks if that's what those Circles are, that's an easy adjustment.
(defun C:DIVDCM (/ cc1 cc2 range spcs spc)
; = DIVide Distance [not object] using Circles, at user-specified Maximum spacing
(initget (if *DIVDCmax* 6 7)); no zero, no negative, no Enter on first use
(setq
*DIVDCmax* ; global variable with routine-specific name
(cond
( (getdist ; returns nil on Enter when permitted
(strcat
"\nMaximum Circle spacing"
(if *DIVDCmax* (strcat " <" (rtos *DIVDCmax*) ">") "")
": "
); strcat
); getdist
); User-input condition
(*DIVDCmax*); prior value if present, on Enter
); cond & *DIVDCmax*
cc1 (getpoint "\nOne end of range: ")
cc2 (getpoint "\nOther end: ")
range (distance cc1 cc2)
spcs (+ (fix (/ range *DIVDCmax*)) (if (equal (rem range *DIVDCmax*) 0 1e-4) 0 1))
spc (/ range spcs)
); setq
(command "_.circle" "_none" cc1 0.125); assumption -- EDIT radius to your value
(repeat spcs
(command "_.circle" "_none" (polar (getvar 'lastpoint) (angle cc1 cc2) spc) 0.125)
); repeat
(princ)
); defun
The use of (getdist) [as opposed to (getreal) in @serag.hassouna' routine] means that you can also enter the distance by picking two points on-screen, or by typing in a distance involving feet, and/or fractions, none of which options are available with (getreal), which allows only an integer or decimal number.
The routine-specific variable name for that maximum distance is so that it's not likely to be replaced by the operation of any other AutoLisp routine. If, for example, it was called simply 'max,' that name might also be used in something else, and if you then came back to this, the default would be wrong. [The * before and after the name is just a convention some people use to distinguish global variable names. Sometimes I use one only before, some people use _ instead, etc. -- completely arbitrary and expendable.]
Kent Cooper, AIA