fillet and join lines

fillet and join lines

leticia.campanelli
Advocate Advocate
865 Views
12 Replies
Message 1 of 13

fillet and join lines

leticia.campanelli
Advocate
Advocate

Hi there,

 

I am wondering if someone has a lisp for fillet and join lines. 

 

Thanks

0 Likes
866 Views
12 Replies
Replies (12)
Message 2 of 13

Kent1Cooper
Consultant
Consultant

I would guess that such a thing is out there somewhere for the Searching [but I'll let you Search].

 

But if not, are you talking about only Line objects specifically, or anything Filletable?  And at any radius including zero [meaning there may or may not be a new Arc resulting from the command]?

Kent Cooper, AIA
0 Likes
Message 3 of 13

Moshe-A
Mentor
Mentor

@leticia.campanelli  hi,

 

by saying join lines you mean that after fillet you want the outcome to be a pline?

 

Moshe

 

0 Likes
Message 4 of 13

pendean
Community Legend
Community Legend
@leticia.campanelli Fillet and Join together as one LISP? Please explain and show circumstances where you need that please, so we have a better idea of your goals here.

Otherwise... F is for FILLET and J is for JOIN, what more do you need those to do, please elaborate and be very specific.
0 Likes
Message 5 of 13

Sea-Haven
Mentor
Mentor

Like others Join into a pline then, Fillet, Polyline, for common radius in all segments.

0 Likes
Message 6 of 13

leticia.campanelli
Advocate
Advocate

Hi

sorry I wasn't clear.

I meant selecting lines fillet with zero radius and join them in one go so it turns into a Pline.

thanks

 

0 Likes
Message 7 of 13

pendean
Community Legend
Community Legend

@leticia.campanelli wrote:

Hi

sorry I wasn't clear.

I meant selecting lines fillet with zero radius and join them in one go so it turns into a Pline.

thanks

 


How would the LISP know which ends of lines to FILLET to keep? Is there a static criteria that always shows up in your files?

What is it you are trying to create with this tool: can you show us a bunch of screenshots before/after type?

 

 

0 Likes
Message 8 of 13

CADaSchtroumpf
Advisor
Advisor

Does this meet your need?

 

 

(defun det_wh (px p1 p2 / v1 v2 det_or)
  (setq
    v1 (mapcar '- p2 p1)
    v2 (mapcar '- px p1)
  )
  (if (> (apply '(lambda (x1 y1 z1 x2 y2 z2) (- (* x1 y2) (* y1 x2))) (append v1 v2)) 0.0) 1 -1)
)
(defun k_th (p1 p2 c / k)
  (setq k (/ c (distance p1 p2)))
  (mapcar '+ (mapcar '* (mapcar '- p2 p1) (list k k k)) p1)
)
(defun c:fillet0lw ( / ps1 ps2 js1 js2 dxf_210 pt_lst pt l3)
  (princ "\nSelect the first line: ")
  (while (or (null (setq js1 (entsel))) (/= (cdr (assoc 0 (entget (car js1)))) "LINE")))
  (princ "\nSelect the second line: ")
  (while (or (null (setq js2 (entsel))) (/= (cdr (assoc 0 (entget (car js2)))) "LINE")))
  (setq
    ps1 (trans (cadr js1) 1 0)
    ps2 (trans (cadr js2) 1 0)
    js1 (entget (car js1))
    js2 (entget (car js2))
    dxf_210 (cdr (assoc 210 js1))
    pt_lst (list (cdr (assoc 10 js1)) (cdr (assoc 11 js1)) (cdr (assoc 10 js2)) (cdr (assoc 11 js2)))
    pt_lst (mapcar '(lambda (x) (trans (trans x (cdar js1) 1) 1 dxf_210)) pt_lst)
    pt (inters (car pt_lst) (cadr pt_lst) (caddr pt_lst) (cadddr pt_lst) nil)
  )
  (cond
    (pt
      (if (eq (det_wh (cadddr pt_lst) (car pt_lst) (cadr pt_lst)) (det_wh (caddr pt_lst) (car pt_lst) (cadr pt_lst)))
        (if (> (distance pt (caddr pt_lst)) (distance pt (cadddr pt_lst)))
          (setq l3 (list pt (caddr pt_lst)))
          (setq l3 (list pt (cadddr pt_lst)))
        )
        (if (eq (det_wh ps2 (car pt_lst) (cadr pt_lst)) (det_wh (caddr pt_lst) (car pt_lst) (cadr pt_lst)))
          (setq l3 (list pt (caddr pt_lst)))
          (setq l3 (list pt (cadddr pt_lst)))
        )
      )
      (if (eq (det_wh (cadr pt_lst) (caddr pt_lst) (cadddr pt_lst)) (det_wh (car pt_lst) (caddr pt_lst) (cadddr pt_lst)))
        (if (> (distance pt (car pt_lst)) (distance pt (cadr pt_lst)))
          (setq l3 (cons (car pt_lst) l3))
          (setq l3 (cons (cadr pt_lst) l3))
        )
        (if (eq (det_wh ps1 (caddr pt_lst) (cadddr pt_lst)) (det_wh (car pt_lst) (caddr pt_lst) (cadddr pt_lst)))
          (setq l3 (cons (car pt_lst) l3))
          (setq l3 (cons (cadr pt_lst) l3))
        )
      )
      (entdel (cdar js1))
      (entdel (cdar js2))
      (entmake
        (append
          (list
            '(0 . "LWPOLYLINE")
            '(100 . "AcDbEntity")
            (assoc 67 js1)
            (assoc 410 js1)
            (assoc 8 js1)
            (if (assoc 62 js1) (assoc 62 js1) (cons 62 256))
            (if (assoc 6 js1) (assoc 6 js1) (cons 6 "BYLAYER"))
            '(100 . "AcDbPolyline")
            '(90 . 3)
            '(70 . 0)
            '(43 . 0.0)
            (cons 38 0.0)
            (cons 39 (getvar "THICKNESS"))
            (cons 10 (car l3))
            '(40 . 0.0)
            '(41 . 0.0)
            '(42 . 0.0)
            '(91 . 0)
            (cons 10 (cadr l3))
            '(40 . 0.0)
            '(41 . 0.0)
            '(42 . 0.0)
            '(91 . 0)
            (cons 10 (caddr l3))
            '(40 . 0.0)
            '(41 . 0.0)
            '(42 . 0.0)
            '(91 . 0)
            (cons 210 dxf_210)
          )
        )
      )
    )
    (T
      (princ "\nCan't fillet lines in differents planes!")
    )
  )
  (prin1)
)

 

0 Likes
Message 9 of 13

pendean
Community Legend
Community Legend
@CADaSchtroumpf The LISP only works on two lines, stops working on any PLINE it creates if the user needs more than two lines completed.
0 Likes
Message 10 of 13

Kent1Cooper
Consultant
Consultant

@leticia.campanelli wrote:

.... selecting lines fillet with zero radius and join them in one go so it turns into a Pline. ....


Won't something as simple as this do?

 

(defun C:FZJ ; = Fillet at Zero radius and Join
  (/ L1 L2)
  (setvar 'filletrad 0)
  (setq L1 (entsel "\nFirst Line/Arc to FZJ: "))
  (redraw (car L1) 3)
  (setq L2 (entsel "\nSecond Line/Arc to FZJ: "))
  (command "_.fillet" (cadr L1) (cadr L2))
  (initcommandversion)
  (command "_join" (car L1) (car L2) "")
  (prin1)
)

 

[Somehow, without the (initcommandversion), the JOIN command doesn't operate as expected from inside an AutoLisp (command) function.]

It works with Arcs as well as Lines [you never explicitly answered my question about whether you meant Line objects specifically, but I assume that], and with Polylines, too, though in that case you need to give it an extra Enter to finish selection in the JOIN command.

Kent Cooper, AIA
0 Likes
Message 11 of 13

pendean
Community Legend
Community Legend

@Kent1Cooper wrote:

@leticia.campanelli wrote:

.... selecting lines fillet with zero radius and join them in one go so it turns into a Pline. ....


Won't something as simple as this do?

 


The simplest old-school workflow is to convert the first picked line to a PLINE, then just FILLET away until you run out of lines to "join".

0 Likes
Message 12 of 13

Kent1Cooper
Consultant
Consultant

@pendean wrote:
.... convert the first picked line to a PLINE, then just FILLET away ....

An interesting thought.  If the OP would still want to use it on only two things:

(defun C:FZJ ; = Fillet at Zero radius and Join
  (/ L1)
  (setvar 'filletrad 0)
  (setvar 'peditaccept 1)
  (setq L1 (entsel "\nFirst Line/Arc to FZJ: "))
  (command
    "_.pedit" (car L1) ""
    "_.fillet" (cadr L1)
  )
  (prin1)
)

But it has drawbacks in relation to Arcs [which they may not care about].  You can't Fillet a Polyline and an Arc, or a Polyline arc segment and a Line, but you can two Polylines, whether line or arc segments.  So the above doesn't work if the second thing picked is an Arc, but it does if it's a Polyline arc.  And if the first thing picked is an Arc, it doesn't work if the second one is a Line, but it does if it it's a Polyline line.  It could overcome that with more code, by also converting the second thing to a Polyline before Filleting.

Kent Cooper, AIA
0 Likes
Message 13 of 13

Sea-Haven
Mentor
Mentor

This works with lines only adding arcs complicates things. In code below maybe can erase arc then ask for next segment. Need some true examples in a supplied dwg. It also relies on a bit of common sense when picking objects so fillet will work.

 

 

; simple fillet multi lines with radius zero
; By AlanH July 2024

(defun c:F0 ( / L1 pt typ ent)
(setvar 'filletrad 0)
(setvar 'peditaccept 1)

(setq L1 (entsel "\nFirst Line/Arc to FZJ: "))
(setq pt (cadr l1))
(setq typ (cdr (assoc 0 (entget (car l1)))))

(if (= typ "LWPOLYLINE")
  (princ)
  (command "pedit" (car l1) "")
)

(while (setq ent (entsel "\nPick next line - arc Enter to exit "))
(command "Fillet" pt (cadr ent))
(setq pt (cadr ent))
)

(princ)
)
(c:f0)

 

0 Likes