Jump to content

Recommended Posts

Posted

I want to be able to get the two points between the portion of polyline I select.

 

example:

the blue line is the portion of the polyline selected and the X's are the two points I wish to get.

example.jpg

 

I'm able to get this by comparing angles and sorting by distance but there must be a better way.

Posted

you just want to select the line and have its endpoints returned as coordinates?

Posted

(defun AT:Segment (objPnt)
 ;; Retreive segment number and Start & End points
 ;; objPnt - List with object & point
 ;; Alan J. Thompson, 11.10.09 / 08.19.10
 (if (vl-consp objPnt)
   ((lambda (seg)
      (list seg
            (list (vlax-curve-getPointAtParam (car objPnt) seg)
                  (cond ((vlax-curve-getPointAtParam (car objPnt) (1+ seg)))
                        ((vlax-curve-getPointAtParam (car objPnt) (1- seg)))
                  )
            )
      )
    )
     (fix (vlax-curve-getParamAtPoint
            (car objPnt)
            (vlax-curve-getClosestPointTo (car objPnt) (trans (cadr objPnt) 1 0))
          )
     )
   )
 )
)

 

eg.

(AT:Segment (entsel))

Posted

I was looking at the Curve measurement functions in Developer's Help but could not figure out how to get the end points.

 

Thank you!! :D

Posted

Thank you for that snippet Alanjt, the code i wrote for the same purpose is waaaaayyyyy to long. (DXF codes)

 

 (vlax-curve-getClosestPointTo (car objPnt) (trans (cadr objPnt) 1 0));<------  

 

Nice :)

Posted
Thank you for that snippet Alanjt, the code i wrote for the same purpose is waaaaayyyyy to long. (DXF codes)

 

 (vlax-curve-getClosestPointTo (car objPnt) (trans (cadr objPnt) 1 0));<------  

 

Nice :)

Enjoy. I'd like to see you DXF example, if you don't mind sharing. It's always neat to see how others approach a task.

Posted
Enjoy. I'd like to see you DXF example, if you don't mind sharing. It's always neat to see how others approach a task.

 

sure, its not pefect though, wrote it for regular shape polylines(squares.rectangles.triangles,closed polygons) because i use distance to test, as much as possible i pick at the middle of the segment :lol:

 

(defun c:Seg (/ pl ss a_10 pt_lst dst_tst seg_pts)
(if (setq pl (entsel "\nSelect Pline:"))
  (progn
          (setq ss (entget (car pl)))
 (while (setq a_10 (assoc 10 ss))
          (setq ss (member a_10 ss))
          (setq
            pt_lst
             (cons (cdr (assoc 10 ss)) pt_lst)
            ss (cdr ss)) ;_ end of setq
          )
 (setq dst_tst (mapcar (function (lambda (j) (distance (cadr pl) j))) pt_lst)
   2pt (vl-sort dst_tst '<)
  seg_pts 
                 (list 
   (nth (vl-position (nth 0 2pt) dst_tst) pt_lst)
   (nth (vl-position (nth 1 2pt) dst_tst) pt_lst))
           )
          )
  )
  )

 

Your code is more elegant and effective

Oh well :) (lesson learned)

Posted

Yeah, I could see where you'd have problems with vertices being close together. I still like it.

Posted
Yeah, I could see where you'd have problems with vertices being close together. I still like it.

 

yup, bummer huh

 

I could've made it shorter it i did this way(not that it matters)

 

 
(setq ss     (entget (car pl))
       pt_lst (mapcar
                'cdr
                (vl-remove-if-not '(lambda (x) (= (car x) 10)) ss)))

 

but still.. anyhoo. i'll worked on it when i get time, thank you for the encouragement Alanjt

 

:)

Posted

This may be of interest:

(defun AT:GetVertices (e / p l)
 ;; Return point at each vertex of curve
 ;; e - curve to evaluate (Arc, Line, *Polyline, Spline)
 ;; Alan J. Thompson, 09.30.10
 (if e
   (if (eq (setq p (vlax-curve-getEndParam e)) (fix p))
     (repeat (setq p (1+ (fix p)))
       (setq l (cons (vlax-curve-getPointAtParam e (setq p (1- p))) l))
     )
     (list (vlax-curve-getStartPoint e) (vlax-curve-getEndPoint e))
   )
 )
)

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.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...