CAD Forum ► EN ► AutoCAD ► LISP define the position of a rectangle
Show full version of the posting: LISP define the position of a rectangle
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!
Wouldn't that "D" be for "Dimensions? Why would you specify diameters if you are drawing rectangles? Makes no sense.
Sorry, my fault. It is stand for Dimensions.
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.
Thank you very much, it is works
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!
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.
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