teknomatika Posted March 26, 2012 Posted March 26, 2012 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)) Quote
MSasu Posted March 26, 2012 Posted March 26, 2012 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 Quote
teknomatika Posted March 26, 2012 Author Posted March 26, 2012 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? ")) Quote
Lee Mac Posted March 26, 2012 Posted March 26, 2012 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. Quote
teknomatika Posted March 26, 2012 Author Posted March 26, 2012 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. Quote
MSasu Posted March 26, 2012 Posted March 26, 2012 However in the AutoCad Help these examples are presented: 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 Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.