masterfal Posted October 24, 2016 Posted October 24, 2016 Hi All, I've got this simple lisp made up which draws a square from a center-point. I find this quite handy because alot of the time i need to draw a pad central to a column and using the normal rectangle command, it doesn't let you create it from a center-point, which is a bit annoying. Autocad should have that as an option.. Anyway, the only thing with it is that if i need a 800sq pad for example, i need to enter 400 because it requests 'radius' size. Is it possible to modify it so if i need 800sq i can just enter 800? If its pretty simple i'd like to do it but if not i can continue to halve my pad sizes and do it that way (defun c:rre () (command "polygon" "4" pause "c")) Quote
Grrr Posted October 24, 2016 Posted October 24, 2016 (edited) Explore this thread: http://www.cadtutor.net/forum/showthread.php?96834-Draw-a-square EDIT: Or try this: (defun C:test ( / d AcSpc p CircleObj p1 p3 ll ur ) (initget (+ 1 2 4)) (setq d (getreal "\nSpecify square's size: ")) (setq AcSpc (vlax-get-property (vla-get-ActiveDocument (vlax-get-acad-object)) (if (= 1 (getvar 'CVPORT)) 'Paperspace 'Modelspace))) (setvar 'errno 0) (while (/= 52 (getvar 'errno)) (initget 128 "Size") (setq p (getpoint "\nSpecify square's center point or [size]: ")) (cond ((and (= 'STR (type p)) (wcmatch p "S*")) (initget (+ 1 2 4)) (setq d (getreal "\nSpecify square's size: "))) ((and p (listp p)) (setq CircleObj (vla-AddCircle AcSpc (vlax-3D-point p) (/ d 2.))) (vla-GetBoundingBox CircleObj 'll 'ur) (mapcar 'set '(p1 p3) (mapcar 'vlax-safearray->list (list ll ur))) (entmake (append (list (cons 0 "LWPOLYLINE")(cons 100 "AcDbEntity")(cons 100 "AcDbPolyline")(cons 90 4)(cons 70 1)) (mapcar '(lambda (x) (cons 10 x)) (list p1 (list (car p1) (cadr p3)) p3 (list (car p3) (cadr p1)))) ) ) (vla-Delete CircleObj) ) (T (setvar 'errno 52)) ) ) (princ) );| defun |; (or (vlax-get-acad-object) (vl-load-com)) (princ) Edited October 24, 2016 by Grrr Quote
RobDraw Posted October 24, 2016 Posted October 24, 2016 Hi All, I've got this simple lisp made up which draws a square from a center-point. I find this quite handy because alot of the time i need to draw a pad central to a column and using the normal rectangle command, it doesn't let you create it from a center-point, which is a bit annoying. Autocad should have that as an option AutoCAD does have this option. POLYGON Quote
PDuMont Posted October 24, 2016 Posted October 24, 2016 Hi All, I've got this simple lisp made up which draws a square from a center-point. I find this quite handy because alot of the time i need to draw a pad central to a column and using the normal rectangle command, it doesn't let you create it from a center-point, which is a bit annoying. Autocad should have that as an option.. Anyway, the only thing with it is that if i need a 800sq pad for example, i need to enter 400 because it requests 'radius' size. Is it possible to modify it so if i need 800sq i can just enter 800? If its pretty simple i'd like to do it but if not i can continue to halve my pad sizes and do it that way (defun c:rre () (command "polygon" "4" pause "c")) (defun c:rre ( / dia ) (setq dia (getreal "\nEnter diameter... ")) (setq dia (/ dia 2)) (command "polygon" "4" pause "c" dia) (princ) ) Quote
BIGAL Posted October 25, 2016 Posted October 25, 2016 About as short as you can get it (defun c:rre ( ) (command "polygon" "4" pause "c" (/ (getreal "enter dia") 2.0)) ) Quote
masterfal Posted October 25, 2016 Author Posted October 25, 2016 Problem solvered!! Cheers guys! I'm gonna look into working this stuff out for myself one day.. Quote
PDuMont Posted October 25, 2016 Posted October 25, 2016 About as short as you can get it (defun c:rre ( ) (command "polygon" "4" pause "c" (/ (getreal "enter dia") 2.0)) ) Much better BIGAL... 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.