Challenge 01/23

Challenge 01/23

Sea-Haven
Mentor Mentor
1,888 Views
34 Replies
Message 1 of 35

Challenge 01/23

Sea-Haven
Mentor
Mentor

This has been on my to do list for years the simple do a fillet between two arcs or circles, yes Circle TTR gives a result but draws a circle rather than an arc. So this is arc option 1 if can be done better please do so, there are 4 possible options for a new arc. 

 

You just pick the 2 circles and the top approx new arc center point. It drawa the arc based on a left to right method.

SeaHaven_0-1672962266890.png

 

; 2 circle add arc. downwards between 2 circle or arcs
; BY alanH Jan 2023


(defun C:A1 ( / ent1 ent2 cen1 cen2 obj1 obj2 obj3 obj4)
(vl-load-com)
(setq oldsnap (getvar 'osmode))
(setvar 'osmode 0)
(setq ent1 (vlax-ename->vla-object (car  (entsel "Pick circle 1 (L) "))))
(setq ent2 (vlax-ename->vla-object (car  (entsel "Pick circle 2 (R) "))))
(setq cen1 (vlax-get ent1 'center))
(setq cen2 (vlax-get ent2 'center))
(setq rad1 (vlax-get ent1 'radius))
(setq rad2 (vlax-get ent2 'radius))
(setq rad3 (getreal "\nEnter radius "))
(command "circle" cen1 (+ rad1 rad3))
(setq obj1 (vlax-ename->vla-object  (entlast)))
(command "circle" cen2 (+ rad2 rad3))
(setq obj2 (vlax-ename->vla-object  (entlast)))
(setq intpt (vlax-invoke obj2 'intersectWith obj1 acExtendThisEntity))
(setq pt1 (list (car intpt)(cadr intpt) 0.0))
(setq pt2 (list (nth 3 intpt)(nth 4 intpt) 0.0))
(vla-delete obj1)
(vla-delete obj2)
(setq cenpt (getpoint "\npick near arc point center "))
(setq d1 (distance pt1 cenpt)
	    d2 (distance pt2 cenpt)
)
(if (> d1 d2)
    (progn
    (setq temp pt1)
    (setq pt1 pt2)
    (setq pt2 temp)
    )
)
(command "line" pt1 cen1 "")
(setq obj3 (vlax-ename->vla-object (entlast)))
(setq arcpt1 (vlax-invoke ent1 'intersectWith obj3 acExtendThisEntity))
(command "line" pt1 cen2 "")
(setq obj4 (vlax-ename->vla-object (entlast)))
(setq arcpt2 (vlax-invoke ent2 'intersectWith obj4 acExtendThisEntity))
(vla-delete obj3)
(vla-delete obj4)
(command "arc" "s" arcpt1 "E" arcpt2 "R" rad3)
(princ)
)
(C:a1)

 

So what about an external arc ?

0 Likes
Accepted solutions (1)
1,889 Views
34 Replies
Replies (34)
Message 2 of 35

john.uhden
Mentor
Mentor

@Sea-Haven 

I'm working on it, but my code is growing to be a lot longer than yours.

But that's because, unlike Kent, I don't like running into errors.

I prefer prompting the user what is improper input.

John F. Uhden

0 Likes
Message 3 of 35

phanaem
Collaborator
Collaborator

I'm not sure in which version was introduced, but you can FILLET 2 circles. Pretty much the same result as your lisp.

Message 4 of 35

yangguoshe
Advocate
Advocate

Yes, the fill command can achieve similar functions

0 Likes
Message 5 of 35

Sea-Haven
Mentor
Mentor

How do I get the red outside arc using Fillet ?

SeaHaven_1-1672993292672.png

I want red arc

SeaHaven_0-1672993271713.png

My 1st post  "there are 4 possible options for a new arc."

phanaem I think you missed the multiple choices depending on what your trying to achieve, the c:A1 is the 1st option there are at least 4 solutions to adding an arc to 2 arc/circles. I sold add on software that did it. It was proprietary. Looking for A2 A3 and A4.

 

If your older like me you will know about the dreaded "S" bend when trying to use fillet. Yes maybe there has been an update to fillet but only for 1 scenario.

0 Likes
Message 6 of 35

john.uhden
Mentor
Mentor

Well, look at that.

Thanks for wasting my time, @Sea-Haven .

Thank you, @phanaem .

John F. Uhden

0 Likes
Message 7 of 35

john.uhden
Mentor
Mentor

My apologies, @Sea-Haven .

Back to the drawing board.

John F. Uhden

0 Likes
Message 8 of 35

marko_ribar
Advisor
Advisor

@Sea-Haven 

Why don't try CCP - circle-circle-point option rather than input of radius of 3rd circle...

Link : https://www.cadtutor.net/forum/files/file/29-apollonius-problem-solvedlsp/ 

 

HTH.

M.R.

Marko Ribar, d.i.a. (graduated engineer of architecture)
0 Likes
Message 9 of 35

Kent1Cooper
Consultant
Consultant

@Sea-Haven wrote:

.... there are 4 possible options for a new arc.  ....  So what about an external arc ?


Not always 4, and an external-to-both-Circles-and-the-space-between-them Arc [if that's what you're talking about] is not always possible.

Kent1Cooper_0-1673034207727.png

Say RC1 is the Radius of Circle 1, RC2 is the Radius of Circle 2, RA is the Radius of the desired Arc result, and D is the distance between the center points of the two Circles.

 

When D + RC1 + RC2 [that is, the farthest distance between extremes of the Circles] is more than 2 x RA, no external-to-everything Arc is possible, and there are 6 possible Arcs [the other-than-white] -- see the left half of the image.  When D + RC1 + RC2 is less than or equal to 2 x RA, there are 8 possible Arcs -- see the right half.

 

Not shown -- if D - RC1 - RC2 [that is, the space between the Circles at their nearest] is more than 2 x RA, of course no solution is possible.  If that's exactly 2 x RA, there are only 2 possible Arcs, together making the Circle tangent to both the others and between them.  And I think the number remains 2 for a while as RA increases -- I'd have to think about at what RA size relative to the other measurements the number of possible Arcs increases from 2.

Kent Cooper, AIA
Message 10 of 35

Sea-Haven
Mentor
Mentor

I maybe did not explain the task properly. Using fillet is still a problem as some of the desired answers can not be made using that command.

 

What is wanted is the other 2 choices in a simple manner. I have done a possible solution for Arc 1. Marko_Ribar has offered a good solution for other curves as well, worth having a look at.

 

SeaHaven_2-1673048560801.png

Having a dcl, toolbar or ribbon with icon for choices would be good.

 

 

 

0 Likes
Message 11 of 35

CADaSchtroumpf
Advisor
Advisor

If you give the tangency points as close as possible to the desired solution, as well as the order of selection to have the arc counter-clockwise (trigonometric), this solution can give the correct results.

(vl-load-com)
(defun C:Arc-TT-RAD ( / p1 e1 t1 p2 e2 t2 rad cx)
  (setvar "cmdecho" 0)
  (while (not (setq e1 (nentsel "\n1st point of tangency: "))))
  (setq p1 (cadr e1))
  (setq t1 (osnap p1 "_near"))
  (while (not (setq e2 (nentsel "\n2nd point of tangency: "))))
  (setq p2 (cadr e2))
  (setq t2 (osnap p2 "_near"))
  (cond
    ((and t1 t2)
      (initget 7)
      (setq rad (getreal "\nRadius?: "))
      (command "_.circle" "_Ttr" t1 t2 rad)
      (setq cx (entlast))
      (setq t1
        (vlax-invoke
          (vlax-ename->vla-object cx)
          'IntersectWith
          (vlax-ename->vla-object (car e1))
          acextendotherentity
        )
      )
      (setq t2
        (vlax-invoke
        (vlax-ename->vla-object cx)
          'IntersectWith
          (vlax-ename->vla-object (car e2))
          acextendotherentity
        )
      )
      (setq cx (cdr (assoc 10 (entget cx))))
      (entdel (entlast))
      (if (and t1 t2)
        (command "_.arc" "_none" (trans t1 0 1) "_ce" "_none" (trans cx 0 1) "_none" (trans t2 0 1))
        (princ "\nNo solution!")
      )
    )
  )
  (setvar "cmdecho" 1)
  (prin1)
)

And in the same way with an obligatory passage point instead of a radius.

(vl-load-com)
(defun C:Arc-TT-PT ( / p1 e1 t1 p2 e2 t2 px cx)
  (setvar "cmdecho" 0)
  (while (not (setq e1 (nentsel "\n1st point of tangency: "))))
  (setq p1 (cadr e1))
  (setq t1 (osnap p1 "_near"))
  (while (not (setq e2 (nentsel "\n2nd point of tangency: "))))
  (setq p2 (cadr e2))
  (setq t2 (osnap p2 "_near"))
  (cond
    ((and t1 t2)
      (initget 9)
      (setq px (getpoint "\nObliged passage point: "))
      (command "_.circle" "_3p" "_tan" t1 "_tan" t2 "_none" px)
      (setq cx (entlast))
      (setq t1
        (vlax-invoke
          (vlax-ename->vla-object cx)
          'IntersectWith
          (vlax-ename->vla-object (car e1))
          acextendotherentity
        )
      )
      (setq t2
        (vlax-invoke
        (vlax-ename->vla-object cx)
          'IntersectWith
          (vlax-ename->vla-object (car e2))
          acextendotherentity
        )
      )
      (entdel (entlast))
      (if (and t1 t2)
        (command "_.arc" "_none" (trans t1 0 1) "_none" px "_none" (trans t2 0 1))
        (princ "\nNo solution!")
      )
    )
  )
  (setvar "cmdecho" 1)
  (prin1)
)
0 Likes
Message 12 of 35

Sea-Haven
Mentor
Mentor

Shows alternative way for ARC 1 between 2 arc/circle. 

 

Second option is good, now have an extra arc option, so slowly building the arc solutions, thanks CADaSchtroumpf.

 

Arc-TT-PT this also solves the outside arc where a point is selected, so another solution so that is 3 now.

 

Will think about other options. Any one ?

0 Likes
Message 13 of 35

john.uhden
Mentor
Mentor

@Kent1Cooper & @Sea-Haven 

I count 12 possibilities (two for each of the groups in the image below).

Red circle is on layer 1 (color 1), radius 1

Yellow circle is on layer 2 (color 2), radius 2

Layer 3 (color 3) contains construction lines and circles.

Layer 4 (color 4) contains fillet circles, radius 7.

AutoCAD POINTS (filletmode 34) represent the centers of the fillet circles

Layer 6 (color 6) contains wide polylines representing the actual fillet, broken out of the fillet circles at their tangent points.

johnuhden_0-1673205534961.png

I haven't yet written the code, but it look pretty easy if you can zoom in on the labels.

OR, I will attach the 2002 drawing.

 

John F. Uhden

0 Likes
Message 14 of 35

phanaem
Collaborator
Collaborator

@john.uhdenEach of your magenta solution has a complementary one, the cyan arcs. So there are 16 solutions in total.

 

Cfillet.png

Message 15 of 35

Sea-Haven
Mentor
Mentor

I think for the moment only the what I will call internal arcs are required, I dont remember doing any of the outside Magenta arcs. They remind me of what fillet does some times. So really whilst most have 2 solutions a rule of pick what is to be known as 1st arc/circle then 2nd will control the new arc is top or bottom answer. Having the extra of go through a point would be handy. 

0 Likes
Message 16 of 35

john.uhden
Mentor
Mentor

@phanaem 

I see.  I see.

I hadn't seen the opportunity to complement the first two.

Good work!

John F. Uhden

0 Likes
Message 17 of 35

john.uhden
Mentor
Mentor

@Sea-Haven 

I was planning to allow the user to pick a point roughly in the area of the midpoint of the fillet.  Either that or he has to erase 15 fillets.  OR, I provide  a DCL with 8 image_buttons to limit the results to two.

Whadoyathink?

John F. Uhden

0 Likes
Message 18 of 35

Sea-Haven
Mentor
Mentor

I anticipate a dcl and pick type of arc. Look at my post 10 only diff would be that allow for the point option for all, Arc 1 has some solutions for that. 

 

This is cut from a bigger piece of code but may be useful. 

; dd3x3 to pick a slide form image list and run a defun
; By alanh 
(setq ai_pts_lst '(list of up to 9 slide names))

(setq ai_pts_lst2 '("33sq1" "33sq2" "33sq3" "33sq4" "33sq5" "33sq6""33sq7" "33sq8" "33sq9" ))

(defun sq_pick ()
  (cond 
    ((= ans "33sq1")(A1))
    ((= ans "33sq2")(A1pt))
    ((= ans "33sq3")(A2))
    ((= ans "33sq4")(A2pt))
    ((= ans "33sq5")(a3))
    ((= ans "33sq6")(A3Pt))
    ((= ans "33sq7")(A4))
    ((= ans "33sq8")(A4pt))
    ((= ans "33sq9")(spare))
    )
)

; calculates next slide
(defun alan4 ()
(setq x (+ x 1))
(setq sldname (nth x ai_pts_lst))
)

; third step
; set up slide libraray 
(defun ai_ptype_start ()
  (setq x -1)
  (foreach pts0 ai_pts_lst2
      (alan4)
      (start_image pts0)
      (slide_image 0 0 (- (dimx_tile pts0) 1) (- (dimy_tile pts0) 1) sldname)
      (end_image)
  )
)

; this is second step
(defun ai_ptype_main (/ globals)
  (ai_ptype_start)
;now check each sq if picked then run alan2
  (foreach pd0 ai_pts_lst2
    (action_tile  pd0  "(done_dialog)(setq ans $key)")
  )
  (start_dialog)

)

; this is first step

  (if (= w2 nil)(setw2))      
  
  (setq app "dd3x3.dcl")
  (if (= id_3x3 nil)
    (progn
    (setq dcl_id (load_dialog app))
    (setq id_3x3 dcl_id)
    )
  )
  (if (not (new_dialog "dd3x3" id_3x3))
  (exit))
  (ai_ptype_main)
  (sq_pick)

 

 

0 Likes
Message 19 of 35

dbroad
Mentor
Mentor

For 2 non-overlapping circles, there might be as many as 14 possibilities, depending on point pick location, radius and which part of the circle to keep (large part or small part). This code will work with lines, arcs, circles, and polylines.  It requires the user to pick 2 tangent points, enter a radius (code doesn't save a default), and pick the part of the circle to trim away. May require additional trimming for polylines though.

 

 

 

;;Fillet arc generalized
;;Will create an arc tangent to any 2 selected objects
;;Doesn't trim selected objects (arcs, lines, circles, polylines, etc.
;;Could be enhanced to trim those objects as well.
;;For objects such as lines and arcs that do not extend to the tangent point
;;the code may need to be revised to add the extend edge option.
;;D. C. Broad, Jr.  1/9/2023
;;Will stop if any step doesn't succeed.
(defun c:farc ( / es1 e1 p1 es2 e2 p2 r e3 p3 ss1)
  (and
  (setq es1 (entsel "\nPick first tangent point: "))
  (setq e1 (car es1))
  (setq p1 (osnap (cadr es1) "_nea"))
  (setq es2 (entsel "\nPick second tangent point: " ))
  (setq e2 (car es2))
  (setq p2 (osnap (cadr es2) "_nea"))
  (setq r (getdist "\nArc radius: "))
  (not (command "_.circle" "_ttr" "_tan" p1 "_tan" p2 r))
  (setq e3 (entlast))
  (setq p3 (osnap (cadr(entsel "\nPick part of circle to erase: "))"nea"))
  (setq ss1 (ssadd))
  (ssadd e1 ss1)
  (ssadd e2 ss1)
  (not (command "_.trim" ss1 "" p3 ""))
  )
  (princ)
  )

 

 

 

 

Architect, Registered NC, VA, SC, & GA.
0 Likes
Message 20 of 35

john.uhden
Mentor
Mentor

@dbroad 

Ya know, my earlier challenge to create straight tangents specified not to use any osnaps.  BUT

this is @Sea-Haven 's challenge and he didn't specify anything like that.  So I guess you're good to go.

John F. Uhden

0 Likes