Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

Extracting Coordinates from a curve 6

Status
Not open for further replies.

Santhosh_94

Mechanical
Dec 16, 2014
25
0
0
IN
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.
2017-12-14_11-53-51_ehfj0f.jpg

What i got to do is divide the curve something like this and get the intersection points?(shown below)
2017-12-14_15-15-35_xxjrbt.jpg

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?
 
Replies continue below

Recommended for you

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.
 
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.
 
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.
 
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
 
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.

2017-12-16_18-26-38_vikeyq.jpg


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.
 
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.
 
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
 
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:
(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.
 
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.
 
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.

 
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]
 
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.
 
Hi,
Here is a fragment of code instead of two lines in above written code:
Code:
<...>
[COLOR=#729FCF];(princ "\n\nPoints list:\n")
;(foreach ppoint Curve-Points (print ppoint))[/color]

(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.
 
Status
Not open for further replies.
Back
Top