advex Posted October 7, 2011 Posted October 7, 2011 I am looking for an application to solve the following problem: I have a drawing with many points p1, p2, ... pn. Ability to select a point and to draw lines from selected point to the other points in the drawing. Thanks. Quote
Tharwat Posted October 7, 2011 Posted October 7, 2011 Would this help you with it .... ? (defun c:TesT (/ ss p i sname p1 a) ;; Tharwat 07. Oct. 2011 ;; (if (setq ss (ssget '((0 . "POINT")))) (progn (setq p (assoc 10 (entget (ssname ss 0)))) (repeat (setq i (sslength ss)) (setq sname (ssname ss (setq i (1- i)))) (setq p1 (cdr (assoc 10 (entget sname)))) (entmakex (list '(0 . "LINE") p (setq a (cons 11 p1)))) (setq p (cons 10 (list (nth 1 a) (nth 2 a) (nth 3 a)))) ) ) (princ) ) (princ) ) Tharwat Quote
Tharwat Posted October 7, 2011 Posted October 7, 2011 The routes of connecting points with lines would be according to the creation of points one by one which means the point which is created first in a drawing would have the property in advance . Regards. Quote
advex Posted October 7, 2011 Author Posted October 7, 2011 Thanks for quick response. My English is not good, the requirement is slightly different .... I hope to be suggestive photo attached! From the point selected will draw lines to other points. Quote
Tharwat Posted October 7, 2011 Posted October 7, 2011 To get the best result as you are looking for , select the base point first and after that the rest of points . Try this .. (defun c:TesT (/ ss p i sname p1 ) ;; Tharwat 07. Oct. 2011 ;; (if (setq ss (ssget '((0 . "POINT")))) (progn (setq p (assoc 10 (entget (ssname ss 0)))) (repeat (setq i (sslength ss)) (setq sname (ssname ss (setq i (1- i)))) (setq p1 (cdr (assoc 10 (entget sname)))) (entmakex (list '(0 . "LINE") p (cons 11 p1))) ) ) (princ) ) (princ) ) Tharwat Quote
advex Posted October 7, 2011 Author Posted October 7, 2011 To get the best result as you are looking for , select the base point first and after that the rest of points . Thank you. All the best! Quote
Tharwat Posted October 7, 2011 Posted October 7, 2011 Thank you. All the best! You're welcome anytime . Quote
Lee Mac Posted October 7, 2011 Posted October 7, 2011 (edited) Another idea: (defun c:test ( / a b g i l p s u ) (if (setq s (ssget '((0 . "POINT")))) (progn (repeat (setq i (sslength s)) (setq p (assoc 10 (entget (ssname s (setq i (1- i))))) u (cons (trans (cdr p) 0 1) u) l (cons p l) ) ) (princ "\nSelect Point: ") (while (progn (setq g (grread t 13 2) a (car g) b (cadr g)) (cond ( (= 5 a) (redraw) (foreach x u (grdraw x b 1 1)) t ) ( (= 3 a) (if (setq s (ssget b '((0 . "POINT")))) (progn (setq p (cdr (assoc 10 (entget (ssname s 0))))) (foreach x l (entmakex (list (cons 0 "LINE") x (cons 11 p)))) nil ) (princ "\nPlease Select a Point.") ) ) ) ) ) ) ) (redraw) (princ) ) Edited October 7, 2011 by Lee Mac Quote
advex Posted October 7, 2011 Author Posted October 7, 2011 Another idea:... Ideas are worth a dime dozen, but people who put them into action are priceless. (African proberb) Lee Mac - Thank you! Quote
Lee Mac Posted October 7, 2011 Posted October 7, 2011 Ideas are worth a dime dozen, but people who put them into action are priceless. (African proberb) A very thoughtful quotation advex, I like it. Lee Mac - Thank you! Cheers Quote
advex Posted October 7, 2011 Author Posted October 7, 2011 Lee, It is possible to replace points with blocks? Select blocks (points with attributes) and the same functionality .... ?!?! :cry: Quote
Lee Mac Posted October 7, 2011 Posted October 7, 2011 Lee,It is possible to replace points with blocks? Select blocks (points with attributes) and the same functionality .... ?!?! :cry: Certainly! In my code, replace the word "POINT" with "INSERT" (in two places), change the prompts, and all should still work Quote
advex Posted October 8, 2011 Author Posted October 8, 2011 Certainly! In my code, replace the word "POINT" with "INSERT" (in two places), change the prompts, and all should still work Thanks again! Your applications made my life easier... [from www.millan.net] Quote
Lee Mac Posted October 8, 2011 Posted October 8, 2011 Thanks again! Your applications made my life easier... Good stuff advex! Quote
marko_ribar Posted October 9, 2011 Posted October 9, 2011 (edited) Here is another one, based on points distances... You select first one, and routine connect them based on closest next point : (defun pointsarray ( ptst ptl / dptpt dptptlst mindptpt pten ptl ) (foreach pt ptl (setq dptpt (distance ptst pt)) (setq dptptlst (cons dptpt dptptlst)) ) (setq dptptlst (vl-remove 0.0 dptptlst)) (setq mindptpt (eval (cons 'min dptptlst))) (mapcar '(lambda (pt) (if (= (distance ptst pt) mindptpt) (setq pten pt))) ptl) (setq ptlst (cons ptst ptlst)) (setq ptl (vl-remove ptst ptl)) (if (not (null ptl)) (pointsarray pten ptl) ) ptlst ) (defun c:pts2lines ( / ss ssn pt ptl ptst ptlst ) (prompt "\nSelect points that you want to connect with lines") (setq ss (ssget '((0 . "POINT") (210 0.0 0.0 1.0)) )) (setq ssn (sslength ss) i ssn) (repeat ssn (setq pt (cdr (assoc 10 (entget (ssname ss (setq i (1- i))))))) (setq ptl (cons pt ptl)) ) (setq ptl (reverse ptl)) (vl-cmdf "_.OSNAP" "node") (setq ptst (getpoint "\nPick start point from witch to create continous array of lines obtained from rest of selected points")) (setq ptlst (pointsarray ptst ptl)) (vl-cmdf "_.LINE") (foreach pt ptlst (vl-cmdf pt) ) (vl-cmdf "") (princ) ) M.R. BTW. If you want to draw polyline, just replace (vl-cmdf "_.LINE") with (vl-cmdf "_.PLINE") Edited October 9, 2011 by marko_ribar BTW... Quote
advex Posted October 9, 2011 Author Posted October 9, 2011 Here is another one, based on points distances... You select first one, and routine connect them based on closest next point... Thanks for posting the application but the algorithm is different. Add to collection! Quote
teknomatika Posted October 10, 2011 Posted October 10, 2011 It would be interesting that the lines were drawn in all possible combinations in selected points but with the criterion of triangulation, an example of MDT. It means that the crossing lines've not be considered. Better yet, would be able to choose the option to trade triangles, but it would be a program topography. 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.