Make a milling angle

Make a milling angle

Rikkes
Advocate Advocate
1,439 Views
14 Replies
Message 1 of 15

Make a milling angle

Rikkes
Advocate
Advocate

Hi, I wonder if it's possible to write lisp to create milling angles. 

Let me explain: I draw a lot of DXF files to mill figures in a wood panel. Now, when I have a corner, as the mill is round, I get a milled corner with the mill's radius. That's not good because I have to cut them out with a tool. 

I would like a kind of inverted fillet command that, depending on the mill's diameter, makes something like a bulb. (See figure in attachment)

Would that be possible?

 Thanks

 

Rikkes

0 Likes
Accepted solutions (2)
1,440 Views
14 Replies
Replies (14)
Message 2 of 15

Kent1Cooper
Consultant
Consultant
Accepted solution

BubbleFillet.lsp could be just what the doctor ordered -- available >>here<<.

 

[EDIT:  this is a newer revision from the one I originally had linked here, if you went for that one before I found the updated one.]

Kent Cooper, AIA
Message 3 of 15

CADaSchtroumpf
Advisor
Advisor

I have this, but I'm not sure that it is you have need's.

You can try...!

(defun ang_x (px p1 p2 / l_pt l_d p ang)
  (setq
    l_pt (mapcar '(lambda (x) (list (car x) (cadr x))) (list px p1 p2))
    l_d (mapcar 'distance l_pt (append (cdr l_pt) (list (car l_pt))))
    p (/ (apply '+ l_d) 2.0)
    ang (* (atan (sqrt (/ (* (- p (car l_d)) (- p (caddr l_d))) (* p (- p (cadr l_d)))))) 2.0)
  )
)
(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:bubble_fillet ( / js1 js2 ps1 ps2 pt_lst pt l3 key_fillet alpha chord p_o a1 a2)
  (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))
    pt_lst (list (cdr (assoc 10 js1)) (cdr (assoc 11 js1)) (cdr (assoc 10 js2)) (cdr (assoc 11 js2)))
    pt (inters (car pt_lst) (cadr pt_lst) (caddr pt_lst) (cadddr pt_lst) nil)
  )
  (cond
    ((and pt (equal (assoc 210 js1) (assoc 210 js2) 1E-8))
      (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))
        )
      )
      (initget 4)
      (setq key_fillet
        (getdist
          (strcat
            "\nSpecifie radius fillet <"
            (rtos (getvar "FILLETRAD"))
            ">:"
          )
        )
      )
      (if (null key_fillet) (setq key_fillet (getvar "FILLETRAD")) (setvar "FILLETRAD" key_fillet))
      (setq
        alpha (ang_x (cadr l3) (car l3) (caddr l3))
        chord (/ (* (getvar "FILLETRAD") (sin (- pi alpha))) (sin (* alpha 0.5)))
        js1 (subst (cons 10 (car l3)) (assoc 10 js1) js1)
        js2 (subst (cons 10 (caddr l3)) (assoc 10 js2) js2)
      )
      (entmod (setq js1 (subst (cons 11 (k_th pt (car l3) chord)) (assoc 11 js1) js1)))
      (entmod (setq js2 (subst (cons 11 (k_th pt (caddr l3) chord))  (assoc 11 js2) js2)))
      (setq
        p_o (k_th pt (mapcar '* (mapcar '+ (cdr (assoc 11 js1)) (cdr (assoc 11 js2))) '(0.5 0.5 0.5)) (getvar "FILLETRAD"))
        a1 (angle p_o (cdr (assoc 11 js1)))
        a2 (angle p_o (cdr (assoc 11 js2)))
      )
      (entmake
        (list
          (cons 0 "ARC")
          (cons 100 "AcDbEntity")
          (assoc 67 js1)
          (assoc 410 js1)
          (cons 8 (getvar "CLAYER"))
          (if (assoc 62 js1) (assoc 62 js1) (cons 62 256))
          (if (assoc 6 js1) (assoc 6 js1) (cons 6 "BYLAYER"))
          (cons 38 (+ (cadddr (assoc 10 js1)) (getvar "ELEVATION")))
          (cons 39 (getvar "THICKNESS"))
          (cons 100 "AcDbCircle")
          (cons 10 (trans p_o 0 (cdr (assoc 210 js1))))
          (cons 40 (getvar "FILLETRAD"))
          (assoc 210 js1)
          (cons 100 "AcDbArc")
          (cons 50
            (if (equal (* (+ (max a1 a2) (min a1 a2)) 0.5) (angle p_o pt) 1E-8)
              (min a1 a2)
              (max a1 a2)
            )
          )
          (cons 51
            (if (equal (* (+ (max a1 a2) (min a1 a2)) 0.5) (angle p_o pt) 1E-8)
              (max a1 a2)
              (min a1 a2)
            )
          )
        )
      )
    )
    (T
      (princ "\nCan't fillet lines, aren't in same plane!")
    )
  )
  (prin1)
)

 

Message 4 of 15

Rikkes
Advocate
Advocate

Hmmm, doesn't work... Thank's anyway!

0 Likes
Message 5 of 15

Rikkes
Advocate
Advocate

Works fine Kent!

Is it possible to make it work on arcs to?

Greetz

Rikkes

 

0 Likes
Message 6 of 15

Kent1Cooper
Consultant
Consultant

@Rikkes wrote:

Works fine Kent!

Is it possible to make it work on arcs to?

.... 


It may be, but I think the calculation of the locations where the "bubble" Arc would meet the original ones would be extraordinarily more complex than with Lines.  When I have some time, I'll think about whether that can be done....

Kent Cooper, AIA
Message 7 of 15

Rikkes
Advocate
Advocate

Would be nice! 

Hope you can sleep till you found the solution  🙂

 

0 Likes
Message 8 of 15

Rikkes
Advocate
Advocate

****, Kent, it doesn't work anymore...

What did I do wrong. It worked fine bun now it does strange things...

When I start with a clean DXF file, it works fine

When I start with my own start drawing (dwg) it does't

0 Likes
Message 9 of 15

Kent1Cooper
Consultant
Consultant

@Rikkes wrote:

.... Is it possible to make it work on arcs to? .... 


One of the questions that arises:  What should be the criterion for the cut-off points on the initial Arcs relative to their intersection?  [This is assuming, because of your description of the need, that they do intersect, or their extensions do.]  As an illustration, using Arcs of significantly different radius to illustrate how it matters:
FilletArcs.PNG

Calling the point where the white Arcs meet the "peak," and with the green and yellow Arcs of equal* radius:

The green Arc's ends are at equal chord lengths  along the white Arcs [straight-line  distances] from the peak.  The yellow Arc's ends are at equal distances along the white Arcs  from the peak.  [A similar difference would apply when done between an Arc and a Line.]

 

Is one or another of those, or maybe some other criterion, what you would want used to define this kind of bubble fillet, for the right kind of end result?

 

* They're not actually precisely  the same radius, but very close, for illustration.  Alternatively, I could have made them the same, and slightly fudged the "equality" of the chord or along-the-Arcs distances.  This is one of the complications, depending on what criterion you choose -- it may not be possible to calculate it with exact precision, but could require actually drawing a temporary Circle of desired radius passing through the peak, testing the result at its intersections with the initial Arcs for equality of the criterion distances, fine-tune-Rotating the Circle about the peak in a direction to get them closer to equal and testing again, repeatedly until the variance from precise equality falls within some small tolerance.

Kent Cooper, AIA
0 Likes
Message 10 of 15

Kent1Cooper
Consultant
Consultant

@Rikkes wrote:

****, Kent, it doesn't work anymore...

What did I do wrong. It worked fine bun now it does strange things...

When I start with a clean DXF file, it works fine

When I start with my own start drawing (dwg) it does't


"Strange things" and "doesn't work" are not enough information.  What does it do that you don't expect?  What does it not do that you do expect?  If it does some of the process, but not all, how far does it get?  Are there any error messages?  Etc., etc.

 

It's working for me [Acad2016 here].  Did you get the later version after I Edited my first Reply, or are you using the one I first linked to?  [The webpage in the updated link says something about what's different, if any of those things might be the cause of your problems.]

Kent Cooper, AIA
0 Likes
Message 11 of 15

Rikkes
Advocate
Advocate

Hi Kent,

As we use the command to make milling templates it doesn't matter how the bubbel is made. As long as the workpiece (in your drawing the white part) fits in the template, it's ok.

Rikkes

0 Likes
Message 12 of 15

Rikkes
Advocate
Advocate

I'm using the second one... 

Strange things happen when I use a DWG instead of a DXF file.

I'll try to explain but it's not easy...

When I use the command on two lines, the bullet appears about 12000mm away from the two lines and one of the lines is cut of... 

I put the drawing in attachment.

Little note: I am still using ACAD 2011. I have 2015 version aswell but I don't want to change because of all my personalisation...

0 Likes
Message 13 of 15

ВeekeeCZ
Consultant
Consultant

@Rikkeswrote:

I'm using the second one... 

Strange things happen when I use a DWG instead of a DXF file.

I'll try to explain but it's not easy...

When I use the command on two lines, the bullet appears about 12000mm away from the two lines and one of the lines is cut of... 

I put the drawing in attachment.

Little note: I am still using ACAD 2011. I have 2015 version aswell but I don't want to change because of all my personalisation...


Change the UCS coord system to WCS and it will work.

0 Likes
Message 14 of 15

Rikkes
Advocate
Advocate

 

Ok, found it! 

 

Thx

0 Likes
Message 15 of 15

ВeekeeCZ
Consultant
Consultant
Accepted solution
command UCS, then World ... very often reason why such routine is "not working"

I guess when the sun reach the East coast, Kent will fix the routine for you. It's quite simple fix.