Okay I made a small function that draws a 3d box by getting the bottom left corner, and then defining height, width and depth. It draws a _3dpoly then extrudes it to the proper depth. This function works most of the time but sometimes it messes up drawing the 3dpoly because of an unknown reason. Here is the Code:
(defun C:tmBox()
(setq orgin (getpoint "\nPick the lower left-hand corner of the cabinet: ")
(setq width (getdist "\nEnter the Width: ")
(setq height (getdist "\nEnter the Height: ")
(setq depth (getdist "\nEnter the Depth: ")
(setq p0 orgin)
(setq p1 (list (car p0) (+ (cadr p0) height) (caddr p0)))
(setq p2 (list (+ (car p0) width) (+ (cadr p0) height) (caddr p0)))
(setq p3 (list (+ (car p0) width) (cadr p0) (caddr p0)))
(command "_3dpoly" p0 p1 p2 p3 "c"
(setq e1 (entlast))
(command "extrude" e1 "" depth ""
"Enjoy your box"
)
Here is a test case that does not work. The first 2 boxes draw properly, but the third doesnt. Here are the entries:
First Box:
Bottom Left Point: 0,0,0
Width: .5
Height: 10
Depth: 3
Second Box:
Bottom Left Point: 5,0,0
Width: -.5
Height: 10
Depth: 3
Third Box (this one fails to draw properly):
Bottom Left Point: .5,0,0
Width: 4
Height: .5
Depth: 3
The funny thing is, if I draw the third box first, it works. Also, if I draw the third box (after drawing the first 2) by using commands, rather than my function, the box is drawn properly. It is very confusing... Anyone know what is wrong?
PS: Autocad version is 2002
(defun C:tmBox()
(setq orgin (getpoint "\nPick the lower left-hand corner of the cabinet: ")
(setq width (getdist "\nEnter the Width: ")
(setq height (getdist "\nEnter the Height: ")
(setq depth (getdist "\nEnter the Depth: ")
(setq p0 orgin)
(setq p1 (list (car p0) (+ (cadr p0) height) (caddr p0)))
(setq p2 (list (+ (car p0) width) (+ (cadr p0) height) (caddr p0)))
(setq p3 (list (+ (car p0) width) (cadr p0) (caddr p0)))
(command "_3dpoly" p0 p1 p2 p3 "c"
(setq e1 (entlast))
(command "extrude" e1 "" depth ""
"Enjoy your box"
)
Here is a test case that does not work. The first 2 boxes draw properly, but the third doesnt. Here are the entries:
First Box:
Bottom Left Point: 0,0,0
Width: .5
Height: 10
Depth: 3
Second Box:
Bottom Left Point: 5,0,0
Width: -.5
Height: 10
Depth: 3
Third Box (this one fails to draw properly):
Bottom Left Point: .5,0,0
Width: 4
Height: .5
Depth: 3
The funny thing is, if I draw the third box first, it works. Also, if I draw the third box (after drawing the first 2) by using commands, rather than my function, the box is drawn properly. It is very confusing... Anyone know what is wrong?
PS: Autocad version is 2002