Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

rectangle lisp

1,063 views
Skip to first unread message

Steve Preslin

unread,
Jan 15, 1998, 3:00:00 AM1/15/98
to

Hi,
I'm looking for a simple lisp routine that draws a rectangle with a
start point, and length and width.

Thanks in advance,
Steve

BG

unread,
Jan 16, 1998, 3:00:00 AM1/16/98
to

Try rectang (acad command). It requires corner to corner coordinates.
You can enter them either relative or absolute.

Ian A. White

unread,
Jan 17, 1998, 3:00:00 AM1/17/98
to

On Thu, 15 Jan 1998 22:22:14 -0600, Steve Preslin
<sxp...@mail.netnitco.net> wrote:

>Hi,
>I'm looking for a simple lisp routine that draws a rectangle with a
>start point, and length and width.

Why not use the standard RECTANG function and after picking the first
corner, use relative co-ordinate input to specify the second point.

For example, if you want a rectangle 500 x 1000, you would have to
enter @500,1000 in response to the second corner. No additional
AutoLISP needed.


--

Regards,

Ian A. White, CPEng
WAI Engineering
Sydney 2000
Australia

Ph: +61 418 203 229
Fax: +61 2 9622 0450

Junk e-mail will be returned, as is, to the sender's host system.

Tom Berger

unread,
Jan 17, 1998, 3:00:00 AM1/17/98
to

Steve,

This would be a very good starting point to learn AutoLISP. Even as an
absolute novice you will be able to write the requested function.

Start with what you have:
startpoint - from (getpoint "enter point: ")
length - from (getdist startpoint "enter length: ")
width - from (getdist startpoint "enter width: ")
and then calculate the points:
P1 = startpoint
P2 = X of startpoint + length, Y of startpoint
P3 = ...
and so on, and the draw what you have to:
(command "_line" p1 p2 p3 p4 "_cl")

Forgive me not give you the working AutoLISP code - I'm a teacher!

Tom Berger

Steve Preslin wrote:

> Hi,
> I'm looking for a simple lisp routine that draws a rectangle with a
> start point, and length and width.
>

> Thanks in advance,
> Steve

--
******************************************
* Tom Berger
* tbe...@architektur.uni-kassel.de
******************************************
* Universität Gh Kassel
* FB Architektur
* Henschelstr. 2
* D-34127 Kassel
* Tel +49 (0)561 804 2352 Fax ~3267
******************************************
* privat:
******************************************
* Pfannkuchstr. 17
* D-34121 Kassel
* Tel +49 (0)561 73 91 152
* Fax +49 (0)561 73 91 151
******************************************

Michael Mauldin

unread,
Jan 18, 1998, 3:00:00 AM1/18/98
to

Try this. It will draw arectangle by length and width with a stariting
point or by two pick points.

(defun C:RECTLINE (/ pt1 pt2 pt3 pt4 oldbw oldbh)
(initget "Width")
(setq pt1 (getpoint "\nFirst corner or Width/Height <Width/Height>: "))
(if (not pt1) (setq pt1 "Width"))
(cond ((/= pt1 "Width")
(while pt1
(setq pt3 (getcorner pt1 " Other corner: "))
(setq pt2 (list (car pt3) (cadr pt1)))
(setq pt4 (list (car pt1) (cadr pt3)))
(setq os (getvar "osmode")) (setvar "osmode" 0)
(command "LINE" pt1 pt2 pt3 pt4 "C")
(setvar "osmode" os)
(setq pt1 (getpoint "\nFirst corner: "))
)
)
((= pt1 "Width")
(if bw (setq oldbw bw) (setq oldbw 0.5))
(initget 2)
(setq bw (getdist (strcat "\nRectangle width <" (rtos oldbw)
">:")))
(if (not bw) (setq bw oldbw))
(if bh (setq oldbh bh) (setq oldbh 0.5))
(initget 2)
(setq bh (getdist (strcat "\nRectangle height <" (rtos oldbh)
">:")))
(if (not bh) (setq bh oldbh))
(while
(setq pt1 (getpoint "\nIndicate reference corner of box: "))
(setq pt2 (list (+ (car pt1) bw) (cadr pt1)))
(setq pt3 (list (+ (car pt1) bw) (+ (cadr pt1) bh)))
(setq pt4 (list (car pt1) (+ (cadr pt1) bh)))
(setq os (getvar "osmode")) (setvar "osmode" 0)
(command "LINE" pt1 pt2 pt3 pt4 "C")
(setvar "osmode" os)
)
)
)
(prin1)
)

Steve Preslin <sxp...@mail.netnitco.net> wrote in article
<34BEE0...@mail.netnitco.net>...

Robbie Creamer

unread,
Jan 19, 1998, 3:00:00 AM1/19/98
to sxp...@mail.netnitco.net

Steve,

Below find two routines, BX and BXEX. BX is the simple routine you
asked for, pick two points and bang, you're done, but if you are drawing
rectangles at an angle you'll want to use BXEX which will let you set
the base angle then draws a rectangle at that angle, I wrote this for a
member of our users group to use this for simple house footprints. Hope
you find them useful, you'll probably get tons of responses for this
request, rectangles are simple to draw, BX was one of the first routines
I ever wrote. If you don't know how to set lisp routines up for
automatic load/run, e me back and I'll send the syntax, or if you have
any questions about routines, let me know.

Robbie Creamer


;draws a rectangle w/ bottom axis at 0d
;rbc late '89
;updated rbc 9-91
(defun c:BX ( / PT DPT) ;name &
local vars
(setq PT (getpoint "\nStarting corner: ")) ;1st point
(setq DPT (getcorner pt "\nDiagonal corner: ")) ;diagonal point
(command "pline" PT ".x" DPT ".y" PT ;draw with x-y
filters
DPT ".x" PT ".y" DPT "C") ;and two
points
)
;end defun


;draws rectangle with bottom axis at any angle
;asks for angle, then base and height (length by pic or #)
;rbc 9-91
(defun c:BXEX ( / SNO ORO PT1 AG1 BASE HITE AG2 PT2 PT3 PT4) ;start
defun declar local variables
(graphscr) ;make
sure we are at the graphic screen
(if (/= 0 (setq ORO (getvar "orthomode")))(setvar "orthomode" 0))
;test/set orthomode
(setq SNO (getvar "snapang") ;get current snapangle
PT1 (getpoint "\nStarting corner: ")) ;get starting corner
(if (= nil (setq AG1 (getorient PT1 "\nAngle for base <0> ")))
;set/test AG1, if AG1 is nil then
(setq AG1 0) ) ;set AG1 to 0, end if
(setvar "snapang" AG1) ;set snapang to AG1, whatever it is
(setvar "orthomode" 1) ;turn orthomode on for height
(setq BASE (getdist PT1 "\nBase: (point or #) ") ;get length of base
by point or number input
HITE (getdist PT1 "\nHeight: (point or #) ") ;get length of height by
point or number input
AG2 (+ AG1 (dtr 90)) ;set angle of height, add 90 degrees to
AG1
PT2 (polar PT1 AG1 BASE) ;calc point2 based on angle & length of
base
PT3 (polar PT2 AG2 HITE) ;calc point3 based on angle & length of
height
PT4 (polar PT1 AG2 HITE)) ;calc point4 based on angle & length of
height
(command "pline" PT1 PT2 PT3 PT4 "C") ;draw the rectangle at exact
angle/width/height
(setvar "orthomode" ORO)(setvar "snapang" SNO) ;reset orthomode &
snapangle
) ;end the function

R.K. McSwain

unread,
Jan 20, 1998, 3:00:00 AM1/20/98
to

how about this:

rectang
(pick point here)
@length,width

0 new messages