36
161
125
初露锋芒
使用道具 举报
26
145
122
5
956
963
初来乍到
(defun c:test (/ )(setq radius [color="red"]??[/color] ); say you put this [color="red"]??[/color] but we can help to do the rest(setq point [color="red"]??[/color]); tell us what point in comment(command "helix" ..... ) ; comment what to do this(command "circle" ...) ; what to do next(command "sweep" ....) ; etc..(command "union" ....)......)
1334
1410
限制会员
(defun c:springs ( / el p rmax rmin n ch1 ch2 hmax hmin h pitch helix do ci pl sols ss ) (command "_.UCS" "_W") (command "_.VIEW" "_SWISO") (command "_.ZOOM" "_C" "_non" '(0.0 0.0 0.0) "") (setq p '(0.0 0.0 0.0)) (setq el (entlast)) (initget 7) (setq rmax (getdist p "\nPick or specify radius of helix : ")) (initget 7) (setq rmin (getdist "\nPick or specify radius of sweep circle along helix : ")) (while (<= rmax rmin) (prompt "\nInvalid radius of sweep circle specification (must be < ") (princ (rtos rmax 2 50)) (prompt " ), please try specifying again...") (initget 7) (setq rmin (getdist "\nPick or specify radius of sweep circle along helix : ")) ) (initget 7) (setq n (getreal "\nSpecify number of turns of helix : ")) (while (not (or (= 0.5 (- n (float (fix n)))) (= 0.0 (- n (float (fix n)))))) (prompt "\nInvalid number of turns of helix (must be whole number, or whole+half number), please try specifying again...") (initget 7) (setq n (getreal "\nSpecify number of turns of helix : ")) ) (initget "Height Pitch") (setq ch1 (getkword "\nChoose specification [Height/Pitch] <Height> : ")) (if (null ch1) (setq ch1 "Height")) (initget "Extension Compression") (setq ch2 (getkword "\nChoose type [Extension/Compression] <Extension> : ")) (if (null ch2) (setq ch2 "Extension")) (if (eq ch2 "Extension") (if (eq ch1 "Height") (progn (initget 7) (setq hmax (getdist "\nPick or specify height : ")) (setq h (- hmax (* 4 rmax) (* 4 rmin))) (setq hmin (/ h n)) (while (or (< hmax (* 4 rmax)) (< hmin (* 2 rmin))) (prompt "\nInvalid height specification (must be >= ") (princ (rtos (+ (* 4 rmax) (* 2 (+ n 2) rmin)) 2 50)) (prompt "), please try specifying again...") (initget 7) (setq hmax (getdist "\nPick or specify height : ")) (setq h (- hmax (* 4 rmax) (* 4 rmin))) (setq hmin (/ h n)) ) (command "_.HELIX" p rmax rmax "_T" n "_H" hmin) (while (> (getvar 'cmdactive) 0) (command "")) (setq helix (entlast)) ) (progn (initget 7) (setq pitch (getreal "\nSpecify pitch angle in decimal degrees : ")) (setq hmin (* 2 pi rmax (/ (sin (cvunit pitch "degree" "radian")) (cos (cvunit pitch "degree" "radian"))))) (while (not (<= (cvunit (atan (/ rmin (* pi rmax))) "radian" "degree") pitch)) (prompt "\nInvalid pitch specification (must be >= ") (princ (rtos (cvunit (atan (/ rmin (* pi rmax))) "radian" "degree") 2 50)) (prompt "), please try specifying again...") (initget 7) (setq pitch (getreal "\nSpecify pich angle in decimal degrees : ")) (setq hmin (* 2 pi rmax (/ (sin (cvunit pitch "degree" "radian")) (cos (cvunit pitch "degree" "radian"))))) ) (command "_.HELIX" p rmax rmax "_T" n "_H" hmin) (while (> (getvar 'cmdactive) 0) (command "")) (setq helix (entlast)) ) ) (if (eq ch1 "Height") (progn (initget 7) (setq hmax (getdist "\nPick or specify height : ")) (setq hmin (/ hmax n)) (while (< hmin (* 2 rmin)) (prompt "\nInvalid height specification (must be >= ") (princ (rtos (* 2 n rmin) 2 50)) (prompt "), please try specifying again...") (initget 7) (setq hmax (getdist "\nPick or specify height : ")) (setq hmin (/ hmax n)) ) (command "_.HELIX" p rmax rmax "_T" n "_H" hmin) (while (> (getvar 'cmdactive) 0) (command "")) (setq helix (entlast)) ) (progn (initget 7) (setq pitch (getreal "\nSpecify pitch angle in decimal degrees : ")) (setq hmin (* 2 pi rmax (/ (sin (cvunit pitch "degree" "radian")) (cos (cvunit pitch "degree" "radian"))))) (while (not (<= (cvunit (atan (/ rmin (* pi rmax))) "radian" "degree") pitch)) (prompt "\nInvalid pitch specification (must be >= ") (princ (rtos (cvunit (atan (/ rmin (* pi rmax))) "radian" "degree") 2 50)) (prompt "), please try specifying again...") (initget 7) (setq pitch (getreal "\nSpecify pich angle in decimal degrees : ")) (setq hmin (* 2 pi rmax (/ (sin (cvunit pitch "degree" "radian")) (cos (cvunit pitch "degree" "radian"))))) ) (command "_.HELIX" p rmax rmax "_T" n "_H" hmin) (while (> (getvar 'cmdactive) 0) (command "")) (setq helix (entlast)) ) ) ) (setq do (getvar 'delobj)) (setvar 'delobj 1) (setq ci (entmakex (list '(0 . "CIRCLE") '(10 0.0 0.0 0.0) (cons 40 rmin)))) (command "_.SWEEP" ci "" helix) (while (> (getvar 'cmdactive) 0) (command "")) (entdel helix) (if (eq ch2 "Extension") (if (= 0.5 (- n (float (fix n)))) (progn (setq h (* n hmin)) (command "_.UCS" "_FRONT") (command "_.PLINE" "_non" (list rmax 0.0) "_non" '(0.0 0.0) "_non" (list 0.0 (- (* 2 rmin))) "_A" "_S" "_non" (list rmax (- (+ (* 2 rmin) rmax))) "_non" (list (- rmax) (- (+ (* 2 rmin) rmax))) "") (setq pl (entlast)) (setq ci (entmakex (list '(0 . "CIRCLE") '(10 0.0 0.0 0.0) (cons 40 rmin)))) (command "_.SWEEP" ci "" pl) (while (> (getvar 'cmdactive) 0) (command "")) (entdel pl) (command "_.SPHERE" "_non" (list rmax 0.0) rmin) (while (> (getvar 'cmdactive) 0) (command "")) (command "_.PLINE" "_non" (list (- rmax) h) "_non" (list 0.0 h) "_non" (list 0.0 (+ (* 2 rmin) h)) "_A" "_S" "_non" (list (- rmax) (+ (* 2 rmin) rmax h)) "_non" (list rmax (+ (* 2 rmin) rmax h)) "") (setq pl (entlast)) (setq ci (entmakex (list '(0 . "CIRCLE") '(10 0.0 0.0 0.0) (cons 40 rmin)))) (command "_.SWEEP" ci "" pl) (while (> (getvar 'cmdactive) 0) (command "")) (entdel pl)