Kowal Posted March 19, 2015 Posted March 19, 2015 Hi. I choose the LWPOLYLINE using a ENTSEL function. Using code. (setq cor (vlax-get (vlax-ename->vla-object (car (entsel))) 'coordinates)) Always get. '(1x 1y 2x 2y 3x 3y ...) How to get a list of coordinates, depending on which side you choose an LWPOLYLINE? Example: Select segment on side 1-2. Get: '(1x 1y 2x 2y 3x 3y ...) Select segment on side 4-5. Get: '(5x 5y 4x 4y 3x 3y ...) Quote
Tharwat Posted March 19, 2015 Posted March 19, 2015 Try this . (if (and (setq s (entsel "\n Pick a LWPOLYLINE :")) (eq (cdr (assoc 0 (entget (car s)))) "LWPOLYLINE") (mapcar '(lambda (p) (if (eq (car p) 10) (setq lst (cons (cdr p) lst)) ) ) (entget (setq o (car s))) ) ) (if (< (distance (cadr s) (vlax-curve-getstartpoint o)) (distance (cadr s) (vlax-curve-getendpoint o))) (setq lst (reverse lst)) ) ) Quote
Lee Mac Posted March 19, 2015 Posted March 19, 2015 Try this . (if (and (setq s (entsel "\n Pick a LWPOLYLINE :")) (eq (cdr (assoc 0 (entget (car s)))) "LWPOLYLINE") ) (progn (mapcar '(lambda (p) (if (eq (car p) 10) (setq lst (cons (cdr p) lst)) ) ) (entget (setq o (car s))) ) (if (< (distance (cadr s) (vlax-curve-getstartpoint o)) (distance (cadr s) (vlax-curve-getendpoint o))) (setq lst (reverse lst)) ) ) ) What about polylines such as this? (entmake '( (000 . "LWPOLYLINE") (100 . "AcDbEntity") (100 . "AcDbPolyline") (90 . 5) (70 . 0) (10 0.0 0.0) (10 1.0 0.0) (10 1.0 1.0) (10 -0.01 1.0) (10 -0.01 -4.0) ) ) Quote
Lee Mac Posted March 19, 2015 Posted March 19, 2015 I would suggest something along the lines of: (defun c:test ( / e l s x ) (if (and (setq s (entsel "\nSelect polyline: ")) (= "LWPOLYLINE" (cdr (assoc 0 (setq x (entget (setq e (car s))))))) (setq l (mapcar 'cdr (vl-remove-if-not '(lambda ( x ) (= 10 (car x))) x))) ) (if (< (/ (vlax-curve-getdistatparam e (vlax-curve-getendparam e)) 2.0) (vlax-curve-getdistatpoint e (vlax-curve-getclosestpointto e (trans (cadr s) 1 0))) ) (reverse l) l ) ) ) (vl-load-com) (princ) Quote
Tharwat Posted March 19, 2015 Posted March 19, 2015 What about polylines such as this? I intended to use the vlax-curve-getdistatpoint function and I don't know why I have changed my mind , though my first codes in my first post earlier should work as per the OP's requirements . Anyway that easily could be handled somehow to cover other shapes of LWpolylines as Lee's example . (defun c:Test (/ s o lst) (if (and (setq s (entsel "\n Pick a LWPOLYLINE :")) (eq (cdr (assoc 0 (entget (setq o (car s))))) "LWPOLYLINE") (mapcar '(lambda (p) (if (eq (car p) 10) (setq lst (cons (cdr p) lst)) ) ) (entget o) ) ) (if (> (vlax-curve-getdistatpoint o (vlax-curve-getclosestpointto o (cadr s))) (vlax-curve-getdistatparam o (vlax-curve-getendparam o)) ) (setq lst (reverse lst)) ) ) lst )(vl-load-com) Quote
Stefan BMR Posted March 19, 2015 Posted March 19, 2015 Recently, I had exactly the same issue to solve. First, I had to determine where the polyline is picked. After seeing Lee's code here, I did realize my code doesn't work on any UCS/View. But the (trans p 1 0) doesn't do the trick either. This could be a valid solution for every situation, but I let the debate open, as I am not so sure. (vlax-curve-getclosestpointtoprojection e (trans p 1 0) (trans (getvar 'viewdir) 1 0 T)) Quote
BIGAL Posted March 20, 2015 Posted March 20, 2015 A simple method I use is to always say "pick start end" the idea here being if you are going to do say offsets you know which is left and right, even when the pick is up side down as per your image. The only problem I can see is with closed plines you probably need a pick again option with say a Circle indicating start point. 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.