afroze9 Posted February 12 Posted February 12 Hi. 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. RectMidPoint.lsp Quote
fuccaro Posted February 13 Posted February 13 (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! 1 Quote
afroze9 Posted February 13 Author Posted February 13 @fuccaro It works perfectly ! Much appreciated on the swift response. 1 Quote
fuccaro Posted February 13 Posted February 13 @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! Quote
fuccaro Posted February 13 Posted February 13 Oh, and I forgot the one modification I should have mention first: localize the variables! Quote
afroze9 Posted February 13 Author Posted February 13 Will definitely update as per these suggestions! Thanks again. Quote
BIGAL Posted February 13 Posted February 13 (edited) 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 February 13 by BIGAL Quote
pkenewell Posted February 14 Posted February 14 A Google search would show this has been done before several times. I like this dynamic example from Lee Mac. Quote
Recommended Posts
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.