Extracting Coordinates from a curve
Extracting Coordinates from a curve
(OP)
I am trying to extract the X and Y coordinates from a curve dividing it at equal interval. How could i possibly do that??
Below i have attached the image of the curve from which i want to get the coordinates. I tried using measure and divide options but it didn't work.

What i got to do is divide the curve something like this and get the intersection points?(shown below)

Is there a way to get the list of coordinates of x and y with reference to the start of the polyline at all the intersections?
Below i have attached the image of the curve from which i want to get the coordinates. I tried using measure and divide options but it didn't work.

What i got to do is divide the curve something like this and get the intersection points?(shown below)

Is there a way to get the list of coordinates of x and y with reference to the start of the polyline at all the intersections?





RE: Extracting Coordinates from a curve
RE: Extracting Coordinates from a curve
RE: Extracting Coordinates from a curve
RE: Extracting Coordinates from a curve
RE: Extracting Coordinates from a curve
Thanks IFRs, Divide and measure command separates the polyline along the line at equal interval gaps and not exactly what i am trying to do. I tried those.
Thanks CarlB, Exactly i am trying to use the equal interval along the x axis. Where could i find those lisp routines?
Thanks USPOKER, How exactly are you saying i am not able to understand? Could you explain please.
RE: Extracting Coordinates from a curve
RE: Extracting Coordinates from a curve
RE: Extracting Coordinates from a curve
Then run LIST, choosing the new polyline. The LIST will give the coordinates in regularly spaced X positions, corresponding to your vertical lines, and the Y coordinate.
Take Chickpee's advice before running LIST.
STF
RE: Extracting Coordinates from a curve
Yes definitely the list command would work with the UCS placed at the right place, But unfortunately i have something like this to analyze.
More finite intervals and moreover i will be getting around 1200 points or coordinates, doing them in a conventional way of creating a line node to node and using a list command would be more of a tough task.
I tried using dataextraction command after measure or divide, it works like charm and yields me a good result. But the only problem is measure and divide commands divides the polyline along the line itself instead of equal interval along x axis.
I am searching for some easier way to make this out. I am still exploring some commands in commandline which we don't normally use in day to day practical applications.
Is there any way to create points or nodes at every line intersections(like selecting them all at once)?? so that i could use data extraction or list command to get the desired results.
RE: Extracting Coordinates from a curve
RE: Extracting Coordinates from a curve
The TRIM command can be used to trim all of the vertical lines at the polyline.
You could then LIST all of the vertical lines, which would include the XY coordinates as the "end".
There would, of course, be a vast amount of other data from the LIST output to sort through.
Depending on how much you need this process to be automated, copy-pasting the output to a spreadsheet would allow you to isolate the end XY coordinates.
The spreadsheet part would be done manually, but it's just one copy-paste operation, one selection of suitable delimiters, one time cleaning out the unused list text.
If you can choose efficient delimiters on import into the spreadsheet, the conversion should take 60 seconds.
STF
RE: Extracting Coordinates from a curve
With AutoLISP INTERS it's more complicated solution. But I tried to write AutoLISP with vlax-curve-getClosestPointTo function:
CODE --> autolisp
(defun c:cpoints () ;; Creates the list of points for selected curve (LINE, PLINE, SPLINE) according to the iteration distance. (setq snapmode (getvar "OSMODE") cUCS (getvar "UCSORG") curve-obj (car (entsel "\nSelect curve: ")) ) (setvar "OSMODE" 0) ;; Select bounding box of the selected curve (vla-getBoundingBox (vlax-ename->vla-object curve-obj) 'mn 'mx) ;; Lower left corner point Upper right corner point of the curve (setq LLP (vlax-safearray->list mn) URP (vlax-safearray->list mx) ) ;; Select the iteration distance (setq deltaX (getdist "Set the distance for the horizontal steps: ") Count_X (1+ (fix (/ (- (car URP) (car LLP)) deltaX))) i 0 Curve-Points nil OX nil ) ;; Start analysis (repeat Count_X (setq P1 (list (+ (car LLP) (* deltaX i)) (1- (cadr LLP)) (caddr LLP)) P2 (list (+ (car LLP) (* deltaX i)) (1+ (cadr URP)) (caddr URP)) CP1 (vlax-curve-getClosestPointTo curve-obj P1) CP2 (vlax-curve-getClosestPointTo curve-obj P2) ) (while (not (or (equal P1 CP1 1e-6) (equal P2 CP2 1e-6))) ;; Finding the Y of the curve (progn (setq P1 (list (car P1) (cadr CP1) (caddr P1)) P2 (list (car P2) (cadr CP2) (caddr P2)) CP1 (vlax-curve-getClosestPointTo curve-obj P1) CP2 (vlax-curve-getClosestPointTo curve-obj P2) ) ) ) ;; End of While (setq Curve-Points (cons (if (< (distance P1 CP1) (distance P2 CP2)) (mapcar '- CP1 cUCS) (mapcar '- CP2 cUCS)) Curve-Points) i (1+ i) ) ) ;repeat end (setvar "OSMODE" snapmode) (setq Curve-Points (Reverse Curve-Points)) (princ "\n\nPoints list:\n") (foreach ppoint Curve-Points (print ppoint)) (princ) )It looks like working to me.
Enjoy.
RE: Extracting Coordinates from a curve
RE: Extracting Coordinates from a curve
RE: Extracting Coordinates from a curve
I didn't find a lisp routine that exactly fit your needs. But maripali has written one that appears to work properly.
For ease use of the extracted data, the routine should be modified a bit to write the coordinates to a text file in "x,y" format rather than just list coordinates to the text screen enclosed in parentheses. Let us know how you'd like the output formatted; maripali or I could probably take care of that.
RE: Extracting Coordinates from a curve
https://newtonexcelbach.com/2012/09/26/daily-downl...
RE: Extracting Coordinates from a curve
Thanks SparWeb,
It a good option to go with. I never though about that. Thanks
Thanks maripali,
Amazing work with your lisp routine
I tried using it, It works perfectly.
But i am not able to get all the coordinates listed for my curve in the status window. Only few are visible.
I checked the program with a small polyline and verified it.
Actually i never used lisp routine before, this i what i did i saved your code in .lsp format and used appload to load the lisp and used the command cpoints(this is what i got when i googled how to use lisp). Am i right here in using the program?
Thanks Chicopee,
That curve is extracted from a 3D part model (Step file).
Thanks CarlB,
Yes, I am trying to figure out how to get all the coordinates displayed. It would be nice if it is outputted to an excel or a text file.
Thanks robyengIT,
It is much similar to your previous suggestion. More useful tool if we have an image to measure and analyze.
RE: Extracting Coordinates from a curve
RE: Extracting Coordinates from a curve
Here is a fragment of code instead of two lines in above written code:
CODE --> AutoLISP
<...> ;(princ "\n\nPoints list:\n") ;(foreach ppoint Curve-Points (print ppoint)) (setq file_name (getfiled "Generate points list file for the slected curve: " "" "txt" 1) ) (setq file_write (open file_name "w")) (foreach ppoint Curve-Points (print ppoint file_write)) (close file_write) <...>These two lines I left commented but you can delete them.
Now you should be able to write coords to the simple text file.
RE: Extracting Coordinates from a curve
CODE
(defun c:cpoints () ;; Creates the list of points for selected curve (LINE, PLINE, SPLINE) according to the iteration distance. ;; by maripali for Eng-Tips December 17, 2017 (setq snapmode (getvar "OSMODE") cUCS (getvar "UCSORG") curve-obj (car (entsel "\nSelect curve: ")) ) (setvar "OSMODE" 0) ;; Select bounding box of the selected curve (vla-getBoundingBox (vlax-ename->vla-object curve-obj) 'mn 'mx) ;; Lower left corner point Upper right corner point of the curve (setq LLP (vlax-safearray->list mn) URP (vlax-safearray->list mx) ) ;; Select the iteration distance (setq deltaX (getdist "Set the distance for the horizontal steps: ") Count_X (1+ (fix (/ (- (car URP) (car LLP)) deltaX))) i 0 Curve-Points nil OX nil ) ;; Start analysis (repeat Count_X (setq P1 (list (+ (car LLP) (* deltaX i)) (1- (cadr LLP)) (caddr LLP)) P2 (list (+ (car LLP) (* deltaX i)) (1+ (cadr URP)) (caddr URP)) CP1 (vlax-curve-getClosestPointTo curve-obj P1) CP2 (vlax-curve-getClosestPointTo curve-obj P2) ) (while (not (or (equal P1 CP1 1e-6) (equal P2 CP2 1e-6))) ;; Finding the Y of the curve (progn (setq P1 (list (car P1) (cadr CP1) (caddr P1)) P2 (list (car P2) (cadr CP2) (caddr P2)) CP1 (vlax-curve-getClosestPointTo curve-obj P1) CP2 (vlax-curve-getClosestPointTo curve-obj P2) ) ) ) ;; End of While (setq Curve-Points (cons (if (< (distance P1 CP1) (distance P2 CP2)) (mapcar '- CP1 cUCS) (mapcar '- CP2 cUCS)) Curve-Points) i (1+ i) ) ) ;repeat end (setvar "OSMODE" snapmode) (setq Curve-Points (Reverse Curve-Points)) ;(princ "\n\nPoints list:\n") ;(foreach ppoint Curve-Points (print ppoint)) (setq file_name (getfiled "Generate point list file for the selected curve: " "" "txt" 1) ) (setq file_write (open file_name "w")) ;;CarlB modification for text file output, "x,y" format Dec. 19 2017 (foreach ppoint Curve-Points (write-line (strcat (rtos (car ppoint) 2 4) "," (rtos (cadr ppoint) 2 4)) file_write)) (close file_write) (princ) )RE: Extracting Coordinates from a curve
You have done such an amazing work. It works perfectly. Thanks for helping me out.