Ali K Posted January 22, 2024 Posted January 22, 2024 (edited) Hello, I have a set of about 5400 points that are created consecutively. I am looking for a lisp that i select all those points and it gives me the distance between each consecutive two points. I have this lisp but I have to select each pair, which will take a lot of time. So, any help would be really appreciated. ;SHOW LEVEL DIFFERENT BETWEEN TWO POINTS (defun c:LVDIF() (setq pt1 (getpoint"\nPick First Point"));SELECT FIRST POINT (setq pt2 (getpoint"\nPick Second Point"));SELECT SECOND POINT (setq dis (distance pt1 pt2));DISTANCE BETWEEN TOW POINTS (setq ang (angle pt1 pt2));ANGLE BETWEEN TWO POINTS (setq mid (polar pt1 ang (/ dis 2)));POINT BETWEEN SELLECTED TWO POINTS (setq vpt1 (nth 2 pt1));LEVEL OF FIRST POINT (setq vpt2 (nth 2 pt2));LEVEL OF SECOMD POINT (setq vdif (- vpt1 vpt2));LEVEL DIFFERENT (if (< vdif 0);CHANGE SIGN IF IT NIGATIVE VALUE (setq vdif (* vdif -1))) (if (> vdif 0.5);CHANGE COLOR OF LEVEL DIFFERENT TO RED IN CASE MORETHAN LIMIT (command "color" "T" "255,0,0") (command "-color" "bylayer")) (command "text" "J" "MC" mid 2.5 0 (strcat "DIF="(rtos vdif 2 2)));WRITE TEXT BETWEEN SELLECTED POINTS );end Edited January 22, 2024 by SLW210 Added Code Tags! Quote
SLW210 Posted January 22, 2024 Posted January 22, 2024 Please use Code Tags! (use the <> in the editor). Quote
Steven P Posted January 22, 2024 Posted January 22, 2024 when you say consecutive points, are you looking for them in consecutive order of creation or as drawn on the sheet, distance between the point and it's closest neighbour? First option is trickier, 2nd option is easier. For the 2nd option is there a maximum distance between consecutive points, my thinking here is that to find the closest point you will need to asses other points to work it out, if you can limit the distance you are searching over you might only need the LISP to consider 10 points rather than 5400... which will make it quicker,. To give the result, are you wanting a list or perhaps a dimension drawn between the 2 points? Quote
fuccaro Posted January 23, 2024 Posted January 23, 2024 It seems like our new friend forgot to answer... Anyway, if the previous routine works as expected, I kept it as much as possible and I feed it with point pars. Not sure if that's what the OP needs... (defun c:LVDIF() (setq points (ssget '((0 . "POINT")))) (repeat (setq i (1- (sslength points))) (lvdif1 (cdr (assoc 10 (entget (ssname points i)))) (cdr (assoc 10 (entget (ssname points (setq i (1- i))))))) ) ) ;SHOW LEVEL DIFFERENT BETWEEN TWO POINTS (defun LVDIF1(pt1 pt2) ;(setq pt1 (getpoint"\nPick First Point"));SELECT FIRST POINT ;(setq pt2 (getpoint"\nPick Second Point"));SELECT SECOND POINT (setq dis (distance pt1 pt2));DISTANCE BETWEEN TOW POINTS (setq ang (angle pt1 pt2));ANGLE BETWEEN TWO POINTS (setq mid (polar pt1 ang (/ dis 2)));POINT BETWEEN SELLECTED TWO POINTS (setq vpt1 (nth 2 pt1));LEVEL OF FIRST POINT (setq vpt2 (nth 2 pt2));LEVEL OF SECOMD POINT (setq vdif (- vpt1 vpt2));LEVEL DIFFERENT (if (< vdif 0);CHANGE SIGN IF IT NIGATIVE VALUE (setq vdif (* vdif -1))) (if (> vdif 0.5);CHANGE COLOR OF LEVEL DIFFERENT TO RED IN CASE MORETHAN LIMIT (command "color" "T" "255,0,0") (command "-color" "bylayer")) (command "text" "J" "MC" mid 2.5 0 (strcat "DIF="(rtos vdif 2 2)));WRITE TEXT BETWEEN SELLECTED POINTS );end Quote
Ali K Posted January 25, 2024 Author Posted January 25, 2024 (edited) On 1/22/2024 at 3:22 PM, Steven P said: when you say consecutive points, are you looking for them in consecutive order of creation or as drawn on the sheet, distance between the point and it's closest neighbour? First option is trickier, 2nd option is easier. For the 2nd option is there a maximum distance between consecutive points, my thinking here is that to find the closest point you will need to asses other points to work it out, if you can limit the distance you are searching over you might only need the LISP to consider 10 points rather than 5400... which will make it quicker,. To give the result, are you wanting a list or perhaps a dimension drawn between the 2 points? Thank you for your reply. Actually, it is the first option where all the points were created in consecutive order. To clarify, I need the lisp to run in a loop to write the distance between each pair: 1&2, 3&4, 5&6 and so on. Edited January 25, 2024 by Ali K Quote
Ali K Posted January 25, 2024 Author Posted January 25, 2024 On 1/23/2024 at 3:22 PM, fuccaro said: It seems like our new friend forgot to answer... Anyway, if the previous routine works as expected, I kept it as much as possible and I feed it with point pars. Not sure if that's what the OP needs... (defun c:LVDIF() (setq points (ssget '((0 . "POINT")))) (repeat (setq i (1- (sslength points))) (lvdif1 (cdr (assoc 10 (entget (ssname points i)))) (cdr (assoc 10 (entget (ssname points (setq i (1- i))))))) ) ) ;SHOW LEVEL DIFFERENT BETWEEN TWO POINTS (defun LVDIF1(pt1 pt2) ;(setq pt1 (getpoint"\nPick First Point"));SELECT FIRST POINT ;(setq pt2 (getpoint"\nPick Second Point"));SELECT SECOND POINT (setq dis (distance pt1 pt2));DISTANCE BETWEEN TOW POINTS (setq ang (angle pt1 pt2));ANGLE BETWEEN TWO POINTS (setq mid (polar pt1 ang (/ dis 2)));POINT BETWEEN SELLECTED TWO POINTS (setq vpt1 (nth 2 pt1));LEVEL OF FIRST POINT (setq vpt2 (nth 2 pt2));LEVEL OF SECOMD POINT (setq vdif (- vpt1 vpt2));LEVEL DIFFERENT (if (< vdif 0);CHANGE SIGN IF IT NIGATIVE VALUE (setq vdif (* vdif -1))) (if (> vdif 0.5);CHANGE COLOR OF LEVEL DIFFERENT TO RED IN CASE MORETHAN LIMIT (command "color" "T" "255,0,0") (command "-color" "bylayer")) (command "text" "J" "MC" mid 2.5 0 (strcat "DIF="(rtos vdif 2 2)));WRITE TEXT BETWEEN SELLECTED POINTS );end Thank you so much for your reply and editing the lisp. However, when I run it, it doesn't accept to select the COGO points as shown in the picture below. Quote
fuccaro Posted January 25, 2024 Posted January 25, 2024 You are right, that program will process plain "point" entities only Quote
Ali K Posted January 25, 2024 Author Posted January 25, 2024 37 minutes ago, fuccaro said: You are right, that program will process plain "point" entities only I fixed the lisp to select cogo points, but the issue is the missing repeat or loop function to process the difference between each pair. Quote
BIGAL Posted January 29, 2024 Posted January 29, 2024 For CIV3D COGO points need to look at property "Location" (setq obj (vlax-ename->vla-object (car (entsel)))) (setq pt1 (vlax-safearray->list (vlax-variant-value (vlax-get-property obj "Location")))) 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.