Visual LISP, AutoLISP and General Customization
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

the "c" option in command

2 REPLIES 2
Reply
Message 1 of 3
derryck
291 Views, 2 Replies

the "c" option in command

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)
)
2 REPLIES 2
Message 2 of 3
hmsilva
in reply to: derryck


@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

 

 

EESignature

Message 3 of 3
Kent1Cooper
in reply to: derryck

[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.]

Kent Cooper, AIA

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report

”Boost