Jump to content

Recommended Posts

Posted

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"))

Posted (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 by Grrr
Posted
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

Posted
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)
 )

Posted

About as short as you can get it

 

(defun c:rre ( )
(command "polygon" "4" pause "c" (/ (getreal "enter dia") 2.0))
)

Posted

Problem solvered!! Cheers guys!

I'm gonna look into working this stuff out for myself one day.. :P

Posted
About as short as you can get it

 

(defun c:rre ( )
(command "polygon" "4" pause "c" (/ (getreal "enter dia") 2.0))
)

 

Much better BIGAL...

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.

Guest
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...