Visual LISP, AutoLISP and General Customization
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Drawing a rectangle in lisp

11 REPLIES 11
Reply
Message 1 of 12
Anonymous
15613 Views, 11 Replies

Drawing a rectangle in lisp

I am trying to write a lisp that would prompt a user for height, width &
depth of a piece of equipment then draw 3 views of it. Simple rectangles are
needed. I'm trying to figure out how to do a relative distance like
@width,depth from a point picked. Can someone please help.

Thanks,

--
Erik D.
CAD Manager
Atkinson Industries, Inc.
620-231-6900
11 REPLIES 11
Message 2 of 12
Anonymous
in reply to: Anonymous

Here's a couple of helper routines I regularly use:

;;returns a point x,y from the "LASTPOINT" sysvar
(defun @PT (x y) (mapcar '+ (getvar "LASTPOINT") (list x y)))

;;returns a point x,y from the supplied point
(defun ADDPT (sp x y) (mapcar '+ sp (list x y)))
Message 3 of 12
Anonymous
in reply to: Anonymous

Sorry, Erik
I am so stupid...
What you mean about height, width &
depth of rectangle
Can you uppload some picture about what you need?
One more question: do you want to use this routine
with DCL or without it (with prompts in command line only)?

Fatty The Stupid Old Horse

>'J'<
Message 4 of 12
Anonymous
in reply to: Anonymous

Command prompt is fine for this. I want the lisp to prompt for the height,
width, depth of a piece of equipment & then draw 3 rectangles representing
the top view, side view & front view of the described piece of equipment.

--
Erik D.
CAD Manager
Atkinson Industries, Inc.
620-231-6900
wrote in message news:5392840@discussion.autodesk.com...
Sorry, Erik
I am so stupid...
What you mean about height, width &
depth of rectangle
Can you uppload some picture about what you need?
One more question: do you want to use this routine
with DCL or without it (with prompts in command line only)?

Fatty The Stupid Old Horse

>'J'<
Message 5 of 12
Anonymous
in reply to: Anonymous

Aha
That's make me sence about
no warranty, but I'll try to write something similar
on it

>'J'<
Message 6 of 12
Anonymous
in reply to: Anonymous

(defun c:drawrect ( / hgt width depth pt1 pt2 pt3 pt4 pt5 pt6 pt7)
(setq
hgt (getreal "\Height: ")
width (getreal "\Width: ")
depth (getreal "\Depth: ")
pt1 (getpoint "\nSelect start point: ");lower left corner of front
pt2 (polar pt1 0 width);lower right corner of front
pt3 (polar pt2 (* pi 0.5) hgt);upper right corner of front
pt4 (polar pt1 (* pi 0.5) (+ hgt 1.0));lower left corner of top
pt5 (polar pt2 (* pi 0.5) (+ hgt 1.0 depth));upper right corner of top
pt6 (polar pt1 0 (+ width 1.0));lower left corner of end
pt7 (polar pt3 0 (+ 1.0 depth));upper right corner of end
)
(command
".rectangle" pt1 pt3
".rectangle" pt4 pt5
".rectangle" pt6 pt7
)
(princ)
)

"Erik Deyo" wrote in message
news:5392845@discussion.autodesk.com...
Command prompt is fine for this. I want the lisp to prompt for the height,
width, depth of a piece of equipment & then draw 3 rectangles representing
the top view, side view & front view of the described piece of equipment.

--
Erik D.
CAD Manager
Atkinson Industries, Inc.
620-231-6900
wrote in message news:5392840@discussion.autodesk.com...
Sorry, Erik
I am so stupid...
What you mean about height, width &
depth of rectangle
Can you uppload some picture about what you need?
One more question: do you want to use this routine
with DCL or without it (with prompts in command line only)?

Fatty The Stupid Old Horse

>'J'<
Message 7 of 12
Anonymous
in reply to: Anonymous

Brilliant, thank you

--
Erik D.
CAD Manager
Atkinson Industries, Inc.
620-231-6900
"Jim Claypool" wrote in message
news:5392901@discussion.autodesk.com...
(defun c:drawrect ( / hgt width depth pt1 pt2 pt3 pt4 pt5 pt6 pt7)
(setq
hgt (getreal "\Height: ")
width (getreal "\Width: ")
depth (getreal "\Depth: ")
pt1 (getpoint "\nSelect start point: ");lower left corner of front
pt2 (polar pt1 0 width);lower right corner of front
pt3 (polar pt2 (* pi 0.5) hgt);upper right corner of front
pt4 (polar pt1 (* pi 0.5) (+ hgt 1.0));lower left corner of top
pt5 (polar pt2 (* pi 0.5) (+ hgt 1.0 depth));upper right corner of top
pt6 (polar pt1 0 (+ width 1.0));lower left corner of end
pt7 (polar pt3 0 (+ 1.0 depth));upper right corner of end
)
(command
".rectangle" pt1 pt3
".rectangle" pt4 pt5
".rectangle" pt6 pt7
)
(princ)
)

"Erik Deyo" wrote in message
news:5392845@discussion.autodesk.com...
Command prompt is fine for this. I want the lisp to prompt for the height,
width, depth of a piece of equipment & then draw 3 rectangles representing
the top view, side view & front view of the described piece of equipment.

--
Erik D.
CAD Manager
Atkinson Industries, Inc.
620-231-6900
wrote in message news:5392840@discussion.autodesk.com...
Sorry, Erik
I am so stupid...
What you mean about height, width &
depth of rectangle
Can you uppload some picture about what you need?
One more question: do you want to use this routine
with DCL or without it (with prompts in command line only)?

Fatty The Stupid Old Horse

>'J'<
Message 8 of 12
Anonymous
in reply to: Anonymous

As always I am late again....

Anyway, see this attempt

(defun c:3w ()
(setq l (getdist "\nLength: ")
w (getdist "\nWidth: ")
d (getdist "\nDepth: ")
gap (getdist "\Enter gap between views: ")
p (getpoint "\nSpecify lower left point: ")
)
(setq p1 p
p2 (list (+ (car p) l)(+(cadr p)w))
p3 (list (+ (car p2) gap)(cadr p1))
p4 (list (+ (car p2) gap d)(cadr p2))
p5 (list (car p1)(- (cadr p1) gap d))
p6 (list (car p2)(-(cadr p1) gap)))
(setvar "osmode" 0)
(setvar "cmdecho" 0)
(command "rectang" p1 p2
"rectang" p3 p4
"rectang" p5 p6)

(setvar "osmode" 703);your favourite osnap
(setvar "cmdecho" 1)
(princ)
)

Fatty

~'J'~
Message 9 of 12
ranjankarthik
in reply to: Anonymous

how to fill the rectangular with some objects like i am in solar field after drawing rectangular need to put the modules like dimension of 2x1m so please help

Message 10 of 12
Moshe-A
in reply to: ranjankarthik

@ranjankarthik ,

 

Just want to make sure, Are you aware that last time this thread was active is NOV 2006?

 

 

Message 11 of 12
ranjankarthik
in reply to: Moshe-A

No I was not. I need to fill the rectangular with array please let me know
how to do
Message 12 of 12
Kent1Cooper
in reply to: ranjankarthik


@ranjankarthik wrote:

how to fill the rectangular with some objects ….


This is a very different topic.  But before starting a new one, try some Searching -- similar questions have come up here before.

Kent Cooper, AIA

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report

”Boost