Continue to Site

Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

  • Congratulations KootK on being selected by the Eng-Tips community for having the most helpful posts in the forums last week. Way to Go!

Extracting Coordinates from a curve 6

Status
Not open for further replies.

Santhosh_94

Mechanical
Dec 16, 2014
25
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

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


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

[Thanks]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor