Jump to content

Longest section in Polyline


mousho

Recommended Posts

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

 

Link to comment
Share on other sites

;; 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 by Jonathan Handojo
  • Like 1
Link to comment
Share on other sites

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 :)

Link to comment
Share on other sites

  • 2 years later...

Jonathan i need your help again :)

How can i find the Vertics of the shortest section in a specific polyline

Link to comment
Share on other sites

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
    )
)

 

  • Like 1
Link to comment
Share on other sites

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...