aloy Posted March 30, 2014 Share Posted March 30, 2014 Hi everyone, What is the simplest way to find whether two points are connected in a drawing using Alisp. Thanking in advance. Aloy Quote Link to comment Share on other sites More sharing options...
Tharwat Posted March 30, 2014 Share Posted March 30, 2014 Maybe this .. ? (vl-every '(lambda (u) (eq u t)) (mapcar '(lambda (q p) (equal q p 1e-) p1 p2)) Quote Link to comment Share on other sites More sharing options...
Lee Mac Posted March 30, 2014 Share Posted March 30, 2014 Perhaps: (defun connected-p ( p1 p2 ) (and (ssget "_X" (list '(0 . "LINE") '(-4 . "<OR") '(-4 . "<AND") (cons 10 p1) (cons 11 p2) '(-4 . "AND>") '(-4 . "<AND") (cons 10 p2) (cons 11 p1) '(-4 . "AND>") '(-4 . "OR>") ) ) ) ) Test program: (defun c:test ( / p1 p2 ) (if (and (setq p1 (getpoint "\nPoint 1: ")) (setq p2 (getpoint "\nPoint 2: ")) ) (print (connected-p (trans p1 1 0) (trans p2 1 0))) ) (princ) ) Though, the above is very inefficient if you are looking to test multiple points - a more efficient method would be to retrieve the set of all lines in the appropriate drawing layout and test the points against the end points of the lines in this set. Quote Link to comment Share on other sites More sharing options...
Lee Mac Posted March 30, 2014 Share Posted March 30, 2014 (vl-every '(lambda (u) (eq u t)) (mapcar '(lambda (q p) (equal q p 1e-) p1 p2)) Your code is the same as: (equal p1 p2 1e- Quote Link to comment Share on other sites More sharing options...
hmsilva Posted March 30, 2014 Share Posted March 30, 2014 Another (defun c:demo (/ A B ENT FLAG ITM NUM P1 P2 SS) (if (and (setq p1 (getpoint "\nPick the first point <exit> : ")) (setq p2 (getpoint "\nPick the second point <exit> :")) (setq ss (ssget "_F" (list p1 p2) '((0 . "LINE")))) ) (progn (setq itm 0 num (sslength ss) flag nil ) (while (and (< itm num) (/= flag T) ) (setq ent (entget (ssname ss itm)) a (cdr (assoc 10 ent)) b (cdr (assoc 11 ent)) itm (1+ itm) ) (if (and (or (equal p1 a 1e- (equal p1 b 1e-) (or (equal p2 a 1e- (equal p2 b 1e-) ) (progn (setq flag T) (prompt "\nA line is connecting the two points!") ) ) ) (if (not flag) (prompt "\nNo line is connecting the two points!")) ) ) (princ) ) HTH Henrique Quote Link to comment Share on other sites More sharing options...
Tharwat Posted March 30, 2014 Share Posted March 30, 2014 Your code is the same as: (equal p1 p2 1e- You're correct . I don't know why did I go that far ? Thank you . Quote Link to comment Share on other sites More sharing options...
hmsilva Posted March 30, 2014 Share Posted March 30, 2014 Though, the above is very inefficient if you are looking to test multiple points - a more efficient method would be to retrieve the set of all lines in the appropriate drawing layout and test the points against the end points of the lines in this set. Lee wouldn't be more eficiente if your "connected-p" function only tests a possible line (defun connected-p (p1 p2) (and (ssget "_F" (list p1 p2) (list '(0 . "LINE") '(-4 . "<OR") ... Henrique Quote Link to comment Share on other sites More sharing options...
Lee Mac Posted March 30, 2014 Share Posted March 30, 2014 Lee wouldn't be more eficiente if your "connected-p" function only tests a possible line (defun connected-p (p1 p2) (and (ssget "_F" (list p1 p2) (list '(0 . "LINE") '(-4 . "<OR") ... Henrique A good suggestion Henrique, but since the Fence mode string is a graphical selection method, this relies on the points always being visible in the drawing area, otherwise the function will return unexpected results. Quote Link to comment Share on other sites More sharing options...
hmsilva Posted March 30, 2014 Share Posted March 30, 2014 A good suggestion Henrique, but since the Fence mode string is a graphical selection method, this relies on the points always being visible in the drawing area, otherwise the function will return unexpected results. Good point! Henrique Quote Link to comment Share on other sites More sharing options...
aloy Posted March 30, 2014 Author Share Posted March 30, 2014 Thanks LeeMac your input has been always useful. I used the above function without arguments so that I can go round the convexhull connecting any points that are unconnected together with any others inside in one go. Thanks to hmsilva (a very familiar name in my part of the world) and to Tharwat, too. Regards, Aloy Quote Link to comment Share on other sites More sharing options...
anaskattayil Posted April 15, 2014 Share Posted April 15, 2014 I have 500 points in Auto cad, 250 points up & others are down. Surveyor take the points at up&down one bye one position. I connected that points by the help of a lisp. Its coming in ZIGZAG model. I need to make a rectangular model. Please help me. is there any lisp for that. Please help me.... Quote Link to comment Share on other sites More sharing options...
aloy Posted April 15, 2014 Author Share Posted April 15, 2014 Assankattayil, The question I have put to the forum has been answered and I found the solution. I do not know how it is related to yours and also your question. What do you mean by "I have 500 points in Auto cad, 250 points up & others are down." In what form the survey data came?. The experts in this forum may be able to tell how to put them in ZIGZAG or any other model which I am not familiar. Please put it to them in the form of a post, not as a reply to another thread. Regards, Aloy Quote Link to comment Share on other sites More sharing options...
MSasu Posted April 15, 2014 Share Posted April 15, 2014 I connected that points by the help of a lisp. Its coming in ZIGZAG model. I need to make a rectangular model. Most probably your AutoLISP tool is connecting the points by their adding order; may be useful to adjust it to work on a selection set rather that entire drawing and run it once on top items, respectively on bottom one. Quote Link to comment Share on other sites More sharing options...
anaskattayil Posted April 15, 2014 Share Posted April 15, 2014 I attached one file for example. I connected that points with the help of lisp. But its coming one line goto to up then down then up etc...... I need the drawing in rectangular shape. please can you arrange for me......... Drawing2.dwg Quote Link to comment Share on other sites More sharing options...
anaskattayil Posted April 15, 2014 Share Posted April 15, 2014 any lisp for that file???? Quote Link to comment Share on other sites More sharing options...
MSasu Posted April 15, 2014 Share Posted April 15, 2014 Your file contains only 100 points; just activate the Osnap mode Node and will be done in a couple of minutes. May help also to adjust points display mode by calling DDPTYPE command. Quote Link to comment Share on other sites More sharing options...
anaskattayil Posted April 15, 2014 Share Posted April 15, 2014 Hi Msasu, its an example. Its a rock filling area 8640m length. every 2mtr have points. 4320points in one side. so its 8640 points . Please arrange for me one lisp. Quote Link to comment Share on other sites More sharing options...
MSasu Posted April 15, 2014 Share Posted April 15, 2014 Did you noticed this suggestion? Quote Link to comment Share on other sites More sharing options...
anaskattayil Posted April 15, 2014 Share Posted April 15, 2014 what?? I did not under stand. Quote Link to comment Share on other sites More sharing options...
MSasu Posted April 15, 2014 Share Posted April 15, 2014 What I'm suggesting is to separate the points in two groups, the top, respectively the bottom ones. To don't have to adjust the code (as per above suggestion), may also do this by dividing the drawing in two copies (one for top points and another one for bottom points) and run the aforementioned tool on each of these; next step copy the results in a single file. Quote Link to comment Share on other sites More sharing options...
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.