Getdist - What is wrong?
What is wrong with this code?(setq pnt1 (getpoint "\nPoint 1"))(setq pnt2 (getpoint "\nPoint 2"))(setq disth (getdist '(pnt1 pnt2)))(setq ncol (getint "\nNº Columns"))(setq disth (/ disth ncol)) The GETDIST function allows you to get a distance dynamically on screen:
(if (setq pnt1 (getpoint "\nPoint 1"))(setq disth (getdist pnt1 "\nPoint 2")))
To calcute distance between two point use DISTANCE:
(if (and (setq pnt1 (getpoint "\nPoint 1")) (setq pnt2 (getpoint "\nPoint 2")))(setq disth (distance pnt1 pnt2)))
Regards,
Mircea Tanks Mircea,
However in the AutoCad Help these examples are presented:
(setq dist (getdist)) (setq dist (getdist '(1.0 3.5))) (setq dist (getdist "How far ")) (setq dist (getdist '(1.0 3.5) "How far? ")) getdist will prompt the user to pick one or two points and return the distance between them, it requires a string argument (prompt message) and optional base point for the distance - you are supplying it with a quoted list of two symbols.
Essentially, there are two ways you can approach this:
1) getpoint - getpoint - distance:
(setq p1 (getpoint "\nPoint 1: "))(setq p2 (getpoint "\nPoint 2: "))(setq di (distance p1 p2))2) getpoint - getdist:
(setq p1 (getpoint "\nPoint 1: "))(setq di (getdist p1 "\nDistance: "))Note that both of the above solutions do not account for null user input and will require some error trapping in this respect. Tanks, Lee.
In fact what I want is to use distance value as the value set by the input of points 1 and 2. I understand.
To match the help example you may write it like this:
(setq coordX (getreal "\nCoordinate X of point 1: ") coordY (getreal "\nCoordinate Y of point 1: "))(setq disth (getdist (list coordX coordY) "\nInput second point:"))
For sure this isn't practical at all, is just to help you understand.
Regards,
Mircea
页:
[1]