Simple, but with some possible drawbacks, depending on what the original
poster wants:
- requires (or allows, if that's preferable) the user to tell it how long to
make the lines, which can be automated to save a step if they have a
standard amount of extension;
- puts the lines on whatever layer is current (which could be for plumbing
fixtures, for all anyone can predict), so you might have such centerlines on
any number of layers in the same drawing;
- forces the linetype (but not the color -- wouldn't that be appropriate,
too?), so if you decided to change the linetype of all such lines, you
couldn't do it by changing the linetype of the layer they're on -- you'd
have to select them all.
- assumes the Units angle setting is for degrees.
[By the way, numerical input inside (command) functions doesn't need
quotation marks around it -- that makes it into text strings, which happens
to work as answers to these prompts, but it isn't necessary.]
It also makes a bunch of variables that aren't really needed. Instead of
saving a variable that's only going to be used once, I usually prefer to
just calculate the value where it will be used. Just a matter of
preference, perhaps, but it could be shortened a lot:
(defun C:CA (/ pt1 d1)
(setq pt1 (cdr (assoc 10 (entget (car (entsel "\nSelect circle: "))))))
(setq d1 (getdist pt1 "\nLength of line: "))
(command "line" (polar pt1 0.0 d1) (polar pt1 PI d1) "")
(command "chprop" "l" "" "lt" "center" "")
(command "array" "l" "" "P" pt1 2 90 "")
)
Or you could draw the line across and back in the line command, and then
rotate the last one 90 degrees. Or you could copy the first line in place,
and rotate the last one. Or you could use the little-known and I think
no-longer-documented Circular array option, which asks for an angle between
items rather than an angle to fill (except as a later option):
(command "array" "l" "" "C" pt1 90 2 "Y")
or
(command "array" "l" "" "C" pt1 90 -90 "Y")
[check out its prompts]
Or you could....
--
Kent Cooper
wrote...
Try this out.
(defun C:CA (/ x ent pt1 d1 p1 p2)
(setq x (entsel "\nSelect circle: "))
(setq ent (car x))
(setq pt1 (cdr (assoc 10 (entget ent))))
(setq d1 (getdist pt1 "\nLength of line: "))
(setq p1 (polar pt1 0.0 d1))
(setq p2 (polar pt1 PI d1))
(command "line" p1 p2 "")
(command "chprop" "l" "" "lt" "center" "")
(command "array" "l" "" "P" pt1 "2" "90" "")
)