Lt Dan's legs Posted February 22, 2011 Posted February 22, 2011 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. I'm able to get this by comparing angles and sorting by distance but there must be a better way. Quote
designerstuart Posted February 22, 2011 Posted February 22, 2011 you just want to select the line and have its endpoints returned as coordinates? Quote
Lt Dan's legs Posted February 22, 2011 Author Posted February 22, 2011 I want to select a polyline and have it return the start and end point of that segment What I'm using this for https://sites.google.com/site/reidbooe/videos and view door.avi Quote
alanjt Posted February 22, 2011 Posted February 22, 2011 (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)) Quote
Lt Dan's legs Posted February 22, 2011 Author Posted February 22, 2011 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!! Quote
pBe Posted February 23, 2011 Posted February 23, 2011 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 Quote
alanjt Posted February 23, 2011 Posted February 23, 2011 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. Quote
pBe Posted February 24, 2011 Posted February 24, 2011 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 (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) Quote
alanjt Posted February 24, 2011 Posted February 24, 2011 Yeah, I could see where you'd have problems with vertices being close together. I still like it. Quote
pBe Posted February 26, 2011 Posted February 26, 2011 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 Quote
alanjt Posted February 26, 2011 Posted February 26, 2011 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)) ) ) ) Quote
Recommended Posts
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.