Jump to content

Line Tangent to Two Circles


Recommended Posts

I needed to draw a line that was tangent to two circles, and the Snaps were giving me grief, but after a little search on here, I found this LISP.

 

I found it so useful, I rewrote and though I'd post it for you guys :)

 

[b][color=RED]([/color][/b][b][color=BLUE]defun[/color][/b] c:cam [b][color=RED]([/color][/b][b][color=BLUE]/[/color][/b] *error* A A1 C1 C2 D L OV P P1 P2 P3 P4 R1 R2 VL[b][color=RED])[/color][/b]

 [b][color=RED]([/color][/b][b][color=BLUE]defun[/color][/b] *error* [b][color=RED]([/color][/b]msg[b][color=RED])[/color][/b]
   [b][color=RED]([/color][/b][b][color=BLUE]and[/color][/b] ov [b][color=RED]([/color][/b][b][color=BLUE]mapcar[/color][/b] [b][color=DARKRED]'[/color][/b][b][color=BLUE]setvar[/color][/b] vl ov[b][color=RED])[/color][/b][b][color=RED])[/color][/b]
   [b][color=RED]([/color][/b][b][color=BLUE]or[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]wcmatch[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]strcase[/color][/b] msg[b][color=RED])[/color][/b] [b][color=#ff00ff]"*BREAK,*CANCEL*,*EXIT*"[/color][/b][b][color=RED])[/color][/b]
       [b][color=RED]([/color][/b][b][color=BLUE]princ[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]strcat[/color][/b] [b][color=#ff00ff]"\n** Error: "[/color][/b] msg [b][color=#ff00ff]" **"[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b]
   [b][color=RED]([/color][/b][b][color=BLUE]princ[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b]

 [b][color=RED]([/color][/b][b][color=BLUE]setq[/color][/b] vl [b][color=DARKRED]'[/color][/b][b][color=RED]([/color][/b][b][color=#ff00ff]"CMDECHO"[/color][/b] [b][color=#ff00ff]"OSMODE"[/color][/b][b][color=RED])[/color][/b] ov [b][color=RED]([/color][/b][b][color=BLUE]mapcar[/color][/b] [b][color=DARKRED]'[/color][/b][b][color=BLUE]getvar[/color][/b] vl[b][color=RED])[/color][/b][b][color=RED])[/color][/b]

 [b][color=RED]([/color][/b][b][color=BLUE]if[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]and[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]setq[/color][/b] c1 [b][color=RED]([/color][/b][b][color=BLUE]getpoint[/color][/b]    [b][color=#ff00ff]"\nPick Center of First Radius: "[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b]
          [b][color=RED]([/color][/b][b][color=BLUE]setq[/color][/b] r1 [b][color=RED]([/color][/b][b][color=BLUE]getdist[/color][/b]  c1 [b][color=#ff00ff]"\nEnter First Radius: "[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b]
          [b][color=RED]([/color][/b][b][color=BLUE]setq[/color][/b] c2 [b][color=RED]([/color][/b][b][color=BLUE]getpoint[/color][/b] c1 [b][color=#ff00ff]"\nPick Center of Second Radius: "[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b]
          [b][color=RED]([/color][/b][b][color=BLUE]setq[/color][/b] r2 [b][color=RED]([/color][/b][b][color=BLUE]getdist[/color][/b]  c2 [b][color=#ff00ff]"\nEnter Second Radius: "[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b]
   [b][color=RED]([/color][/b][b][color=BLUE]progn[/color][/b]
     [b][color=RED]([/color][/b][b][color=BLUE]setq[/color][/b] a  [b][color=RED]([/color][/b][b][color=BLUE]angle[/color][/b] c1 c2[b][color=RED])[/color][/b]
           d  [b][color=RED]([/color][/b][b][color=BLUE]distance[/color][/b] c1 c2[b][color=RED])[/color][/b] p [b][color=RED]([/color][/b][b][color=BLUE]-[/color][/b] r1 r2[b][color=RED])[/color][/b]
           l  [b][color=RED]([/color][/b][b][color=BLUE]sqrt[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]-[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]*[/color][/b] d d[b][color=RED])[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]*[/color][/b] p p[b][color=RED])[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b] a1 [b][color=RED]([/color][/b][b][color=BLUE]atan[/color][/b] l p[b][color=RED])[/color][/b]

           p1 [b][color=RED]([/color][/b][b][color=BLUE]polar[/color][/b] c1 [b][color=RED]([/color][/b][b][color=BLUE]-[/color][/b] a a1[b][color=RED])[/color][/b] r1[b][color=RED])[/color][/b]
           p2 [b][color=RED]([/color][/b][b][color=BLUE]polar[/color][/b] p1 [b][color=RED]([/color][/b][b][color=BLUE]+[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]-[/color][/b] a a1[b][color=RED])[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]/[/color][/b] [b][color=BLUE]pi[/color][/b] [b][color=#009999]2.[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b] l[b][color=RED])[/color][/b]
           p3 [b][color=RED]([/color][/b][b][color=BLUE]polar[/color][/b] c1 [b][color=RED]([/color][/b][b][color=BLUE]+[/color][/b] a a1[b][color=RED])[/color][/b] r1[b][color=RED])[/color][/b]
           p4 [b][color=RED]([/color][/b][b][color=BLUE]polar[/color][/b] p3 [b][color=RED]([/color][/b][b][color=BLUE]-[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]+[/color][/b] a a1[b][color=RED])[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]/[/color][/b] [b][color=BLUE]pi[/color][/b] [b][color=#009999]2.[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b] l[b][color=RED])[/color][/b][b][color=RED])[/color][/b]

     [b][color=RED]([/color][/b][b][color=BLUE]mapcar[/color][/b] [b][color=DARKRED]'[/color][/b][b][color=BLUE]setvar[/color][/b] vl [b][color=DARKRED]'[/color][/b][b][color=RED]([/color][/b][b][color=#009900]0[/color][/b] [b][color=#009900]0[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b]
     [b][color=RED]([/color][/b][b][color=BLUE]command[/color][/b] [b][color=#ff00ff]"_.arc"[/color][/b] [b][color=#ff00ff]"_C"[/color][/b] c1 p3 p1 [b][color=#ff00ff]"_.arc"[/color][/b] [b][color=#ff00ff]"_C"[/color][/b] c2 p2 p4[b][color=RED])[/color][/b]
     [b][color=RED]([/color][/b][b][color=BLUE]command[/color][/b] [b][color=#ff00ff]"_.line"[/color][/b] p1 p2 [b][color=#ff00ff]""[/color][/b] [b][color=#ff00ff]"_.line"[/color][/b] p3 p4 [b][color=#ff00ff]""[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b]

 [b][color=RED]([/color][/b][b][color=BLUE]mapcar[/color][/b] [b][color=DARKRED]'[/color][/b][b][color=BLUE]setvar[/color][/b] vl ov[b][color=RED])[/color][/b]
 [b][color=RED]([/color][/b][b][color=BLUE]princ[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b]

     

 

Lee

Link to post
Share on other sites
  • Replies 30
  • Created
  • Last Reply

Top Posters In This Topic

  • Lee Mac

    11

  • LEsq

    6

  • wizman

    5

  • David Bethel

    3

Top Posters In This Topic

Posted Images

This toolbar button macro works: ^C^C_line tan;\tan;\;

 

True, I knew there was a Snap way to do it, but, I just found this particular LISP useful :)

 

Slight improvement?

 

[b][color=RED]([/color][/b][b][color=BLUE]defun[/color][/b] c:cam [b][color=RED]([/color][/b][b][color=BLUE]/[/color][/b] *error* A A1 C1 C2 D E1 E2 L OV P P1 P2 P3 P4 R1 R2 VL[b][color=RED])[/color][/b]

 [b][color=RED]([/color][/b][b][color=BLUE]defun[/color][/b] *error* [b][color=RED]([/color][/b]msg[b][color=RED])[/color][/b]
   [b][color=RED]([/color][/b][b][color=BLUE]and[/color][/b] ov [b][color=RED]([/color][/b][b][color=BLUE]mapcar[/color][/b] [b][color=DARKRED]'[/color][/b][b][color=BLUE]setvar[/color][/b] vl ov[b][color=RED])[/color][/b][b][color=RED])[/color][/b]
   [b][color=RED]([/color][/b][b][color=BLUE]or[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]wcmatch[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]strcase[/color][/b] msg[b][color=RED])[/color][/b] [b][color=#ff00ff]"*BREAK,*CANCEL*,*EXIT*"[/color][/b][b][color=RED])[/color][/b]
       [b][color=RED]([/color][/b][b][color=BLUE]princ[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]strcat[/color][/b] [b][color=#ff00ff]"\n** Error: "[/color][/b] msg [b][color=#ff00ff]" **"[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b]
   [b][color=RED]([/color][/b][b][color=BLUE]princ[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b]

 [b][color=RED]([/color][/b][b][color=BLUE]setq[/color][/b] vl [b][color=DARKRED]'[/color][/b][b][color=RED]([/color][/b][b][color=#ff00ff]"CMDECHO"[/color][/b] [b][color=#ff00ff]"OSMODE"[/color][/b][b][color=RED])[/color][/b] ov [b][color=RED]([/color][/b][b][color=BLUE]mapcar[/color][/b] [b][color=DARKRED]'[/color][/b][b][color=BLUE]getvar[/color][/b] vl[b][color=RED])[/color][/b][b][color=RED])[/color][/b]
 [b][color=RED]([/color][/b][b][color=BLUE]setvar[/color][/b] [b][color=#ff00ff]"CMDECHO"[/color][/b] [b][color=#009900]0[/color][/b][b][color=RED])[/color][/b]

 [b][color=RED]([/color][/b][b][color=BLUE]if[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]setq[/color][/b] c1 [b][color=RED]([/color][/b][b][color=BLUE]getpoint[/color][/b]    [b][color=#ff00ff]"\nPick Center of First Radius: "[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b]
   [b][color=RED]([/color][/b][b][color=BLUE]progn[/color][/b]
     [b][color=RED]([/color][/b][b][color=BLUE]princ[/color][/b] [b][color=#ff00ff]"\nEnter First Radius: "[/color][/b][b][color=RED])[/color][/b]
     [b][color=RED]([/color][/b][b][color=BLUE]command[/color][/b] [b][color=#ff00ff]"_.circle"[/color][/b] [b][color=#ff00ff]"_non"[/color][/b] c1 pause[b][color=RED])[/color][/b]
     [b][color=RED]([/color][/b][b][color=BLUE]setq[/color][/b] r1 [b][color=RED]([/color][/b][b][color=BLUE]cdr[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]assoc[/color][/b] [b][color=#009900]40[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]entget[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]setq[/color][/b] e1 [b][color=RED]([/color][/b][b][color=BLUE]entlast[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b]
     
     [b][color=RED]([/color][/b][b][color=BLUE]if[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]setq[/color][/b] c2 [b][color=RED]([/color][/b][b][color=BLUE]getpoint[/color][/b] c1 [b][color=#ff00ff]"\nPick Center of Second Radius: "[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b]
       [b][color=RED]([/color][/b][b][color=BLUE]progn[/color][/b]
         [b][color=RED]([/color][/b][b][color=BLUE]princ[/color][/b] [b][color=#ff00ff]"\nEnter Second Radius: "[/color][/b][b][color=RED])[/color][/b]
         [b][color=RED]([/color][/b][b][color=BLUE]command[/color][/b] [b][color=#ff00ff]"_.circle"[/color][/b] [b][color=#ff00ff]"_non"[/color][/b] c2 pause[b][color=RED])[/color][/b]
         [b][color=RED]([/color][/b][b][color=BLUE]setq[/color][/b] r2 [b][color=RED]([/color][/b][b][color=BLUE]cdr[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]assoc[/color][/b] [b][color=#009900]40[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]entget[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]setq[/color][/b] e2 [b][color=RED]([/color][/b][b][color=BLUE]entlast[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b]

         [b][color=RED]([/color][/b][b][color=BLUE]mapcar[/color][/b] [b][color=DARKRED]'[/color][/b][b][color=BLUE]entdel[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]list[/color][/b] e1 e2[b][color=RED])[/color][/b][b][color=RED])[/color][/b]
         
         [b][color=RED]([/color][/b][b][color=BLUE]setq[/color][/b] a  [b][color=RED]([/color][/b][b][color=BLUE]angle[/color][/b] c1 c2[b][color=RED])[/color][/b]
               d  [b][color=RED]([/color][/b][b][color=BLUE]distance[/color][/b] c1 c2[b][color=RED])[/color][/b] p [b][color=RED]([/color][/b][b][color=BLUE]-[/color][/b] r1 r2[b][color=RED])[/color][/b]
               l  [b][color=RED]([/color][/b][b][color=BLUE]sqrt[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]-[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]*[/color][/b] d d[b][color=RED])[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]*[/color][/b] p p[b][color=RED])[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b] a1 [b][color=RED]([/color][/b][b][color=BLUE]atan[/color][/b] l p[b][color=RED])[/color][/b]
               
               p1 [b][color=RED]([/color][/b][b][color=BLUE]polar[/color][/b] c1 [b][color=RED]([/color][/b][b][color=BLUE]-[/color][/b] a a1[b][color=RED])[/color][/b] r1[b][color=RED])[/color][/b]
               p2 [b][color=RED]([/color][/b][b][color=BLUE]polar[/color][/b] p1 [b][color=RED]([/color][/b][b][color=BLUE]+[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]-[/color][/b] a a1[b][color=RED])[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]/[/color][/b] [b][color=BLUE]pi[/color][/b] [b][color=#009999]2.[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b] l[b][color=RED])[/color][/b]
               p3 [b][color=RED]([/color][/b][b][color=BLUE]polar[/color][/b] c1 [b][color=RED]([/color][/b][b][color=BLUE]+[/color][/b] a a1[b][color=RED])[/color][/b] r1[b][color=RED])[/color][/b]
               p4 [b][color=RED]([/color][/b][b][color=BLUE]polar[/color][/b] p3 [b][color=RED]([/color][/b][b][color=BLUE]-[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]+[/color][/b] a a1[b][color=RED])[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]/[/color][/b] [b][color=BLUE]pi[/color][/b] [b][color=#009999]2.[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b] l[b][color=RED])[/color][/b][b][color=RED])[/color][/b]
         
         [b][color=RED]([/color][/b][b][color=BLUE]mapcar[/color][/b] [b][color=DARKRED]'[/color][/b][b][color=BLUE]setvar[/color][/b] vl [b][color=DARKRED]'[/color][/b][b][color=RED]([/color][/b][b][color=#009900]0[/color][/b] [b][color=#009900]0[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b]
         [b][color=RED]([/color][/b][b][color=BLUE]command[/color][/b] [b][color=#ff00ff]"_.arc"[/color][/b] [b][color=#ff00ff]"_C"[/color][/b] c1 p3 p1 [b][color=#ff00ff]"_.arc"[/color][/b] [b][color=#ff00ff]"_C"[/color][/b] c2 p2 p4[b][color=RED])[/color][/b]
         [b][color=RED]([/color][/b][b][color=BLUE]command[/color][/b] [b][color=#ff00ff]"_.line"[/color][/b] p1 p2 [b][color=#ff00ff]""[/color][/b] [b][color=#ff00ff]"_.line"[/color][/b] p3 p4 [b][color=#ff00ff]""[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b]

 [b][color=RED]([/color][/b][b][color=BLUE]mapcar[/color][/b] [b][color=DARKRED]'[/color][/b][b][color=BLUE]setvar[/color][/b] vl ov[b][color=RED])[/color][/b]
 [b][color=RED]([/color][/b][b][color=BLUE]princ[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b]

Link to post
Share on other sites
This toolbar button macro works: ^C^C_line tan;\tan;\;

Yes it is but I want from Lee in lisp option:P.

Used to use program called CirTools and it end up at 2002 version. It was very handy, hope one day Lee will make it available for higher version:)

Link to post
Share on other sites
Glen Smith

While I was taking my class I needed to draw a circle using either (I don't remember now which) Tan Tan Radius or 3Point. After several faulty attempts I asked my instructor how AuotCAD could be so smart and contrarian that it knew which one of the multiple possible circles that I wanted, yet refused to draw it.

 

His eyes lit up and he said, "let me show you something". And he brought up a drawing titled "The Problem Of Apollonius". As he went over it, I thought that it would be a perfect problem for you to code in LISP, covering both some fairly complex math and - I would assume - fairly complex coding. Perhaps to be able to select the objects that you wish to be tangent to and then toggling through the possible solutions until you get the one that you want.

 

Then I forgot about it - till you posted this.

 

Glen

Link to post
Share on other sites
David Bethel

Thought of another way. I just haven't figured out how to get thew correct bulge factor. -David

[b][color=BLACK]([/color][/b]initget 7[b][color=BLACK])[/color][/b]
[b][color=BLACK]([/color][/b]setq r1 [b][color=FUCHSIA]([/color][/b]getdist [color=#2f4f4f]"\nRadius 1:   "[/color][b][color=FUCHSIA])[/color][/b][b][color=BLACK])[/color][/b]

[b][color=BLACK]([/color][/b]initget 7[b][color=BLACK])[/color][/b]
[b][color=BLACK]([/color][/b]setq r2 [b][color=FUCHSIA]([/color][/b]getdist [color=#2f4f4f]"\nRadius 2:   "[/color][b][color=FUCHSIA])[/color][/b][b][color=BLACK])[/color][/b]

[b][color=BLACK]([/color][/b]initget 7[b][color=BLACK])[/color][/b]
[b][color=BLACK]([/color][/b]setq d [b][color=FUCHSIA]([/color][/b]getdist [color=#2f4f4f]"\nCL->CL Distance:   "[/color][b][color=FUCHSIA])[/color][/b][b][color=BLACK])[/color][/b]

[b][color=BLACK]([/color][/b]setq delta [b][color=FUCHSIA]([/color][/b]- r1 r2[b][color=FUCHSIA])[/color][/b]
      h [b][color=FUCHSIA]([/color][/b]sqrt [b][color=NAVY]([/color][/b]+ [b][color=MAROON]([/color][/b]* d d[b][color=MAROON])[/color][/b] [b][color=MAROON]([/color][/b]* delta delta[b][color=MAROON])[/color][/b][b][color=NAVY])[/color][/b][b][color=FUCHSIA])[/color][/b]
     a1 [b][color=FUCHSIA]([/color][/b]angle '[b][color=NAVY]([/color][/b]0 0[b][color=NAVY])[/color][/b] [b][color=NAVY]([/color][/b]list d [b][color=MAROON]([/color][/b]abs delta[b][color=MAROON])[/color][/b][b][color=NAVY])[/color][/b][b][color=FUCHSIA])[/color][/b]
    ar1 [b][color=FUCHSIA]([/color][/b]- pi a1 a1[b][color=FUCHSIA])[/color][/b] [color=#8b4513]; ARC 1 Included Angle[/color]
    ar2 [b][color=FUCHSIA]([/color][/b]+ pi a1 a1[b][color=FUCHSIA])[/color][/b] [color=#8b4513]; or [b][color=FUCHSIA]([/color][/b]- [b][color=NAVY]([/color][/b]* pi 2[b][color=NAVY])[/color][/b] a1 a1[b][color=FUCHSIA])[/color][/b][/color]
    bf1 [b][color=FUCHSIA]([/color][/b]* 4 [b][color=NAVY]([/color][/b]atan ar1[b][color=NAVY])[/color][/b][b][color=FUCHSIA])[/color][/b]
    bf2 [b][color=FUCHSIA]([/color][/b]* 4 [b][color=NAVY]([/color][/b]atan ar2[b][color=NAVY])[/color][/b][b][color=FUCHSIA])[/color][/b][b][color=BLACK])[/color][/b]

[b][color=BLACK]([/color][/b]setq p1 [b][color=FUCHSIA]([/color][/b]polar [b][color=NAVY]([/color][/b]list 0 0 0[b][color=NAVY])[/color][/b] [b][color=NAVY]([/color][/b]+ [b][color=MAROON]([/color][/b]* pi 0.5[b][color=MAROON])[/color][/b] a1[b][color=NAVY])[/color][/b] r1[b][color=FUCHSIA])[/color][/b]
     p2 [b][color=FUCHSIA]([/color][/b]polar [b][color=NAVY]([/color][/b]list 0 0 0[b][color=NAVY])[/color][/b] [b][color=NAVY]([/color][/b]- [b][color=MAROON]([/color][/b]* pi 1.5[b][color=MAROON])[/color][/b] a1[b][color=NAVY])[/color][/b] r1[b][color=FUCHSIA])[/color][/b]
     p3 [b][color=FUCHSIA]([/color][/b]polar [b][color=NAVY]([/color][/b]list d 0 0[b][color=NAVY])[/color][/b] [b][color=NAVY]([/color][/b]- [b][color=MAROON]([/color][/b]* pi 1.5[b][color=MAROON])[/color][/b] a1[b][color=NAVY])[/color][/b] r2[b][color=FUCHSIA])[/color][/b]
     p4 [b][color=FUCHSIA]([/color][/b]polar [b][color=NAVY]([/color][/b]list d 0 0[b][color=NAVY])[/color][/b] [b][color=NAVY]([/color][/b]+ [b][color=MAROON]([/color][/b]* pi 0.5[b][color=MAROON])[/color][/b] a1[b][color=NAVY])[/color][/b] r2[b][color=FUCHSIA])[/color][/b][b][color=BLACK])[/color][/b]

[b][color=BLACK]([/color][/b]entmake [b][color=FUCHSIA]([/color][/b]list [b][color=NAVY]([/color][/b]cons 0 [color=#2f4f4f]"POLYLINE"[/color][b][color=NAVY])[/color][/b][b][color=NAVY]([/color][/b]cons 66 1[b][color=NAVY])[/color][/b][b][color=NAVY]([/color][/b]cons 10 [b][color=MAROON]([/color][/b]list 0 0 0[b][color=MAROON])[/color][/b][b][color=NAVY])[/color][/b][b][color=NAVY]([/color][/b]cons 70 1[b][color=NAVY])[/color][/b][b][color=FUCHSIA])[/color][/b][b][color=BLACK])[/color][/b]
[b][color=BLACK]([/color][/b]entmake [b][color=FUCHSIA]([/color][/b]list [b][color=NAVY]([/color][/b]cons 0 [color=#2f4f4f]"VERTEX"[/color][b][color=NAVY])[/color][/b][b][color=NAVY]([/color][/b]cons 10 p1[b][color=NAVY])[/color][/b][b][color=NAVY]([/color][/b]cons 42 bf1[b][color=NAVY])[/color][/b][b][color=FUCHSIA])[/color][/b][b][color=BLACK])[/color][/b]
[b][color=BLACK]([/color][/b]entmake [b][color=FUCHSIA]([/color][/b]list [b][color=NAVY]([/color][/b]cons 0 [color=#2f4f4f]"VERTEX"[/color][b][color=NAVY])[/color][/b][b][color=NAVY]([/color][/b]cons 10 p2[b][color=NAVY])[/color][/b][b][color=FUCHSIA])[/color][/b][b][color=BLACK])[/color][/b]
[b][color=BLACK]([/color][/b]entmake [b][color=FUCHSIA]([/color][/b]list [b][color=NAVY]([/color][/b]cons 0 [color=#2f4f4f]"VERTEX"[/color][b][color=NAVY])[/color][/b][b][color=NAVY]([/color][/b]cons 10 p3[b][color=NAVY])[/color][/b][b][color=NAVY]([/color][/b]cons 42 bf2[b][color=NAVY])[/color][/b][b][color=FUCHSIA])[/color][/b][b][color=BLACK])[/color][/b]
[b][color=BLACK]([/color][/b]entmake [b][color=FUCHSIA]([/color][/b]list [b][color=NAVY]([/color][/b]cons 0 [color=#2f4f4f]"VERTEX"[/color][b][color=NAVY])[/color][/b][b][color=NAVY]([/color][/b]cons 10 p4[b][color=NAVY])[/color][/b][b][color=FUCHSIA])[/color][/b][b][color=BLACK])[/color][/b]
[b][color=BLACK]([/color][/b]entmake [b][color=FUCHSIA]([/color][/b]list [b][color=NAVY]([/color][/b]cons 0 [color=#2f4f4f]"SEQEND"[/color][b][color=NAVY])[/color][/b][b][color=FUCHSIA])[/color][/b][b][color=BLACK])[/color][/b]

Link to post
Share on other sites

With bulge:

 

(initget 7)
(setq r1 (getdist "\nRadius 1:   "))

(initget 7)
(setq r2 (getdist "\nRadius 2:   "))

(initget 7)
(setq d (getdist "\nCL->CL Distance:   "))

 (setq delta (- r1 r2) h (sqrt (- (* d d) (* delta delta)))

       ang (atan h delta))

(setq p1 (polar (list 0 0 0) ang r1)
     p2 (polar (list 0 0 0) (- ang) r1)
     p3 (polar (list d 0 0) ang r2)
     p4 (polar (list d 0 0) (- ang) r2)

     b1 (/ (sin (* 0.5 (- pi ang))) (float (cos (* 0.5 (- pi ang)))))
     b2 (/ (sin (* 0.5 ang)) (float (cos (* 0.5 ang)))))

(entmake (list (cons 0 "POLYLINE") (cons 66 1) (cons 10 (list 0 0 0)) (cons 70 1)))

(entmake (list (cons 0 "VERTEX") (cons 10 p1) (cons 42  b1)))
(entmake (list (cons 0 "VERTEX") (cons 10 p2)))

(entmake (list (cons 0 "VERTEX") (cons 10 p4) (cons 42 b2)))
(entmake (list (cons 0 "VERTEX") (cons 10 p3)))

       
(entmake (list (cons 0 "SEQEND")))

Only at zero rotation currently. :)

Link to post
Share on other sites

With angle:

 

(defun c:cam2 (/ ANG B1 B2 C1 C2 D DELTA H IANG R1 R2)

 (if (setq c1 (getpoint "\nPick Center of First Radius: "))
   (progn
     (initget 7) (setq r1 (getdist c1 "\nRadius 1:   "))

     (if (setq c2 (getpoint c1 "\nPick Center of Second Radius: "))
       (progn
         (initget 7) (setq r2 (getdist c2 "\nRadius 2:   "))

         (setq d (distance c1 c2) delta (- r1 r2)
               h (sqrt (- (* d d) (* delta delta)))

               iang (atan h delta) ang (angle c1 c2)

               b1 (/ (sin (* 0.5 (- pi iang))) (float (cos (* 0.5 (- pi iang)))))
               b2 (/ (sin (* 0.5 iang))        (float (cos (* 0.5 iang)))))
 
         (entmake (list (cons 0 "POLYLINE") (cons 66 1) (cons 10 (list 0 0 0)) (cons 70 1)))
         
         (entmake (list (cons 0 "VERTEX") (cons 10 (polar c1 (+ ang iang) r1)) (cons 42 b1)))
         (entmake (list (cons 0 "VERTEX") (cons 10 (polar c1 (- ang iang) r1))))
         
         (entmake (list (cons 0 "VERTEX") (cons 10 (polar c2 (- ang iang) r2)) (cons 42 b2)))
         (entmake (list (cons 0 "VERTEX") (cons 10 (polar c2 (+ ang iang) r2))))
         
         (entmake (list (cons 0 "SEQEND")))))))

 (princ))

Link to post
Share on other sites

Ok, so I got a bit carried away :P

 

cam.gif

 

(defun c:cam3 (/ ANG BLG C1 CEN CEN2 CODE DATA DELTA DIS
                EN GR IANG LEN LST POLY RAD RAD1 RAD2 TAN)
 ;; by Lee McDonnell (Lee Mac)  ~  19.12.2009
 
 (vl-load-com)

 (if (setq cen (getpoint "\nPick Center of First Radius: "))
   (progn
     (setq poly (entmakex
                  (list
                    (cons 0 "LWPOLYLINE")
                    (cons 100 "AcDbEntity")
                    (cons 100 "AcDbPolyline")
                    (cons 90 2)
                    (cons 70 1)
                    (cons 10 cen)
                    (cons 10 (polar cen 0 1.))))

           en   (reverse
                  (vl-member-if
                    (function
                      (lambda (x)
                        (= 39 (car x))))

                    (reverse (entget poly)))))
     
     (princ "\nPick First Radius: ")
     
     (while
       (progn
         (setq gr (grread 't 15 0) code (car gr) data (cadr gr))

         (cond (  (and (= 5 code) (listp data))

                  (setq ang (angle cen data)

                        dis (distance cen data))

                  (entmod
                    (append en
                      (setq lst
                        (list
                          (cons 10 data)
                          (cons 42 1.)
                          (cons 10 (polar data (+ ang pi) (* 2. dis)))
                          (cons 42 1.))))))

               (  (and (= 3 code) (listp data))

                  (setq en
                    (append en
                      (setq lst
                        (list
                          (cons 10 data)
                          (cons 42 1.)
                          (cons 10 (polar data (+ ang pi) (* 2. dis)))
                          (cons 42 1.)
                          (cons 10 data))))

                        en (reverse
                             (vl-member-if
                               (function
                                 (lambda (x)
                                   (= 39 (car x))))

                               (reverse
                                 (entmod
                                   (subst (cons 90 3) (assoc 90 en) en)))))
                        
                        rad (distance cen data))

                  (princ "\nPick Center of Second Radius: ")

                  (while
                    (progn
                      (setq gr (grread 't 15 0) code (car gr) data (cadr gr))

                      (cond (  (and (= 5 code) (listp data))

                               (setq dis (distance cen data) ang (angle cen data))

                               (if (< rad dis)
                                 (progn

                                   (setq tan  (sqrt (- (* dis dis) (* rad rad)))

                                         iAng (atan tan rad)

                                         blg  (/ (sin (* 0.5 (- pi iAng)))
                                                 (cos (* 0.5 (- pi iAng)))))

                                   (entmod
                                     (append en
                                       (setq lst
                                         (list
                                           (cons 10 data)
                                           (cons 10 (polar cen (+ ang iAng) rad))
                                           (cons 42 blg)
                                           (cons 10 (polar cen (- ang iAng) rad))))))) t))

                            (  (and (= 3 code) (listp data))

                               (setq dis (distance cen data) ang (angle cen data))

                               (if (< rad dis)
                                 (progn

                                   (setq tan  (sqrt (- (* dis dis) (* rad rad)))

                                         iAng (atan tan rad)

                                         blg  (/ (sin (* 0.5 (- pi iAng)))
                                                 (cos (* 0.5 (- pi iAng)))))

                                   (setq en
                                     (append en
                                       (list
                                         (cons 10 data)
                                         (cons 10 data)
                                         (cons 10 (polar cen (+ ang iAng) rad))
                                         (cons 42 blg)
                                         (cons 10 (polar cen (- ang iAng) rad)))))

                                   (setq en (reverse
                                              (vl-member-if
                                                (function
                                                  (lambda (x)
                                                    (= 39 (car x))))

                                                (reverse
                                                  (entmod
                                                    (subst (cons 90 4) (assoc 90 en) en)))))

                                         cen2 data len (distance cen cen2) ang (angle cen cen2))

                                   (princ "\nPick Second Radius: ")
                                   
                                   (while
                                     (progn
                                       (setq gr (grread 't 15 0) code (car gr) data (cadr gr))
                                       
                                       (cond (  (and (= 5 code) (listp data))
                                              
                                                (setq rad2 (distance cen2 data) delta (- rad rad2))

                                                (if (< (abs delta) len)
                                                  (progn

                                                    (setq tan  (sqrt (- (* len len) (* delta delta))) iAng (atan tan delta)
                                                    
                                                          blg1 (/ (sin (* 0.5 (- pi iAng))) (cos (* 0.5 (- pi iAng))))

                                                          blg2 (/ (sin (* 0.5 iAng))        (cos (* 0.5 iAng))))
                                              
                                                    (entmod
                                                      (append en
                                                        (list
                                                          (cons 10 (polar cen  (+ ang iAng) rad))
                                                          (cons 42 blg1)
                                                          (cons 10 (polar cen  (- ang iAng) rad))
                                                      
                                                          (cons 10 (polar cen2 (- ang iAng) rad2))
                                                          (cons 42 blg2)
                                                          (cons 10 (polar cen2 (+ ang iAng) rad2)))))) t))
                                             
                                             (  (and (= 3 code) (listp data)) nil)

                                             (t )))))))
                            (t )))))
               (t ))))))
 (princ))

Link to post
Share on other sites
David Bethel
With bulge:

Only at zero rotation currently. :)

 

Very good! Now all you have to do is add thickness and PLINE width and you have a modeled a nice belt for a pulley system. 8) -David

AR-LEY.JPG

Link to post
Share on other sites
Nerds!!!! haha 8)

 

Haha, well, what can I say... I am doing a maths degree... you can't really get a much bigger nerd lol :P

 

Very good! Now all you have to do is add thickness and PLINE width and you have a modeled a nice belt for a pulley system. 8) -David

 

Thanks David :)

Link to post
Share on other sites
David Bethel
A Belt you say... :P

 

Exactly. But real world, the pulley size, axle center to center and belt width would be the probable known factors. While the ( grread ) input is neat, accepting relative inputs ( @2

 

It is still a neat concept. Congrats! -David

Link to post
Share on other sites
Exactly. But real world, the pulley size, axle center to center and belt width would be the probable known factors. While the ( grread ) input is neat, accepting relative inputs ( @2

 

It is still a neat concept. Congrats! -David

 

Thanks David :)

 

True, I've allowed the user to enter points and values, and could probably account for relative inputs, but then I would still have to manufacture OSnap...

 

I think I'm just hooked on the "dynamic" look o:)

 

Lee

Link to post
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
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...