Author Topic: Varying Size Tubing Interscetions  (Read 2712 times)

0 Members and 1 Guest are viewing this topic.

David Bethel

  • Swamp Rat
  • Posts: 656
Varying Size Tubing Interscetions
« on: October 18, 2012, 03:21:43 PM »
Greetings,

I'm stuck.....

I'm trying to calculate then intersection points of the take off blue tube and the red manifold.  It forms a saddle style of curve.

The take off will always be smaller or equal to the manifold

Right not it works if the take off = 1 and the manifold = 2 or = 1.  That ain't always the case <g>


Code - Auto/Visual Lisp: [Select]
  1. (defun c:pipe-sdl (/ r1 r2 a i tp c1 s1 c2 c3 c4 bp pl)
  2.  
  3. (setq *error* nil)
  4.  
  5.   (initget 7)
  6.   (setq r1 (getdist "\nTake Off Pipe Size:  "))
  7.  
  8.   (while (< r2 r1)
  9.          (initget 7)
  10.          (setq r2 (getdist "\nManifold Pipe Size:  ")))
  11.  
  12.   (setq a (/ pi 8)
  13.         i 0)
  14.  
  15.   (repeat 17
  16.     (setq tp (polar '(0 0 1) (* a i) r1)   ;;;TOP POINT
  17.           c1 (cos (angle '(0 0 1) tp))
  18.           s1 (sin (angle '(0 0 1) tp))
  19.           c3 (/ c1 r1)
  20.           c4 (/ c3 r2)                    
  21.           bp (list (car tp)                ;;;BOTTOM POINT
  22.                    (cadr tp)
  23.                    (- (- r2) (- (sqrt (- (* r2 r2)
  24.                                          (* (* c4 r2)
  25.                                             (* c4 r2)))))))
  26.           pl (cons tp pl)
  27.           pl (cons bp pl)
  28.            i (1+ i)))
  29.  
  30.   (entmake (list (cons 0 "POLYLINE")
  31.                  (cons 8 "3D-PIPE")
  32.                  (cons 10 (list 0 0 0))
  33.                  (cons 66 1)
  34.                  (cons 70 16)
  35.                  (cons 71 17)
  36.                  (cons 72 2)))
  37.   (foreach v pl
  38.      (entmake (list (cons 0 "VERTEX")
  39.                     (cons 8 "3D-PIPE")
  40.                     (cons 10 (trans v 1 0))
  41.                     (cons 70 64))))
  42.  
  43.   (entmake (list (cons 0 "SEQEND")(cons 8 "3D-PIPE")))
  44.  
  45.  
  46.  
  47.  

Any suggestions would be appreciated.  -David


« Last Edit: October 19, 2012, 06:07:05 AM by David Bethel »
R12 Dos - A2K

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
Re: Varying Size Tubing Interscetions
« Reply #1 on: October 18, 2012, 03:41:44 PM »
Maybe this http://www.theswamp.org/index.php?topic=1324.msg16857#msg16857
There is other code in the thread.
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: 12915
  • London, England
Re: Varying Size Tubing Interscetions
« Reply #2 on: October 18, 2012, 04:07:12 PM »
The points will follow the following function:

Code - Auto/Visual Lisp: [Select]
  1. (defun f ( r1 r2 i / y )
  2.     (list (* r2 (cos i)) (setq y (* r2 (sin i))) (sqrt (- (* r1 r1) (* y y))))
  3. )

Where:
r1 = radius of main tube
r2 = radius of intersecting tube
 i = CCW angle from direction of main tube


To test:
Code - Auto/Visual Lisp: [Select]
  1. (defun c:test ( / a i r1 r2 )
  2.     (setq i  (/ (+ pi pi) 30.0)
  3.           a  0.0
  4.           r1 2.5
  5.           r2 1.5
  6.     )
  7.     (entmake '((0 . "POLYLINE") (70 . 9)))
  8.     (repeat 30
  9.         (entmake (list '(0 . "VERTEX") '(70 . 32) (cons 10 (f r1 r2 a))))
  10.         (setq a (+ a i))
  11.     )
  12.     (entmake '((0 . "SEQEND")))
  13.     (princ)
  14. )

David Bethel

  • Swamp Rat
  • Posts: 656
Re: Varying Size Tubing Interscetions
« Reply #3 on: October 18, 2012, 04:19:37 PM »
The points will follow the following function:

Code - Auto/Visual Lisp: [Select]
  1. (defun f ( r1 r2 i / y )
  2.     (list (* r2 (cos i)) (setq y (* r2 (sin i))) (sqrt (- (* r1 r1) (* y y))))
  3. )



Thanks Lee,

I can do some thing with this.

CAB  It looked most to that thread was 2D oriented.  Maybe I was missing something. 

Thanks!  -David

R12 Dos - A2K

Lee Mac

  • Seagull
  • Posts: 12915
  • London, England
Re: Varying Size Tubing Interscetions
« Reply #4 on: October 18, 2012, 04:26:45 PM »
You're most welcome!  :-)

David Bethel

  • Swamp Rat
  • Posts: 656
Re: Varying Size Tubing Interscetions
« Reply #5 on: October 18, 2012, 04:42:03 PM »
Here's the finished product

Code - Text: [Select]
  1. ;;;90 DEGREE PIPE BRANCH TAKE OFF
  2. ;;;LEE MAC'S ENGINE
  3.  
  4. (defun c:pipe-LMB ( / r1 r2 s i a tp bp)
  5.  
  6.   (defun f ( r1 r2 i / y )
  7.      (list (* r2 (cos i))
  8.            (setq y (* r2 (sin i)))
  9.            (sqrt (- (* r1 r1) (* y y)))))
  10.  
  11.   (initget 7)
  12.   (setq r2 (getdist "\nTake Off Pipe Size:  "))
  13.  
  14.   (while (< r1 r2)
  15.          (initget 7)
  16.          (setq r1 (getdist "\nManifold Pipe Size:  ")))
  17.  
  18.   (initget 6)
  19.   (setq s (getint "\nNumber Of Segments <16>:   "))
  20.   (or s (setq s 16))
  21.  
  22.   (setq i (/ (+ pi pi) s)
  23.         a 0.0)
  24.  
  25.   (entmake (list (cons 0 "POLYLINE")
  26.                  (cons 8 "3D-PIPE")
  27.                  (cons 10 (list 0 0 0))
  28.                  (cons 66 1)
  29.                  (cons 70 16)
  30.                  (cons 71 (1+ s))
  31.                  (cons 72 2)))
  32.   (repeat (1+ s)
  33.      (setq tp (f r1 r2 a)
  34.            bp (list (car tp) (cadr tp) (+ r1 1.)))
  35.      (entmake (list (cons 0 "VERTEX")
  36.                     (cons 8 "3D-PIPE")
  37.                     (cons 10 (trans bp 1 0))
  38.                     (cons 70 64)))
  39.      (entmake (list (cons 0 "VERTEX")
  40.                     (cons 8 "3D-PIPE")
  41.                     (cons 10 (trans tp 1 0))
  42.                     (cons 70 64)))
  43.      (setq a (+ a i)))
  44.   (entmake (list (cons 0 "SEQEND")(cons 8 "3D-PIPE")))
  45.   (princ))
  46.  
  47.  

Makes a general 3D mesh 1 unit long of the tap in.  Thanks again!  -David
R12 Dos - A2K

Lee Mac

  • Seagull
  • Posts: 12915
  • London, England
Re: Varying Size Tubing Interscetions
« Reply #6 on: October 18, 2012, 04:50:42 PM »
To offer an alternative, here is some ugly VL code  :-P

Code - Auto/Visual Lisp: [Select]
  1. (defun c:tubes ( / rd1 rd2 spc tb1 tb2 tb3 tb4 thk )
  2.     (setq rd1 2.5
  3.           rd2 1.5
  4.           thk 0.2
  5.           tb1 (vla-addcylinder spc (vlax-3D-point 0.0 0.0 0.0) rd1 (* 4.0 rd1))
  6.           tb2 (vla-addcylinder spc (vlax-3D-point 0.0 0.0 rd1) rd2 (+ rd1 rd2))
  7.           tb3 (vla-addcylinder spc (vlax-3D-point 0.0 0.0 0.0) (- rd1 thk) (* 4.0 rd1))
  8.           tb4 (vla-addcylinder spc (vlax-3D-point 0.0 0.0 rd1) (- rd2 thk) (+ rd1 rd2))
  9.     )
  10.     (vla-rotate3D tb1 (vlax-3D-point 0.0 0.0 0.0) (vlax-3D-point 0.0 1.0 0.0) (/ pi 2.0))
  11.     (vla-rotate3D tb3 (vlax-3D-point 0.0 0.0 0.0) (vlax-3D-point 0.0 1.0 0.0) (/ pi 2.0))
  12.     (vla-boolean  tb1 acunion tb2)
  13.     (vla-boolean  tb1 acsubtraction tb3)
  14.     (vla-boolean  tb1 acsubtraction tb4)
  15.     (princ)
  16. )

Lee Mac

  • Seagull
  • Posts: 12915
  • London, England
Re: Varying Size Tubing Interscetions
« Reply #7 on: October 18, 2012, 04:53:20 PM »
Here's the finished product

< .. >

Makes a general 3D mesh 1 unit long of the tap in.  Thanks again!  -David

Nice one David - it works well!
Many thanks for the kind accreditation, I'm flattered  :-)

David Bethel

  • Swamp Rat
  • Posts: 656
Re: Varying Size Tubing Interscetions
« Reply #8 on: October 18, 2012, 05:06:03 PM »
No,  Thank You!

To offer an alternative, here is some ugly VL code  :-P

I must admit, that IS ugly.  :wink:

-David
R12 Dos - A2K