Excellent code.
How do i get lisp to store the value of the co-ordinates of the first point i click on when I am setting the length and widths.
You don't with GETDIST. If you're using that function, you'll need to have the user specify lower-left corner of room or something like that.
CAB, the GETxxx functions do not store input points in LASTPOINT.
However, there is a way to emulate GETDIST and get both points and distance. If you look up GETPOINT in the help files, you'll notice that it accepts an optional point as argument - as well as the normal prompt argument. That point is used for dragging a rubber-band just like GETDIST.
Try this out:
(defun getdrag ()
(if (setq pt1 (getpoint "\nInput length of room: "))
(if (setq pt2 (getpoint pt1 "Specify second point: "))
(distance pt1 pt2)
)
)
)
This will store the start point, anchor to it when storing the end point and calculate the distance between the points. The reason for the two IF's is that the second GETPOINT will fail if pt1 is nil and that DISTANCE will fail if both points didn't get assigned.
Result is that the user won't notice a difference which method is used. BUT, there is a problem. If the user types a number at the command line, it will anchor at LASTPOINT and attempt to retrieve a second point. Not good.
There is no easy way to tell if GETPOINT recieved a number or a point (I think? umm) - in both instances it will return a point. But we can try to setup GETPOINT to recieve an arbitrary input. This means that typing a distance will be returned as a string, so we'll have to convert it to a number. It also means that if the user inputs anything else than a number, it'll have to be discarded. INITGET 128 allows for arbitrary input and DISTOF does the conversion (or returns nil if not):
(defun getdrag ()
(initget 128)
(if (setq pt1 (getpoint "\nInput length of room: "))
(progn
(if (listp pt1)
(if (setq pt2 (getpoint pt1 "Specify second point: "))
(setq dist (distance pt1 pt2))
)
)
(if (= (type pt1) 'STR)
(setq dist (distof pt1))
)
)
)
dist
)
Of course, the final comment is that you'll have to discard all of the above because what if the user do not click in the rooms corners but merely points out a distance in the screen somewhere??
Back to square one. Either get length/width AND a corner - or specify that the user NEEDS to click in the corners of the room.