帮助拉伸弹簧和C
大家好我想用例程来画弹簧,需要帮助。
春天的种类
参数
长度(H)、外径(D)、节距(t)、直径(D)、螺旋角(α=5°~9°)、圈数(n)需要用户输入。
如果输入长度(H),则不要输入节距(t)
如果输入节距(t),则不要输入长度(H)
输入参数,选择基点,
关键是画弹簧的末端,可能很难。 好帖子,希望有人能帮忙!
谢谢你,阿尔贝托,但似乎没有人担心。 try命令:helix
或者这条旧的相似的线
http://www.cadtutor.net/forum/showthread.php?78-把你的螺旋线拿过来!
http://www.cadtutor.net/forum/showthread.php?57899-螺旋命令问题
http://www.cadtutor.net/forum/showthread.php?89044-沿路径螺旋&
有什么好主意吗?
至少你在命令中尝试了一些东西,它可以帮助其他程序员理解。
您可以用命令和注释起草简单的代码,这些代码实际上无法工作,不用担心,但至少我们知道步骤。
例子:
(defun c:test (/ )
(setq radius ?? );say you put this ?? but we can help to do the rest
(setq point ??); tell us what point in comment
(command "helix" ..... ); comment what to do this
(command "circle" ...); what to do next
(command "sweep" ....) ; etc..
(command "union" ....)
...
...
)
这个中国食物
如果可以手动绘制,是否可以在lisp中进行?
祝你好运 我的尝试。。。
(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> : "))
(if (null ch1) (setq ch1 "Height"))
(initget "Extension Compression")
(setq ch2 (getkword "\nChoose type <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)
(command "_.SPHERE" "_non" (list (- rmax) h) rmin)
(while (> (getvar 'cmdactive) 0) (command ""))
(command "_.UCS" "_P")
)
(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)
(command "_.SPHERE" "_non" (list rmax h) rmin)
(while (> (getvar 'cmdactive) 0) (command ""))
(command "_.UCS" "_P")
)
)
(if (= 0.5 (- n (float (fix n))))
(progn
(setq h (* n hmin))
(command "_.PLINE" "_non" (list rmax 0.0) "_A" "_S" "_non" (list 0.0 (- rmax)) "_non" (list 0.0 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 "_.PLINE" "_non" (list (- rmax) 0.0 h) "_A" "_S" "_non" (list 0.0 (- rmax) h) "_non" (list 0.0 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)
)
(progn
(setq h (* n hmin))
(command "_.PLINE" "_non" (list rmax 0.0) "_A" "_S" "_non" (list 0.0 (- rmax)) "_non" (list 0.0 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 "_.PLINE" "_non" (list rmax 0.0 h) "_A" "_S" "_non" (list 0.0 rmax h) "_non" (list 0.0 (- 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)
)
)
)
(command "_.UCS" "_P")
(while (setq el (if el (entnext el) (entnext)))
(setq sols (cons el sols))
)
(setq ss (ssadd))
(foreach sol sols
(ssadd sol ss)
)
(command "_.UNION" ss "")
(if (eq ch2 "Compression")
(progn
(setq el (entlast))
(command "_.BOX" "_non" (list (- (+ rmax rmin)) (- (+ rmax rmin)) 0.0) "_non" (list (+ rmax rmin) (+ rmax rmin) h))
(while (> (getvar 'cmdactive) 0) (command ""))
(command "_.INTERSECT" el (entlast) "")
(while (> (getvar 'cmdactive) 0) (command ""))
)
)
(command "_.VSCURRENT" "_C")
(setvar 'delobj do)
(princ)
)
HTH,M.R。
顺便说一句,你哥哥可能是著名的台球运动员丁吗?。。。
你好,hanhphuc
非常感谢!我会仔细品尝的。
Fooood??这是什么意思?
你好,马尔科。
我试一下,然后再打给你:-)
真 的!你知道吗?丁俊晖?你看过他打球吗?
你好,marko
我测试使用autocad 2010。
拾取或指定螺旋半径:10
拾取或指定沿螺旋线扫掠圆的半径:1
指定螺旋的圈数:20
选择规格[高度/像素]:P
选择类型[扩展/压缩]:E
以十进制度数指定pich角度:9
_.螺旋线
圈数=20.0000扭转=逆时针
指定基点的中心点:
指定底面半径或[直径]:10.00000000000000
指定顶部半径或[直径]:10.00000000000000
指定螺旋高度或[轴端点/转角/转角高度/扭曲]:
输入圈数:20.00000000000000
指定螺旋高度或[轴端点/转角/转角高度/扭曲]:
指定转弯之间的距离:
指定螺旋高度或[轴端点/转角/转角高度/扭曲]:
命令:_。扫描
当前线框密度:等值线=4
选择要扫描的对象:找到1个
选择要扫描的对象:
选择扫描路径或[对齐/基点/缩放/扭曲]:
无法扫描选定对象。
命令:;错误:错误的参数类型:numberp:nil
---------------------------------------------------------------------------------------------------
拾取或指定螺旋半径:10
拾取或指定沿螺旋线扫掠圆的半径:1
指定螺旋的圈数:20
选择规格[高度/像素]:P
选择类型[扩展/压缩]:C
以十进制度数指定pich角度:9
_.螺旋线
转数=1.0000扭转=逆时针
指定基点的中心点:
指定底面半径或[直径]:10.00000000000000
指定顶部半径或[直径]:10.00000000000000
指定螺旋高度或[轴端点/转角/转角高度/扭曲]:
输入圈数:20.00000000000000
指定螺旋高度或[轴端点/转角/转角高度/扭曲]:
指定转弯之间的距离:
指定螺旋高度或[轴端点/转角/转角高度/扭曲]:
命令:_。扫描
当前线框密度:等值线=4
选择要扫描的对象:找到1个
选择要扫描的对象:
选择扫描路径或[对齐/基点/缩放/扭曲]:
无法扫描选定对象。
命令:;错误:错误的参数类型:numberp:nil
---------------------------------------------------------------------------------------------------
拾取或指定螺旋半径:10
拾取或指定沿螺旋线扫掠圆的半径:1
指定螺旋的圈数:20
选择规格[高度(H)]:H
选择类型[扩展/压缩]:C
拾取或指定高度:100
_.螺旋线
转数=20.0000转=CCW
指定基点的中心点:
指定底面半径或[直径]:10.00000000000000
指定顶部半径或[直径]:10.00000000000000
指定螺旋高度或[轴端点/转角/转角高度/扭曲]:
输入圈数:20.00000000000000
指定螺旋高度或[轴端点/转角/转角高度/扭曲]:
指定转弯之间的距离:
指定螺旋高度或[轴端点/转角/转角高度/扭曲]:
命令:_。扫描
当前线框密度:等值线=4
选择要扫描的对象:找到1个
选择要扫描的对象:
选择扫描路径或[对齐/基点/缩放/扭曲]:
无法扫描选定对象。
命令:;错误:错误的参数类型:numberp:nil 金辉,我又修改代码了。。。请将其复制并粘贴到记事本中,然后再次另存为*。lsp。。。然后再试一次,并遵循重要信息ab高度和螺距值,你们必须输入,以正确的螺旋作出。。。首先输入一些小的距离或角度,然后输入一个比那个大的被提示到ACAD的文本屏幕。。。
如果您有什么问题,请再次通知我。。。
M、 R。 你好,马尔科。
许多人认为!
我测试了一下,发现有点缺陷。
压缩弹簧,末端重叠。
我想可以缩短
如果不在wcs工作,将如下所示:
拉伸弹簧,过渡的末端不平滑。
能这样做吗?
如果困难,可以这样
再次感谢,马克:拇指支持:
页:
[1]
2