mousho Posted September 9, 2021 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
Jonathan Handojo Posted September 9, 2021 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
mousho Posted September 12, 2021 Author 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
mousho Posted May 2 Author Posted May 2 Jonathan i need your help again How can i find the Vertics of the shortest section in a specific polyline Quote
Jonathan Handojo Posted May 3 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
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.