Jump to content

Mitered End Ellipse For Tubing


Recommended Posts

Posted

I know that I've done this before, but I'm drawing a blank.

 

The end result is a 3DPOLY ellipse shaped with the given diameter and cut angle for tubing:

 (initget 6)
 (setq d (getdist "\nTube Diameter <1>:   "))
 (or d (setq d 1))

 (initget 1)
 (setq l (getangle "\nEnd Angle:   "))

 (initget 6)
 (setq s (getint "\nNumber Of Tube Segments <16>:   "))
 (or s (setq s 16))

 (setq i (/ (* pi 2) s) ; angle increase per segment
       a 0              ; start angle 0 
       ll nil)          ; point list nil

 (repeat (1+ s)
    (setq ll
       (cons
          (list (* (cos a) d 0.5)
                (* (sin a) d 0.5)
                (* d 0.5 (sin a) (cos l)));;;HERE IS THE PROBLEM CHILD
          ll)
           a (+ a i)))

 (command "_.3DPOLY")
 (foreach p ll (command p))
 (command "")

 

It may be that I need the tangent and not the sine.

 

180 or 0 degree cuts won't be allowed as should crash everything

Posted

Hey David,

 

Give this a shot:

 

 (initget 6)
 (setq d (getdist "\nTube Diameter <1>:   "))
 (or d (setq d 1))

 (initget 1)
 (setq l (getangle "\nEnd Angle:   "))

 (initget 6)
 (setq s (getint "\nNumber Of Tube Segments <16>:   "))
 (or s (setq s 16))

 (setq i (/ (* pi 2) s) ; angle increase per segment
       a 0              ; start angle 0 
       ll nil)          ; point list nil

 (repeat (1+ s)
    (setq ll
       (cons
          (list (* (cos a) d 0.5)
                (* (sin a) d 0.5)
                (* d 0.5 (sin a) (sin l)));;;HERE IS THE PROBLEM CHILD
          ll)
           a (+ a i)))

 (command "_.3DPOLY")
 (foreach p ll (command p))
 (command "")

Posted

It was tangent. still didn't find my old one.

 

(defun c:mitertub (/ d l r x s i a rl ll vl)

(defun tan (z / cosz)
  (if (zerop (setq cosz (cos z)))
    9.7e307
    (/ (sin z) cosz)))

 (initget 6)
 (setq d (getdist "\nTube Diameter <1>:   "))
 (or d (setq d 1))

 (initget 1)
 (setq l (getangle "\nLeft End Angle -89.9 to +89.9:   "))

 (initget 1)
 (setq r (getangle "\nRight End Angle -89.9 to +89.9:   "))

 (initget 7)
 (setq x (getdist "\nTube Centerline Length:   "))

 (initget 6)
 (setq s (getint "\nNumber Of Tube Segments <16>:   "))
 (or s (setq s 16))

;;;INITIATE ANGLE VARIABLES
 (setq i (/ (* pi 2) s)
       a 0)

;;;RIGHT AND LEFT END LISTS
 (repeat (1+ s)
    (setq rl (cons (trans (list (* (cos a) d 0.5)
                                (* (sin a) d 0.5)
                                (* d 0.5 (sin a) (tan r)))
                           0 '(1 0 0)) rl)
          ll (cons (trans (list (* (cos a) d 0.5)
                                (* (sin a) d 0.5)
                                (* d 0.5 (sin a) (tan l)))
                           0 '(1 0 0)) ll)
           a (+ a i)))

;;;CREATE THE MESH LIST
 (setq vl (list (list 0 0 0)
                (last ll)
                (list (car (last rl))
                      (- (+ (cadr (last rl)) x))
                      (caddr (last rl)))
                (list 0 (- x) 0)))

 (while ll
    (setq vl (cons (list 0 0 0) vl)
          vl (cons (car ll)     vl)
          vl (cons (list (car (car rl))
                         (- (+ (cadr (car rl)) x))
                         (caddr (car rl))) vl)
          vl (cons (list 0 (- x) 0) vl)
          ll (cdr ll)
          rl (cdr rl)))

;;;MAKE THE MESH
(entmake (list (cons 0 "POLYLINE")
               (cons 10 (list 0 0 0))
               (cons 66 1)(cons 8 "3D")
               (cons 70 16)
               (cons 71 (1+ s))
               (cons 72 4)))
(foreach v vl
   (entmake (list (cons 0 "VERTEX")(cons 8 "3D")
                  (cons 10 v)
                  (cons 70 64))))
(entmake (list (cons 0 "SEQEND")(cons 8 "3D")))

(prin1))

 

For mitered ends of tubular tray rails. -David

3D-TUBE.GIF

ar-tube.jpg

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
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
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...