Darken99
Mechanical
- Apr 5, 2005
- 135
This program is for unwraping cones into 2d. My problem is when ever the cone is greater then 60 Degrees it does not work. Can anyone see why it would not work?
Thanks
(defun c:dcone (/ sd d H sr R X thick deg xp1 xp2 yp1 yp2)
(setq d (getreal "\nLarge Inside Diameter of Cone. "))
(setq sd (getreal "\nSmall Inside Diameter of Cone. "))
(setq H (getreal "\Height of Cone. "))
(setq thick (getreal "\nThickness of Cone. "))
(setq d (+ d (/ (* (* 2 (cos (atan (/ H (/(- d sd) 2 ))))) thick) 2)))
(setq sd (+ sd (/ (* (* 2 (cos (atan (/ H (/(- d sd) 2 ))))) thick) 2)))
(setq x (expt (+ (expt (/ (- d sd) 2) 2) (expt H 2)) 0.5))
(setq sr (/ (* sd x) (- d sd)))
(setq R (+ sr X) )
(setq deg (*(/ d R) 180))
;area = (R ^ 2 - sr ^ 2) * deg / 360 * 3.14159
;wt = area / 144 * thick * 40.8
(If (<= deg 180) (progn
(setq yp1 ( * R (Sin (*(/ 3.14159 180) (/ (- 180 deg) 2)))))
(setq xp1 ( * R (cos (*(/ 3.14159 180) (/ (- 180 deg) 2)))))
(setq yp2 ( * sr (Sin (*(/ 3.14159 180) (/ (- 180 deg) 2)))))
(setq xp2 ( * sr (cos (*(/ 3.14159 180) (/ (- 180 deg) 2)))))
(command "Line" (strcat (rtos xp2) "," (rtos yp2)) (strcat "@" (rtos (- R sr)) "<" (rtos (/(- 180 deg) 2))) "")
(command "_zoom" "e")
(command "_zoom" ".5xp")
(command "copy" "la" "" "0,0" "0,0")
(command "_zoom" "e")
(command "_zoom" ".5xp")
(command "rotate" "la" "" "0,0" deg)
(command "arc" (strcat(rtos xp1) "," (rtos yp1) ) (strcat "0," (rtos R)) (strcat "-" (rtos xp1) "," (rtos yp1) ))
(command "arc" (strcat(rtos xp2) "," (rtos yp2) ) (strcat "0," (rtos sr)) (strcat "-" (rtos xp2) "," (rtos yp2) ))
(command "_zoom" "e")
)
(progn
(If (> deg 270)(progn
(setq yp1 (* R (Sin (*(Atan 1) ( *(/ (- deg 270)180)4)))))
(setq xp1 (* R (COS (*(Atan 1) ( *(/ (- deg 270)180)4)))))
(setq yp2 (* sr (sin (*(Atan 1) ( *(/ (- deg 270)180)4)))))
(setq xp2 (* sr (COS (*(Atan 1) ( *(/ (- deg 270)180)4)))))
)
(progn
(setq yp1 (* (- R) (Sin (*(Atan 1) ( *(/ (- 270 deg)180)4)))))
(setq xp1 (* R (cos (*(Atan 1) ( *(/ (- 270 deg)180)4)))))
(setq yp2 (* (- sr) (Sin (*(Atan 1) ( *(/ (- 270 deg)180)4)))))
(setq xp2 (* sr (cos (*(Atan 1) ( *(/ (- 270 deg)180)4)))))
)
)
(command "line" (strcat "0," (rtos sr)) (strcat "@" (rtos (- R sr)) "<90") "")
(command "line" (strcat (rtos xp1) "," (rtos yp1))(strcat(rtos xp2) "," (rtos yp2)) "")
(command "_zoom" "e")
(command "_zoom" ".5xp")
(command "arc" (strcat "0," (rtos R)) (strcat "-" (rtos R) ",0")(strcat(rtos xp1) "," (rtos yp1)))
(command "arc" (strcat "0," (rtos sr)) (strcat"-" (rtos sr) ",0")(strcat(rtos xp2) "," (rtos yp2)))
(command "_zoom" "e")
)
)
)
Thanks
(defun c:dcone (/ sd d H sr R X thick deg xp1 xp2 yp1 yp2)
(setq d (getreal "\nLarge Inside Diameter of Cone. "))
(setq sd (getreal "\nSmall Inside Diameter of Cone. "))
(setq H (getreal "\Height of Cone. "))
(setq thick (getreal "\nThickness of Cone. "))
(setq d (+ d (/ (* (* 2 (cos (atan (/ H (/(- d sd) 2 ))))) thick) 2)))
(setq sd (+ sd (/ (* (* 2 (cos (atan (/ H (/(- d sd) 2 ))))) thick) 2)))
(setq x (expt (+ (expt (/ (- d sd) 2) 2) (expt H 2)) 0.5))
(setq sr (/ (* sd x) (- d sd)))
(setq R (+ sr X) )
(setq deg (*(/ d R) 180))
;area = (R ^ 2 - sr ^ 2) * deg / 360 * 3.14159
;wt = area / 144 * thick * 40.8
(If (<= deg 180) (progn
(setq yp1 ( * R (Sin (*(/ 3.14159 180) (/ (- 180 deg) 2)))))
(setq xp1 ( * R (cos (*(/ 3.14159 180) (/ (- 180 deg) 2)))))
(setq yp2 ( * sr (Sin (*(/ 3.14159 180) (/ (- 180 deg) 2)))))
(setq xp2 ( * sr (cos (*(/ 3.14159 180) (/ (- 180 deg) 2)))))
(command "Line" (strcat (rtos xp2) "," (rtos yp2)) (strcat "@" (rtos (- R sr)) "<" (rtos (/(- 180 deg) 2))) "")
(command "_zoom" "e")
(command "_zoom" ".5xp")
(command "copy" "la" "" "0,0" "0,0")
(command "_zoom" "e")
(command "_zoom" ".5xp")
(command "rotate" "la" "" "0,0" deg)
(command "arc" (strcat(rtos xp1) "," (rtos yp1) ) (strcat "0," (rtos R)) (strcat "-" (rtos xp1) "," (rtos yp1) ))
(command "arc" (strcat(rtos xp2) "," (rtos yp2) ) (strcat "0," (rtos sr)) (strcat "-" (rtos xp2) "," (rtos yp2) ))
(command "_zoom" "e")
)
(progn
(If (> deg 270)(progn
(setq yp1 (* R (Sin (*(Atan 1) ( *(/ (- deg 270)180)4)))))
(setq xp1 (* R (COS (*(Atan 1) ( *(/ (- deg 270)180)4)))))
(setq yp2 (* sr (sin (*(Atan 1) ( *(/ (- deg 270)180)4)))))
(setq xp2 (* sr (COS (*(Atan 1) ( *(/ (- deg 270)180)4)))))
)
(progn
(setq yp1 (* (- R) (Sin (*(Atan 1) ( *(/ (- 270 deg)180)4)))))
(setq xp1 (* R (cos (*(Atan 1) ( *(/ (- 270 deg)180)4)))))
(setq yp2 (* (- sr) (Sin (*(Atan 1) ( *(/ (- 270 deg)180)4)))))
(setq xp2 (* sr (cos (*(Atan 1) ( *(/ (- 270 deg)180)4)))))
)
)
(command "line" (strcat "0," (rtos sr)) (strcat "@" (rtos (- R sr)) "<90") "")
(command "line" (strcat (rtos xp1) "," (rtos yp1))(strcat(rtos xp2) "," (rtos yp2)) "")
(command "_zoom" "e")
(command "_zoom" ".5xp")
(command "arc" (strcat "0," (rtos R)) (strcat "-" (rtos R) ",0")(strcat(rtos xp1) "," (rtos yp1)))
(command "arc" (strcat "0," (rtos sr)) (strcat"-" (rtos sr) ",0")(strcat(rtos xp2) "," (rtos yp2)))
(command "_zoom" "e")
)
)
)