Jump to content

LISP routine for Rectangle from Center using Dimensions with specific Angle.


Recommended Posts



I am complete newbie to AUTOCAD lisp routines. Been scouring the forums for this specific routine.

Need to draw a rectangle with center as the starting point then input the dimensions & lastly set the rotation angle.


Have found this routine online (attached below) but it doesn't include rotation specification. Any help would be appreciated.



Link to comment
Share on other sites

(defun c:pp()
  (setq c (getpoint "center point ")
	a (getdist "side1 ")
	b (getdist "side2 ")
	rot (getangle "rotation? ")
  (setq angs (list (setq ang1 (atan b a)) (- PI ang1 )(+ PI ang1) (- ang1))
	l (* 0.5 (sqrt(+ (* a a) (* b b))))
	plist nil
	i -1)
  (repeat 4
    (setq plist (cons (cons 10 (polar c (+ rot (nth (setq i (1+ i)) angs)) l)) plist)))
  (entmake (append (list  '(0 . "LWPOLYLINE")(cons 100 "AcDbEntity") (cons 100 "AcDbPolyline") '( 90 . 4) '(70 . 1)) plist))

See here a quick one. It could be improved a lot

Welcome in the forum!

  • Like 1
Link to comment
Share on other sites

@afroze9 Thanks for the appreciation.

You could change the name to a relevant one. Also *you* could add some functionalities. If the user enters a value for the first side, that value could be offered as default for the next input. If you need a square, at the second side just press enter and the second side will be like the first one.

Also if the desired rotation angle is zero, you could press just enter - zero should be the default value.

We would be happy to see your progress! :)

Link to comment
Share on other sites

Multi GETVALS.lspLook into using my Multi getvals.lsp for input as fuccaro has suggested can have default values preset, like angle at 0.0. Can save the values in current session so next time ran they will be the default values, but maybe a different angle etc.



Edited by BIGAL
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Create New...