Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

AutoLISP: commands working inline, not in lisp

Status
Not open for further replies.

KoRUPT

Programmer
Jul 25, 2002
25
0
0
CA
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


 
My guess it is the "osnap" problem. Try running it with all your running osnaps disabled. You should disable the osnaps before the line: (command "_3dpoly" p0 p1 p2 p3 "c")
. One way is with (setvar 'osmode 0)
 
Thank you. It was the osnap problem.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top