If you take a look the following bit of code, which is created to be able to draw a rectangle, I just want to know what the "c" option does to the line function so that a rectangle is drawn?
(defun c:retan (/ pl p2 p3 p4) (setq pl (getpoint "\nfirst corner of rectangle: ")) (setq p3 (getcorner "\nsecond corner of rectangle: ")) (setq p2 (list (car pl)(cadr p3))) (setq p4 (list (car p3)(cadr pl))) (command "line" pl p2 p3 p4 "c") (princ) )
@derryck wrote:
If you take a look the following bit of code, which is created to be able to draw a rectangle, I just want to know what the "c" option does to the line function so that a rectangle is drawn?
(defun c:retan (/ pl p2 p3 p4) (setq pl (getpoint "\nfirst corner of rectangle: ")) (setq p3 (getcorner "\nsecond corner of rectangle: ")) (setq p2 (list (car pl)(cadr p3))) (setq p4 (list (car p3)(cadr pl))) (command "line" pl p2 p3 p4 "c") (princ) )
Hi,
the "c" in the line command is to close, it will draw a line from the last drawn end point, to the first drawn start point.
But your code will fail, at the getcorner function you'll have to supply the start corner pt
(setq p3 (getcorner pl "\nsecond corner of rectangle: "))
Using the command function, you'll have to ensure that the OSMODE settings, will not interfere with the desired points, setting OSMODE to 0, or using an osnapmode "_non"...
i.e.
(defun c:retan (/ p1 p2) (if (and (setq p1 (getpoint "\nfirst corner of rectangle: ")) (setq p2 (getcorner p1 "\nsecond corner of rectangle: ")) );; and (command "_.line" "_non" p1 "_non" (list (car p1) (cadr p2)) "_non" p2 "_non" (list (car p2) (cadr p1)) "_c") );; if (princ) )
Henrique
[Consider also, in this case, just using the RECTANGLE command (or just RECTANG or even just REC aliases). It draws the same in a Polyline, which has several advantages over four separate Lines, and it has options such as chamfering or filleting the corners as it's drawn, width, etc.]