Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

  • Congratulations waross on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Lisp program for cones

Status
Not open for further replies.

Darken99

Mechanical
Apr 5, 2005
135
0
0
US
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")
)
)
)
 
Replies continue below

Recommended for you

I wonder if the zoom command is capturing
everything. try increasing

(command "_zoom" ".5xp")

to (command "_zoom" ".75xp")

or maybe eliminate it and see what happens.


 
Ok I tried that. I don't belive this is the problem. I can do very large cones that are less then 60 Degrees. When I try to do a 65 Degree cones, even small ones, it gives an error after the first line.

Thanks for your suggestions.
 
For what it's worth, the code seems to run fine on my system with a variety of cone dimensions. I can't tell if the layouts are actually correct, since I don't know exactly what the program is doing. But it draws the layouts every time without system errors. I use Intellicad 4 standard. It seems the problem you're having is Autocad or local system related. Hope this helps.
 
Ok thanks for the heads up.

Could you try these dimensions for a cone? I want to make sure it is not an anomaly with these particular dimensions.

169" Large ø
18-5/8" Small ø
161-1/4" Height
.1094" Thickness

Thanks in advance.
 
Status
Not open for further replies.
Back
Top