@Anonymous wrote:
I never heard of grread. Yeah this looks complicated. I'll look into grread. Thank you.
It was kind of complicated to get the pieces together, but this seems to work. It is written to draw Lines specifically, Locked to the 45-degree-Increment directions. The same principle could be applied to a Polyline if of only line segments and without getting into options, and with some modification could probably be made into a function that could be applied in things like Move and Copy.
End the drawing of Lines with it by hitting Enter or space [or, really, with any typed character], not with ESCape. [You can hit ESCape, but will need to again, or hit another Enter -- there may be a way to get around that limitation.]
The trickiest part turned out to be that neither (grdraw) nor the picking of a point under (grread) honors Ortho mode, so I had to figure out how to calculate what the Ortho-ized position in relation to the previous point and the cursor would be.
(defun C:LL45I (/ done cur pt); = Lines Locked to 45-degree angle Increments
(command "_.line" pause)
(while (not done)
(setq cur (grread T 13 0))
(cond
((= (car cur) 5); move cursor
(setvar 'snapang ; nearest 45-degree increment to cursor location
(* (/ pi 4) (fix (+ (/ (angle (getvar 'lastpoint) (cadr cur)) (/ pi 4)) 0.5)))
); setvar
(redraw); eliminate previous rubber-band
(grdraw ; rubber-band
(getvar 'lastpoint) ; from
(setq pt
(inters ; Ortho-ized location
(getvar 'lastpoint) (polar (getvar 'lastpoint) (getvar 'snapang) 1)
(cadr cur) (polar (cadr cur) (+ (getvar 'snapang) (/ pi 2)) 1)
nil
); inters
); setq
(cdr (assoc 62 (tblsearch "layer" (getvar 'clayer))))
); grdraw
); cur=5 condition
((= (car cur) 3) (command pt)); picked a point -- use Ortho-ized one
((= (car cur) 2) (command "") (redraw) (setq done T))
; keyboard input [typically Enter/space, but any other than Esc]
); cond
); while
(setvar 'snapang 0); return to normal
(princ)
); defun
Another possible "improvement," if you think it would be one, would be to use (grdraw) or (grvecs) to add the extra crosshair directions [an 8-armed cursor star], so that as with regular Ortho, all the locked-in directions would show in the crosshairs. Then the look of the crosshairs wouldn't pop back and forth between the 45's and the 90's as you move the cursor around, the way it does in this routine, but that might be a bit much, visually.
Kent Cooper, AIA