×
INTELLIGENT WORK FORUMS
FOR ENGINEERING PROFESSIONALS

Log In

Come Join Us!

Are you an
Engineering professional?
Join Eng-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!
  • Students Click Here

*Eng-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Jobs

Extracting Coordinates from a curve
6

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?

RE: Extracting Coordinates from a curve

I usually do with "plot digitizer" (search with Google : there are free)

RE: Extracting Coordinates from a curve

Use the autocad command "divide" or "measure" then create a new polyline using those nodes then use "list" ?

RE: Extracting Coordinates from a curve

The method you use depends if the "equal interval" is equal in regards to distance along curve, or in x values as your grid method implies. There are scads of free lisp routines to be found. I'm sure there are several that would do it in one click, with output to a text file or similar.

RE: Extracting Coordinates from a curve

Have you tried cutting parallel sections thru the line

RE: Extracting Coordinates from a curve

(OP)
Thanks robyengIT,Really useful tool. But that is much suited for image files i guess? And at specified interval gaps that could yield me a approximate value moreover and i am having this curve as a dwg file.

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

Manually, there is _breakatpoint [with OSnap at intersection], then Node to create Node putting at each break, then 'list.

RE: Extracting Coordinates from a curve

You got choices from the above responders, however, make sure the your UCS is positioned in it proper place. That proper place depends on your choice. The "LIST" command will have the X and Y coordinates listed for each nodal point based on the position of the UCS.

RE: Extracting Coordinates from a curve

Now that you have a grid of vertical lines overlapping the polyline, you can draw a NEW polyline, selecting every intersection of the first polyline with the grid.
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

(OP)
Thanks everyone for your valuable responses.

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

You are going to need a LISP or VP program to do this, but it should be possible. LISP has the INTERS function that returns the coordinates of the intersection of two lines.

RE: Extracting Coordinates from a curve

A follow-up idea, though incomplete...
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

Good idea with the TRIM.
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

I like the trim command also. Make the other end of the lines at a known datum and you can easily filter out those coordinates.

RE: Extracting Coordinates from a curve

My question is with what program was the curve generated and I am referring to the curve presented in your second graph?

RE: Extracting Coordinates from a curve

Santosh,

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

(OP)
Sorry guys for my delayed response.

Thanks SparWeb,
It a good option to go with. I never though about that. Thanks

Thanks maripali,
Amazing work with your lisp routine thumbsup2, unfortunately i am not able to understand the codes sad.
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.

thanks

RE: Extracting Coordinates from a curve

Since there are more lines of output than fit on the text screen ( you can make the text screen larger but limited to your display ) you can either scroll up to highlight and copy/paste into an external document or modify the LISP or VP program to output to a text file.

RE: Extracting Coordinates from a curve

Hi,
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

I took the liberty to add maripali's edits to the original file, and modify it to output the point coordinates in "x,y" format. This format allows you to place in Excel and parse into columns.

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

(OP)
Thanks Maripali and CarlB,
You have done such an amazing work. It works perfectly. Thanks for helping me out.

Thanks

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Eng-Tips Forums free from inappropriate posts.
The Eng-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Eng-Tips forums is a member-only feature.

Click Here to join Eng-Tips and talk with other members!


Resources


Close Box

Join Eng-Tips® Today!

Join your peers on the Internet's largest technical engineering professional community.
It's easy to join and it's free.

Here's Why Members Love Eng-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close