MUTHUKUMAR1983 Posted May 21, 2023 Posted May 21, 2023 (DEFUN C:LA() (SETQ P1(GETPOINT "\n PICK FIRST POINT OF REF-LINE:") P2(GETPOINT P1 "\n PICK SECOND POINT OF REF-LINE:") AL 0 ) (COMMAND "UCS" "3" P1 P2 "") (REPEAT 10 (SETQ P3(GETPOINT "\n PICK FIRST POINT :") P4(GETPOINT P3 "\n PICK SECOND POINT :") ) (SETQ EL(GETREAL "\n ENTER LENGTH:") AL(+ AL EL) ANG(ANGLE P3 P4) XV(*(COS ANG)AL) YV(*(SIN ANG)EL) ) (PRINT XV)(TERPRI) (PRINT YV)(TERPRI) ) ) M1.mp4 Quote
mhupp Posted May 21, 2023 Posted May 21, 2023 (edited) What software did you use to screen cap? looks like its just a rounding error when your only inputting two digits for the length. Then you need to update the value of YV and add the next one to it to get the right value. 7.200+(-2.39969)=4.80031 4.80031+(-2.00037)=2.79994 if you want to keep the code the way it is see if this works for you. (defun C:LA (/ P1 P2 P3 P4 AL EL ANG XV YV) (setq P1 (getpoint "\n PICK FIRST POINT OF REF-LINE:") P2 (getpoint P1 "\n PICK SECOND POINT OF REF-LINE:") AL 0 YV 0 ;added code ) (command "UCS" "3" P1 P2 "") (while (setq P3 (getpoint "\n PICK FIRST POINT :") P4 (getpoint P3 "\n PICK SECOND POINT :") ) (setq EL (distance P3 P4) ;don't need to input just calc the distance from the two points. will also get rid of rounding errors. AL (+ AL EL) ANG (angle P3 P4) XV (* (cos ANG) AL) YV (+ YV (* (sin ANG) EL)) ;update value like your doing with AL ) (prompt (strcat "\n" (rtos XV 2))) (prompt (strcat "\n" (rtos YV 2))) ) ) Improved code only have to pick the two polylines and one point to get the values you want. Benefits: Selecting any point on the polyline with nearest not just endpoints midpoint. Can select points out of order or only points you want to check. ref line doesn't need to start at same point the measured line does. Only problem I see is if the polyline is started from the other side it will need to be reversed to give the correct Distance. and the refence line needs to be longer then the polyline being measured or it wont give the right Y value. Example. (defun C:LA_improved (/ ref line P1 P2) (setq ref (car (entsel "\n Pick Reference Line"))) (setq line (car (entsel "\n Pick Polyline to Measure"))) (while (setq P1 (getpoint "\n Pick Point on Line :")) (setq P2 (vlax-curve-getClosestPointTo ref P1)) (prompt (strcat "\nX: " (rtos (vlax-curve-getdistatpoint line P1) 2))) (prompt (strcat "\nY: " (rtos (distance P1 P2) 2))) ) ) props to vlax-curv functions Edited May 21, 2023 by mhupp 1 Quote
mhupp Posted May 21, 2023 Posted May 21, 2023 5 hours ago, MUTHUKUMAR1983 said: THANKS mhupp ITS WORK FINE What software did you use to screen cap? 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.