addresstemp Posted March 13, 2015 Posted March 13, 2015 Hi! I'm new in lisp loop. I want to draw existing topo line on elevation from topo survey plan. Surveyor drawing attached on top of elevation and get x coordinate to click point from survey plan and input z coordinate. These (x,z) on plan to draw polyline on elevation as (x,y). Drawing units is millimeter and show on plan data are meter. I tried to write lisp as below. I don't really know how to use "while" "list". (defun c:Elevel (/ x1 l1 y1 pt1 x2 l2 y2 pt2) (setq x1 (rtos (car (getpoint "\nPick Point1: ")) 2 2)) (setq l1 (getreal "\nEnter Level1: ")) (setq y1 (rtos (* l1 1000) 2 2)) (setq pt1 (strcat x1 "," y1)) (while (/= nil (setq x2 (rtos (car (getpoint "\nPick Point2: ")) 2 2)) (setq l2 (getreal "\nEnter Level2: ")) (setq y2 (rtos (* l2 1000) 2 2)) (setq pt2 (strcat x2 "," y2)) ) (command "_pline" pt1 pt2 "") (setq pt1 pt2) ) (princ) ) Thanks in advance, Jack Quote
addresstemp Posted March 13, 2015 Author Posted March 13, 2015 (edited) polyline are not continuous. and exit error. can anyone help me to fix lisp? Edited March 13, 2015 by addresstemp Quote
Tharwat Posted March 13, 2015 Posted March 13, 2015 Something like this ? (defun c:Elevel (/ l1 p1 l2 p2) (if (and (setq p1 (getpoint "\nPick Point 1: ")) (setq l1 (getreal "\nEnter Level 1: ")) ) (progn (setq p1 (strcat (rtos (car p1) 2 2) "," (rtos (* l1 1000.) 2 2))) (while (and (setq p2 (getpoint "\nPick Point2: ")) (setq l2 (getreal "\nEnter Level2: ")) ) (command "_pline" "_non" p1 "_none" (setq p2 (strcat (rtos (car p2) 2 2) "," (rtos (* l2 1000.) 2 2)) ) "" ) (setq p1 p2) ) ) ) (princ) ) Quote
addresstemp Posted March 14, 2015 Author Posted March 14, 2015 Yes, something like that. Thank you Tharwat. Looping is ok now. But pline are still not continuous. Quote
BIGAL Posted March 14, 2015 Posted March 14, 2015 You should only need to pick the text or the cross if it has a Z to get the elevation value its an extra step not needed, If the text insert is at the cross point then you can use that for X,Y. The bit missing was working out the true distance between the points I could not see that in your code, its probably easier to make a list of the points and then draw the pline in one go. Did you create the points from maybe a X,Y,Z file CSV then it would be easier to just use that and not pick any points. Quote
Spaj Posted March 14, 2015 Posted March 14, 2015 Hi AFAIK you have to delve a little deeper into AutoLISP to generate continuous polylines. (setq file (open name "r")) ; Open file for second read (entmake '((0 . "polyline") (66 . 1) (62 . 5))) (entmake '((0 . "vertex")(10 0 0 0))) ; Set init polyline point (setq info (read-line file)) ; Read data line (while (/= info nil) (setq data (read (strcat "(" info ")")) ; Convert to list x1 (nth 2 data) ; Point Resist y1 (car data) ; Y coord (depth) y2 (* y1 -10) ; Plot Y's downward x2 (* (* x1 0.2) 10) ) ; end setq (entmake (list '(0 . "vertex") (list 10 x2 y2 0))) (setq info (read-line file)) ) ; end while (entmake '((0 . "seqend"))) ; Close polyline Quote
BIGAL Posted March 14, 2015 Posted March 14, 2015 Another pline routine (command "_pline") (while (= (getvar "cmdactive") 1 ) (command pause) ) Quote
Tharwat Posted March 15, 2015 Posted March 15, 2015 Try this program , and when you finish picking points just hit ENTER and NOT escape button . (defun c:Test (/ l i l1 p1 l2 p2) ;;; Tharwat 15.03.2015 ;;; (if (and (setq p1 (getpoint "\nPick Point 1: ")) (setq l1 (getreal "\nEnter Level 1: ")) ) (progn (setq p1 (list (car p1) (* l1 1000.)) l (cons p1 l) ) (while (and (setq p2 (getpoint "\nPick Point2: ")) (setq l2 (getreal "\nEnter Level2: ")) ) (setq l (cons (setq p2 (list (car p2) (* l2 1000.)) ) l) i 0 ) (repeat (1- (length l)) (grdraw (nth i l) (nth (setq i (1+ i)) l) 2 1) ) ) (entmakex (append (list '(0 . "LWPOLYLINE") '(100 . "AcDbEntity") '(100 . "AcDbPolyline") (cons 90 (length l)) '(70 . 0)) (mapcar (function (lambda (p) (cons 10 p))) l))) ) ) (redraw) (princ) ) Quote
addresstemp Posted May 12, 2015 Author Posted May 12, 2015 (edited) Thank you Tharwat. Your lisp can generate continuous polyline and draw from world UCS. But for elevation, I changed UCS origin and draw elevation around the plan. These topo levels are draw from user ucs. but it is not relate with user ucs. It's far from user ucs. I attached sample dwg. Please check for me. Thanks For Lisp.dwg Edited May 12, 2015 by addresstemp Missing attach file 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.