Display full version of the post: LISP define the position of a rectangle

lumpy92
29.06.2017, 14:19
Hi all!I try to write an autoLISP execution.I need to draw rectangles with it. After I define the first point, I send "d" (diameters dimensions), then I send the numbers for it's height and width. But at the end, I need to select it's position with the cursor.My question is: is there any possible way, to do that WITHOUT the cursor? I want it to draw it into the right bottom position every time (and write it into my LISP code).Thank you for your suggestions!

lumpy922017-06-29 15:07:14

John Connor
29.06.2017, 15:01
Wouldn't that "D" be for "Dimensions?  Why would you specify diameters if you are drawing rectangles?  Makes no sense.

lumpy92
29.06.2017, 15:06
Sorry, my fault. It is stand for Dimensions.

Kent Cooper
29.06.2017, 19:54

Simple example, lightly tested:(defun C:TEST () (command "_.rectang" pause "_d" 15 10 (polar (getvar 'lastpoint) (* pi 1.75) 10))) The red part will feed in a point always in the right-bottom-ward direction.  Adjust the blue parts to suit your needs, or use pauses for the first two, if you want to give it different sizes each time.

lumpy92
03.07.2017, 15:49
Thank you very much, it is works 

lumpy92
03.07.2017, 16:05
Could you explain me what is the difference between ._rectangle and _rectangle?Why is the dot is necessary? Both of them works for me.Thanks!

John Connor
04.07.2017, 13:27
Adding the "dot" before a command name ensures that the generic AutoCAD command will be used instead of one that might be substituted (or missing) by virtue of the command having been undefined.

Kent Cooper
05.07.2017, 18:48

Another way to do it, that uses the RECTANG command without the Dimensions option, but rather by calculating the opposite corner in the right-bottom-ward direction: (defun C:RULS (/ UL xdim ydim); = Rectang from Upper Left by specifying Size  (setq    UL (getpoint "\nUpper Left corner: ")    xdim (getdist "\nHorizontal size: ")    ydim (getdist "\nVertical size: ")  )  (command "_.rectang" UL (mapcar '+ UL (list xdim (- ydim))))  (princ)) An advantage is that the prompts are clearer about what is being asked for.  I can never remember which direction they mean for "length" and "width" in RECTANG's Dimension-option prompts, and I can easily get it wrong because I think of "width" as being horizontal, but they use "length" for the horizontal size and "width" for what I would prefer to call "height." 
Kent Cooper2017-07-05 18:52:48