Author Topic: Ulimate / Maxium Fillet Of Multiple Segment PLINE or Points  (Read 7756 times)

0 Members and 1 Guest are viewing this topic.

David Bethel

  • Swamp Rat
  • Posts: 656
Ulimate / Maxium Fillet Of Multiple Segment PLINE or Points
« on: March 21, 2014, 10:21:56 AM »
Greetings

I purposely made this sample the ultimate possible for the maximum fillet possible.  The end result here is that the entire pline is made of 3 arc segments.

Even if you have calculated the maximum fillet radii, the _.FILLET command would not work due the 'Too short' error.  So the end result needs top be an (entmake) POLYLINE call  with bulge factors.

In the simplest form, I would force the end points of the arcs to be a maximum 1/2 of the segment length with a straight segment connecting the 2 arcs.

Starting segments could be the exception with maximum being the smaller of the entire starting and 1\2 the distance of the 2nd segment
Ending segments could use the reverse values

Has anyone run across anything similar ?

The goal is to have a filleted path that all points reside on the original path.  And a lot fewer points than PEDIT->SPLINE or a SPLINE

TIA  -David
R12 Dos - A2K

ribarm

  • Gator
  • Posts: 3309
  • Marko Ribar, architect
Re: Ulimate / Maxium Fillet Of Multiple Segment PLINE or Points
« Reply #1 on: March 21, 2014, 01:00:58 PM »
David, try MIF.lsp for multiple lines fillet posted here :

http://www.cadtutor.net/forum/showthread.php?83651-Marquee-CHAMFER-AND-FILLET&p=#3

Also it's quite useful next code below MIF - MCHA.lsp

M.R.
Marko Ribar, d.i.a. (graduated engineer of architecture)

:)

M.R. on Youtube

David Bethel

  • Swamp Rat
  • Posts: 656
Re: Ulimate / Maxium Fillet Of Multiple Segment PLINE or Points
« Reply #2 on: March 22, 2014, 08:10:35 AM »
I'm reading and testing your code.  without a lot of sucess  Sorry  -David
R12 Dos - A2K

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
Re: Ulimate / Maxium Fillet Of Multiple Segment PLINE or Points
« Reply #3 on: March 22, 2014, 08:53:02 AM »
David,
Looking at your example I don't see how the radius of the arc is determined?
It would be easy enough to get points along the pline starting at the shortest end segment & working from that to get chord lengths & adjust for the last end segment (longer end segment).
But the arc radius question alludes me. It would stand to reason that they would need to be some ratio of the chord length to keep them smooth or similar.
Maybe I missed something.  Off for the day soon so I can't participate today.
I've reached the age where the happy hour is a nap. (°¿°)
Windows 10 core i7 4790k 4Ghz 32GB GTX 970
Please support this web site.

Lee Mac

  • Seagull
  • Posts: 12926
  • London, England
Re: Ulimate / Maxium Fillet Of Multiple Segment PLINE or Points
« Reply #4 on: March 22, 2014, 09:05:44 AM »
Here's a start David (if I've understood what you are looking for):

Code: [Select]
(defun maxfillet ( ent / lst )
    (mapcar
        (function
            (lambda ( v1 v2 v3 / a1 a2 d1 p1 p2 p3 )
                (setq a1 (angle v2 v1)
                      a2 (angle v2 v3)
                      d1 (/ (min (distance v1 v2) (distance v2 v3)) 2)
                      p1 (polar v2 a1 d1)
                      p2 (polar v2 a2 d1)
                )
                (if (setq p3 (inters p1 (polar p1 (+ a1 (/ pi 2)) 1) p2 (polar p2 (+ a2 (/ pi 2)) 1) nil))
                    (entmake
                        (vl-list*
                           '(0 . "ARC")
                            (cons 10 p3)
                            (cons 40 (distance p1 p3))
                            (mapcar 'cons '(50 51)
                                (if (minusp (sin (- a1 a2)))
                                    (list (angle p3 p2) (angle p3 p1))
                                    (list (angle p3 p1) (angle p3 p2))
                                )
                            )
                        )
                    )
                )
            )
        )
        (setq lst
            (mapcar 'cdr
                (vl-remove-if-not
                    (function
                        (lambda ( x ) (= 10 (car x)))
                    )
                    (entget ent)
                )
            )
        )
        (cdr  lst)
        (cddr lst)
    )
)

Test program:
Code: [Select]
(defun c:test ( / sel )
    (if (setq sel (ssget "_+.:E:S" '((0 . "LWPOLYLINE") (-4 . "<NOT") (-4 . "<>") (42 . 0.0) (-4 . "NOT>"))))
        (maxfillet (ssname sel 0))
    )
    (princ)
)

EDIT (improved test program):
Code: [Select]
(defun c:test ( / ent enx )
    (while
        (progn
            (setvar 'errno 0)
            (setq ent (car (entsel "\nSelect polyline: ")))
            (cond
                (   (= 7 (getvar 'errno))
                    (princ "\nMissed, try again.")
                )
                (   (null ent) nil)
                (   (/= "LWPOLYLINE" (cdr (assoc 0 (setq enx (entget ent)))))
                    (princ "\nSelected object is not a polyline.")
                )
                (   (vl-some '(lambda ( x ) (and (= 42 (car x)) (not (equal 0.0 (cdr x) 1e-8)))) enx)
                    (princ "\nSelected polyline has arc segments.")
                )
                (   (maxfillet ent))
            )
        )
    )
    (princ)
)

Demo:

« Last Edit: March 22, 2014, 09:29:03 AM by Lee Mac »

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
Re: Ulimate / Maxium Fillet Of Multiple Segment PLINE or Points
« Reply #5 on: March 22, 2014, 09:39:16 AM »
That is a good start.  8)
Only thing is that it needs to push beyond the midpoints to maximize the fillet.
I've reached the age where the happy hour is a nap. (°¿°)
Windows 10 core i7 4790k 4Ghz 32GB GTX 970
Please support this web site.

David Bethel

  • Swamp Rat
  • Posts: 656
Re: Ulimate / Maxium Fillet Of Multiple Segment PLINE or Points
« Reply #6 on: March 22, 2014, 09:48:12 AM »
Yes, it is indeed a good start.  My plan was similar only using the 3 points as the parameter.

I believe the endpoint of all fillets is @ perpendicular to the arc center point.  Therefore you can determine the center and radius.

As Lee did, the simplest would be to use 1/2 the straight segment distance as the default.

If I were to get really overboard, You could compare all of the straight segment lengths, looking for the shortest, and then itenrate through adjacent segments to fine there max lengths, until all segments were calculated

Thanks!  -David
R12 Dos - A2K

Lee Mac

  • Seagull
  • Posts: 12926
  • London, England
Re: Ulimate / Maxium Fillet Of Multiple Segment PLINE or Points
« Reply #7 on: March 22, 2014, 10:12:24 AM »
Thanks guys - 
Though as you've both already noted, its not quite the maximum possible fillet since I simply use the shortest segment midpoint  :wink:

Here is an updated version to generate a continuous polyline:
Code: [Select]
(defun maxfillet ( ent / lst )
    (setq lst
        (apply 'append
            (mapcar
                (function
                    (lambda ( v1 v2 v3 / a1 a2 d1 p1 p2 p3 )
                        (if (and v1 v2 v3
                                (setq a1 (angle v2 v1)
                                      a2 (angle v2 v3)
                                      d1 (/ (min (distance v1 v2) (distance v2 v3)) 2)
                                      p1 (polar v2 a1 d1)
                                      p2 (polar v2 a2 d1)
                                      p3 (inters p1 (polar p1 (+ a1 (/ pi 2)) 1) p2 (polar p2 (+ a2 (/ pi 2)) 1) nil)
                                )
                            )
                            (list
                                (cons 10 p1)
                                (cons 42 (tan (/ (- pi (abs (- a1 a2))) (if (minusp (- a1 a2)) -4.0 4.0))))
                                (cons 10 p2)
                            )
                            (list (cons 10 v2))
                        )
                    )
                )
                (cons 'nil
                    (setq lst
                        (mapcar 'cdr
                            (vl-remove-if-not '(lambda ( x ) (= 10 (car x)))
                                (entget ent)
                            )
                        )
                    )
                )
                lst (append (cdr lst) '(( )))
            )
        )
    )
    (entmakex
        (append
            (list
               '(000 . "LWPOLYLINE")
               '(100 . "AcDbEntity")
               '(100 . "AcDbPolyline")
                (cons  90 (length (vl-remove-if-not '(lambda ( x ) (= 10 (car x))) lst)))
                (assoc 70 (entget ent))
            )
            lst
        )
    )
)

;; Tangent  -  Lee Mac
;; Args: x - real

(defun tan ( x )
    (if (not (equal 0.0 (cos x) 1e-10))
        (/ (sin x) (cos x))
    )
)

Test program:
Code: [Select]
(defun c:test ( / ent enx )
    (while
        (progn
            (setvar 'errno 0)
            (setq ent (car (entsel "\nSelect polyline: ")))
            (cond
                (   (= 7 (getvar 'errno))
                    (princ "\nMissed, try again.")
                )
                (   (null ent) nil)
                (   (/= "LWPOLYLINE" (cdr (assoc 0 (setq enx (entget ent)))))
                    (princ "\nSelected object is not a polyline.")
                )
                (   (vl-some '(lambda ( x ) (and (= 42 (car x)) (not (equal 0.0 (cdr x) 1e-8)))) enx)
                    (princ "\nSelected polyline has arc segments.")
                )
                (   (maxfillet ent))
            )
        )
    )
    (princ)
)

ribarm

  • Gator
  • Posts: 3309
  • Marko Ribar, architect
Re: Ulimate / Maxium Fillet Of Multiple Segment PLINE or Points
« Reply #8 on: March 22, 2014, 11:37:51 AM »
I've noted that this is not what David searched for... Look into attachments; Lee can you correct it?

Meanwhile, I've modified Lee's code differently... Used Express Tools (etrim)...

Code: [Select]
(defun maxfilletop ( ent / lst )
    (mapcar
        (function
            (lambda ( v1 v2 v3 / a1 a2 d1 p1 p2 p3 )
                (setq a1 (angle v2 v1)
                      a2 (angle v2 v3)
                      d1 (/ (min (distance v1 v2) (distance v2 v3)) 2)
                      p1 (polar v2 a1 d1)
                      p2 (polar v2 a2 d1)
                )
                (if (setq p3 (inters p1 (polar p1 (+ a1 (/ pi 2)) 1) p2 (polar p2 (+ a2 (/ pi 2)) 1) nil))
                    (setq arcs
                        (cons
                            (entmakex
                                (vl-list*
                                   '(0 . "ARC")
                                    (cons 10 p3)
                                    (cons 40 (distance p1 p3))
                                    (mapcar 'cons '(50 51)
                                        (if (minusp (sin (- a1 a2)))
                                            (list (angle p3 p2) (angle p3 p1))
                                            (list (angle p3 p1) (angle p3 p2))
                                        )
                                    )
                                )
                            )
                            arcs
                        )
                    )
                )
            )
        )
        (setq lst
            (mapcar 'cdr
                (vl-remove-if-not
                    (function
                        (lambda ( x ) (= 10 (car x)))
                    )
                    (entget ent)
                )
            )
        )
        (cdr  lst)
        (cddr lst)
    )
)

(defun maxfilletcl ( ent / lst l )
    (mapcar
        (function
            (lambda ( v1 v2 v3 / a1 a2 d1 p1 p2 p3 )
                (setq a1 (angle v2 v1)
                      a2 (angle v2 v3)
                      d1 (/ (min (distance v1 v2) (distance v2 v3)) 2)
                      p1 (polar v2 a1 d1)
                      p2 (polar v2 a2 d1)
                )
                (if (setq p3 (inters p1 (polar p1 (+ a1 (/ pi 2)) 1) p2 (polar p2 (+ a2 (/ pi 2)) 1) nil))
                    (setq arcs
                        (cons
                            (entmakex
                                (vl-list*
                                   '(0 . "ARC")
                                    (cons 10 p3)
                                    (cons 40 (distance p1 p3))
                                    (mapcar 'cons '(50 51)
                                        (if (minusp (sin (- a1 a2)))
                                            (list (angle p3 p2) (angle p3 p1))
                                            (list (angle p3 p1) (angle p3 p2))
                                        )
                                    )
                                )
                            )
                            arcs
                        )
                    )
                )
            )
        )
        (setq lst
            (append
                (setq l
                    (mapcar 'cdr
                        (vl-remove-if-not
                            (function
                                (lambda ( x ) (= 10 (car x)))
                            )
                            (entget ent)
                        )
                    )
                )
                (list (car l))
                (list (cadr l))
            )
        )
        (cdr  lst)
        (cddr lst)
    )
)

(defun c:maxpolf ( / osm pea hig sel arcs c m p ss )
    (setq osm (getvar 'osmode))
    (setq pea (getvar 'peditaccept))
    (setq hig (getvar 'highlight))
    (setvar 'osmode 0)
    (setvar 'peditaccept 1)
    (load "extrim.lsp")
    (if (setq sel (ssget "_+.:E:S:L" '((0 . "LWPOLYLINE") (-4 . "<NOT") (-4 . "<>") (42 . 0.0) (-4 . "NOT>"))))
        (if (eq (logand (cdr (assoc 70 (entget (ssname sel 0)))) 1) 1)
            (progn
                (maxfilletcl (ssname sel 0))
                (setq ss (ssadd))
                (ssadd (ssname sel 0) ss)
                (foreach a arcs
                    (setq c (cdr (assoc 10 (entget a)))
                          m (polar c (if (< (cdr (assoc 50 (entget a))) (cdr (assoc 51 (entget a)))) (+ (cdr (assoc 50 (entget a))) (/ (- (cdr (assoc 51 (entget a))) (cdr (assoc 50 (entget a)))) 2.0)) (+ (cdr (assoc 50 (entget a))) (/ (+ (cdr (assoc 51 (entget a))) (- (* 2.0 pi) (cdr (assoc 50 (entget a))))) 2.0))) (cdr (assoc 40 (entget a))))
                          p (mapcar '+ c (mapcar '* (mapcar '- m c) (list 1.003 1.003 1.003)))
                    )
                    (etrim a p)
                    (ssadd a ss)
                    (ssadd (entlast) ss)
                )
                (command "_.pedit" "_M" ss "" "_J")
                (while (> (getvar 'cmdactive) 0) (command ""))
            )
            (progn
                (maxfilletop (ssname sel 0))
                (setq ss (ssadd))
                (ssadd (ssname sel 0) ss)
                (foreach a arcs
                    (setq c (cdr (assoc 10 (entget a)))
                          m (polar c (if (< (cdr (assoc 50 (entget a))) (cdr (assoc 51 (entget a)))) (+ (cdr (assoc 50 (entget a))) (/ (- (cdr (assoc 51 (entget a))) (cdr (assoc 50 (entget a)))) 2.0)) (+ (cdr (assoc 50 (entget a))) (/ (+ (cdr (assoc 51 (entget a))) (- (* 2.0 pi) (cdr (assoc 50 (entget a))))) 2.0))) (cdr (assoc 40 (entget a))))
                          p (mapcar '+ c (mapcar '* (mapcar '- m c) (list 1.003 1.003 1.003)))
                    )
                    (etrim a p)
                    (ssadd a ss)
                    (ssadd (entlast) ss)
                )
                (command "_.pedit" "_M" ss "" "_J")
                (while (> (getvar 'cmdactive) 0) (command ""))
            )               
        )
    )
    (setvar 'osmode osm)
    (setvar 'peditaccept pea)
    (setvar 'highlight hig)
    (princ)
)

Lee thanks for your input... We are all looking forward to see correct solution if you have some spare time for this task...

@David, my code (MIF.lsp) is working only with connected LINE entities and I also used mid point calculation based on minimal length of picked lines, so it's also wrong code, but I use it anyway as it can tell me what is max. radius for FILLET "Polyline" option...

M.R.
« Last Edit: March 22, 2014, 12:28:50 PM by ribarm »
Marko Ribar, d.i.a. (graduated engineer of architecture)

:)

M.R. on Youtube

Lee Mac

  • Seagull
  • Posts: 12926
  • London, England
Re: Ulimate / Maxium Fillet Of Multiple Segment PLINE or Points
« Reply #9 on: March 22, 2014, 12:22:03 PM »
Here is an updated version to correctly process the start/end segments & handle closed polylines:
Code: [Select]
(defun maxfillet ( ent / enx lst opn )
    (setq enx (entget ent)
          lst (mapcar 'cdr (vl-remove-if-not '(lambda ( x ) (= 10 (car x))) enx))
          opn (zerop (logand 1 (cdr (assoc 70 enx))))
    )
    (setq lst
        (apply 'append
            (apply 'mapcar
                (cons
                    (function
                        (lambda ( v1 v2 v3 / a1 a2 d1 p1 p2 p3 )
                            (if
                                (and v1 v2 v3
                                    (setq
                                        a1 (angle v2 v1)
                                        a2 (angle v2 v3)
                                        d1 (cond
                                               (   (and opn (equal v1 (car lst) 1e-8))
                                                   (/ (min (* 2 (distance v1 v2)) (distance v2 v3)) 2.0)
                                               )
                                               (   (and opn (equal v3 (last lst) 1e-8))
                                                   (/ (min (distance v1 v2) (* 2 (distance v2 v3))) 2.0)
                                               )
                                               (   (/ (min (distance v1 v2) (distance v2 v3)) 2.0))
                                           )
                                        p1 (polar v2 a1 d1)
                                        p2 (polar v2 a2 d1)
                                        p3 (inters p1 (polar p1 (+ a1 (/ pi 2)) 1) p2 (polar p2 (+ a2 (/ pi 2)) 1) nil)
                                    )
                                )
                                (list
                                    (cons 10 p1)
                                    (cons 42 (tan (/ (- pi (abs (- a1 a2))) (if (minusp (- a1 a2)) -4.0 4.0))))
                                    (cons 10 p2)
                                )
                                (list (cons 10 v2))
                            )
                        )
                    )
                    (if opn
                        (list (cons 'nil lst) lst (append (cdr lst) '(nil)))
                        (list (cons (last lst) lst) lst (append (cdr lst) (list (car lst))))
                    )
                )
            )
        )
    )
    (entmakex
        (append
            (list
               '(000 . "LWPOLYLINE")
               '(100 . "AcDbEntity")
               '(100 . "AcDbPolyline")
                (cons  90 (length (vl-remove-if-not '(lambda ( x ) (= 10 (car x))) lst)))
                (assoc 70 (entget ent))
            )
            lst
        )
    )
)

;; Tangent  -  Lee Mac
;; Args: x - real

(defun tan ( x )
    (if (not (equal 0.0 (cos x) 1e-10))
        (/ (sin x) (cos x))
    )
)

Test program:
Code: [Select]
(defun c:test ( / ent enx )
    (while
        (progn
            (setvar 'errno 0)
            (setq ent (car (entsel "\nSelect polyline: ")))
            (cond
                (   (= 7 (getvar 'errno))
                    (princ "\nMissed, try again.")
                )
                (   (null ent) nil)
                (   (/= "LWPOLYLINE" (cdr (assoc 0 (setq enx (entget ent)))))
                    (princ "\nSelected object is not a polyline.")
                )
                (   (vl-some '(lambda ( x ) (and (= 42 (car x)) (not (equal 0.0 (cdr x) 1e-8)))) enx)
                    (princ "\nSelected polyline has arc segments.")
                )
                (   (maxfillet ent))
            )
        )
    )
    (princ)
)

Demo:


ribarm

  • Gator
  • Posts: 3309
  • Marko Ribar, architect
Re: Ulimate / Maxium Fillet Of Multiple Segment PLINE or Points
« Reply #10 on: March 22, 2014, 02:21:23 PM »
Here, this should satisfy your request David... Just when prompted hit ENTER - open LWPOLYLINES are now processed different... Still it may not satisfy all possible situations... But for your case (drawn posted animated gif) it should do correct... Also added (clean_poly) sub-function by Gilles and many many thanks to wonderful code by Mr. Lee Mac... (If it doesn't do correct on your example David, try reversing LWPOLYLINE and restart routine)

Code: [Select]
(defun clean_poly ( ent / trunc e_lst p_lst )

  (defun trunc ( expr lst )
    (if (and lst (not (equal (car lst) expr)))
      (cons (car lst) (trunc expr (cdr lst)))
    )
  )

  (setq e_lst (entget ent))
  (if (= "LWPOLYLINE" (cdr (assoc 0 e_lst)))
    (progn
      (setq p_lst
                  (vl-remove-if-not
                   '(lambda (x)
                      (or (= (car x) 10)
                          (= (car x) 40)
                          (= (car x) 41)
                          (= (car x) 42)
                      )
                    )
                    e_lst
                  )
            e_lst
                  (vl-remove-if
                   '(lambda (x)
                      (member x p_lst)
                    )
                    e_lst
                  )
      )
      (if (= 1 (logand (cdr (assoc 70 e_lst)) 1))
        (while (equal (car p_lst) (assoc 10 (reverse p_lst)))
          (setq p_lst (reverse (cdr (member (assoc 10 (reverse p_lst)) (reverse p_lst)))))
        )
      )
      (while p_lst
        (setq e_lst (append e_lst (trunc (assoc 10 (cdr p_lst)) p_lst))
              p_lst (member (assoc 10 (cdr p_lst)) (cdr p_lst))
        )
      )
      (entmod e_lst)
    )
  )
  (princ)
)

(defun maxfillet ( ent / enx lst opn ch p1 p2 )
    (setq enx (entget ent)
          lst (mapcar 'cdr (vl-remove-if-not '(lambda ( x ) (= 10 (car x))) enx))
          opn (zerop (logand 1 (cdr (assoc 70 enx))))
    )
    (if opn
        (progn
            (initget "Continuation Segmentation")
            (setq ch  (getkword "\nCalculate arcs from starting arcs continuation or minimal segment distances for open polyline (Continuation/Segmentation) <Continuation> : "))
        )
    )
    (setq lst
        (apply 'append
            (apply 'mapcar
                (cons
                    (function
                        (lambda ( v1 v2 v3 / a1 a2 d1 p3 )
                            (if
                                (and v1 v2 v3
                                    (setq
                                        a1 (angle v2 v1)
                                        a2 (angle v2 v3)
                                        d1 (cond
                                               (   (and opn (equal v1 (car lst) 1e-8))
                                                   (/ (min (* 2 (distance v1 v2)) (distance v2 v3)) 2.0)
                                               )
                                               (   (and opn (equal v3 (last lst) 1e-8))
                                                   (/ (min (distance v1 v2) (* 2 (distance v2 v3))) 2.0)
                                               )
                                               (   (/ (min (distance v1 v2) (distance v2 v3)) 2.0))
                                           )
                                        p1 (if (and opn p2 (or (eq ch nil) (eq ch "Continuation"))) (if (< (distance v1 v2) (distance v2 v3)) p2 (if (> d1 (distance v2 p2)) p2 (polar v2 a1 d1))) (if (and opn (or (eq ch nil) (eq ch "Continuation")) (< (distance v1 v2) (distance v2 v3))) (polar v2 a1 (distance v1 v2)) (polar v2 a1 d1)))
                                        p2 (if (and opn (or (eq ch nil) (eq ch "Continuation")) (< (distance v2 p1) (distance v2 v3))) (polar v2 a2 (distance v2 p1)) (polar v2 a2 d1))
                                        p3 (inters p1 (polar p1 (+ a1 (/ pi 2)) 1) p2 (polar p2 (+ a2 (/ pi 2)) 1) nil)
                                    )
                                )
                                (list
                                    (cons 10 p1)
                                    (cons 42 (tan (/ (- pi (abs (- a1 a2))) (if (minusp (- a1 a2)) -4.0 4.0))))
                                    (cons 10 p2)
                                )
                                (list (cons 10 v2))
                            )
                        )
                    )
                    (if opn
                        (list (cons 'nil lst) lst (append (cdr lst) '(nil)))
                        (list (cons (last lst) lst) lst (append (cdr lst) (list (car lst))))
                    )
                )
            )
        )
    )
    (entmakex
        (append
            (list
               '(000 . "LWPOLYLINE")
               '(100 . "AcDbEntity")
               '(100 . "AcDbPolyline")
                (cons  90 (length (vl-remove-if-not '(lambda ( x ) (= 10 (car x))) lst)))
                (assoc 70 (entget ent))
            )
            lst
        )
    )
)

(defun tan ( x )
    (if (not (equal 0.0 (cos x) 1e-10))
        (/ (sin x) (cos x))
    )
)

(defun remstenvert ( ent / entx prexlst memblst sufxlst )
    (if (and
            (eq (cdr (assoc 0 (setq entx (entget ent)))) "LWPOLYLINE")
            (eq (logand (cdr (assoc 70 (entget ent))) 1) 0)
        )
        (cond ( (and  (equal (assoc 10 entx) (assoc 10 (cdr (member (assoc 10 entx) entx))) 1e-3)
                      (equal (assoc 10 (reverse entx)) (assoc 10 (cdr (member (assoc 10 (reverse entx)) (reverse entx)))) 1e-3)
                )
                (progn
                    (setq memblst (member (assoc 10 entx) entx))
                    (setq memblst (member (assoc 10 (cdr memblst)) memblst))
                    (setq memblst (reverse (cdr (member (assoc 10 (reverse memblst)) (reverse memblst)))))
                    (setq prexlst (vl-remove-if '(lambda ( x ) (or (= 10 (car x)) (= 40 (car x)) (= 41 (car x)) (= 42 (car x)) (= 91 (car x)) (= 210 (car x)))) entx))
                    (setq prexlst (subst (cons 90 (length (vl-remove-if-not '(lambda ( x ) (= 10 (car x))) memblst))) (assoc 90 prexlst) prexlst))
                    (setq sufxlst (list (assoc 210 entx)))
                    (entmod (append prexlst memblst sufxlst))
                    (entupd (cdr (assoc -1 entx)))
                )
              )
              ( (and  (equal (assoc 10 entx) (assoc 10 (cdr (member (assoc 10 entx) entx))) 1e-3)
                      (not (equal (assoc 10 (reverse entx)) (assoc 10 (cdr (member (assoc 10 (reverse entx)) (reverse entx)))) 1e-3))
                )
                (progn
                    (setq memblst (member (assoc 10 entx) entx))
                    (setq memblst (member (assoc 10 (cdr memblst)) memblst))
                    (setq prexlst (vl-remove-if '(lambda ( x ) (or (= 10 (car x)) (= 40 (car x)) (= 41 (car x)) (= 42 (car x)) (= 91 (car x)) (= 210 (car x)))) entx))
                    (setq prexlst (subst (cons 90 (length (vl-remove-if-not '(lambda ( x ) (= 10 (car x))) memblst))) (assoc 90 prexlst) prexlst))
                    (setq sufxlst (list (assoc 210 entx)))
                    (entmod (append prexlst memblst sufxlst))
                    (entupd (cdr (assoc -1 entx)))
                )
              )
              ( (and  (not (equal (assoc 10 entx) (assoc 10 (cdr (member (assoc 10 entx) entx))) 1e-3))
                      (equal (assoc 10 (reverse entx)) (assoc 10 (cdr (member (assoc 10 (reverse entx)) (reverse entx)))) 1e-3)
                )
                (progn
                    (setq memblst (member (assoc 10 entx) entx))
                    (setq memblst (reverse (cdr (member (assoc 10 (reverse memblst)) (reverse memblst)))))
                    (setq prexlst (vl-remove-if '(lambda ( x ) (or (= 10 (car x)) (= 40 (car x)) (= 41 (car x)) (= 42 (car x)) (= 91 (car x)) (= 210 (car x)))) entx))
                    (setq prexlst (subst (cons 90 (length (vl-remove-if-not '(lambda ( x ) (= 10 (car x))) memblst))) (assoc 90 prexlst) prexlst))
                    (setq sufxlst (list (assoc 210 entx)))
                    (entmod (append prexlst memblst sufxlst))
                    (entupd (cdr (assoc -1 entx)))
                )
              )
              ( (and  (not (equal (assoc 10 entx) (assoc 10 (cdr (member (assoc 10 entx) entx))) 1e-3))
                      (not (equal (assoc 10 (reverse entx)) (assoc 10 (cdr (member (assoc 10 (reverse entx)) (reverse entx)))) 1e-3))
                )
                (entupd (cdr (assoc -1 entx)))
              )
        )       
    )
)

(defun c:maxpolf ( / ent enx )
    (if (not ent)
        (progn
            (setvar 'errno 0)
            (setq ent (car (entsel "\nSelect polyline: ")))
            (cond
                (   (= 7 (getvar 'errno))
                    (princ "\nMissed, try again.")
                )
                (   (null ent) nil)
                (   (/= "LWPOLYLINE" (cdr (assoc 0 (setq enx (entget ent)))))
                    (princ "\nSelected object is not a polyline.")
                )
                (   (vl-some '(lambda ( x ) (and (= 42 (car x)) (not (equal 0.0 (cdr x) 1e-8)))) enx)
                    (princ "\nSelected polyline has arc segments.")
                )
                (   t
                    (maxfillet ent)
                    (clean_poly (entlast))
                    (remstenvert (entlast))
                )
            )
        )
    )
    (princ)
)

Regards, M.R.
« Last Edit: March 24, 2014, 02:36:12 PM by ribarm »
Marko Ribar, d.i.a. (graduated engineer of architecture)

:)

M.R. on Youtube

ribarm

  • Gator
  • Posts: 3309
  • Marko Ribar, architect
Re: Ulimate / Maxium Fillet Of Multiple Segment PLINE or Points
« Reply #11 on: March 22, 2014, 05:43:24 PM »
After many tries, this last posted version satisfies my needs - it's something between maximum possible arcs solution and correct version that can process any open LWPOLYLINE... You have to test it to see if it fits your needs (I am satisfied).

M.R.
Marko Ribar, d.i.a. (graduated engineer of architecture)

:)

M.R. on Youtube

David Bethel

  • Swamp Rat
  • Posts: 656
Re: Ulimate / Maxium Fillet Of Multiple Segment PLINE or Points
« Reply #12 on: March 24, 2014, 08:20:33 AM »
Sorry,  Messed up my back with yard work and haven't been able to do much.  Hopefully I can sit for more than 2 minutes in any 1 position today.
R12 Dos - A2K

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
Re: Ulimate / Maxium Fillet Of Multiple Segment PLINE or Points
« Reply #13 on: March 24, 2014, 09:30:13 AM »
<thread hijack-on>
I'm here to tell you that Yard Work is hazardous to your health!
Took some plants I removed to the dump & while unloading them got tangled up & fell on my elbow.
After two & half weeks I can touch my elbow to the armrest to move the mouse again.
It's cheaper to have those young guys do that stuff.  8)
<thread hijack-off>
I've reached the age where the happy hour is a nap. (°¿°)
Windows 10 core i7 4790k 4Ghz 32GB GTX 970
Please support this web site.

David Bethel

  • Swamp Rat
  • Posts: 656
Re: Ulimate / Maxium Fillet Of Multiple Segment PLINE or Points
« Reply #14 on: March 24, 2014, 12:05:40 PM »
<thread hijack-on>
I'm here to tell you that Yard Work is hazardous to your health!
<thread hijack-off>

Cleaning out a fish pond.  Water lily in 8" pot ended up 100 lbs + massive root ball - groaning all the way.  -David
R12 Dos - A2K