mousho Posted September 9, 2021 Share Posted September 9, 2021 Hi friends How can i find the Vertics of the longest section in a specific polyline and then i need to find the mid and the angle of this section. until now i used this lisp that find the middle of entire polyline Quote (defun pmid6 (/ ss) (vl-load-com) (setq se6 (ssget ":S" '((0 . "LINE,SPLINE,LWPOLYLINE,POLYLINE,ARC,CIRCLE,ELLIPSE")))) (setq se6e (ssname se6 0)) (setq p_mid (vlax-curve-GetPointAtDist se6e (/ (vlax-curve-GetDistAtParam se6e (vlax-curve-GetEndParam se6e)) 2) ) ) (setq p_midd (vlax-curve-GetPointAtDist se6e (/ (vlax-curve-GetDistAtParam se6e (vlax-curve-GetEndParam se6e)) 2.01) ) ) (setq anglstR (angle p_midd p_mid)) (setq rot (/ (* anglstR 180.0) pi)) );defun Quote Link to comment Share on other sites More sharing options...
Jonathan Handojo Posted September 9, 2021 Share Posted September 9, 2021 (edited) ;; For polylines ONLY. Points returned in WCS (defun foo (ent / d dis i m pm p) (setq i 0 p 0.0 m 0.0) (while (setq i (1+ i) d (vlax-curve-getdistatparam ent i)) (if (< m (setq dis (- d p))) (setq m dis pm (1- i))) (setq p d) ) (list (vlax-curve-getpointatparam ent pm) ; Start Vertex (vlax-curve-getpointatparam ent (1+ pm)) ; End Vertex (vlax-curve-getpointatparam ent (setq pm (+ 0.5 pm))) ; Mid Vertex (angle '(0.0 0.0 0.0) (vlax-curve-getfirstderiv ent pm)) ; Angle at mid vertex ) ) Edited September 10, 2021 by Jonathan Handojo 1 Quote Link to comment Share on other sites More sharing options...
mousho Posted September 12, 2021 Author Share Posted September 12, 2021 On 9/9/2021 at 6:27 PM, Jonathan Handojo said: ;; For polylines ONLY. Points returned in WCS (defun foo (ent / d dis i m pm p) (setq i 0 p 0.0 m 0.0) (while (setq i (1+ i) d (vlax-curve-getdistatparam ent i)) (if (< m (setq dis (- d p))) (setq m dis pm (1- i))) (setq p d) ) (list (vlax-curve-getpointatparam ent pm) ; Start Vertex (vlax-curve-getpointatparam ent (1+ pm)) ; End Vertex (vlax-curve-getpointatparam ent (setq pm (+ 0.5 pm))) ; Mid Vertex (angle '(0.0 0.0 0.0) (vlax-curve-getfirstderiv ent pm)) ; Angle at mid vertex ) ) thx Jonathan Quote Link to comment Share on other sites More sharing options...
mousho Posted May 2 Author Share Posted May 2 Jonathan i need your help again How can i find the Vertics of the shortest section in a specific polyline Quote Link to comment Share on other sites More sharing options...
Jonathan Handojo Posted May 3 Share Posted May 3 Something like this? ;; For polylines ONLY. Points returned in WCS (defun foo (ent / d dis i m pm p) (setq i 0 p 0.0 m (vlax-curve-getdistatparam ent 1)) (while (setq i (1+ i) d (vlax-curve-getdistatparam ent i)) (and (<= (setq dis (- d p)) m) (setq m dis pm (1- i))) (setq p d) ) (list (vlax-curve-getpointatparam ent pm) ; Start Vertex (vlax-curve-getpointatparam ent (1+ pm)) ; End Vertex (vlax-curve-getpointatparam ent (setq pm (+ 0.5 pm))) ; Mid Vertex (angle '(0.0 0.0 0.0) (vlax-curve-getfirstderiv ent pm)) ; Angle at mid vertex ) ) 1 Quote Link to comment Share on other sites More sharing options...
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.