乐筑天下

搜索
欢迎各位开发者和用户入驻本平台 尊重版权,从我做起,拒绝盗版,拒绝倒卖 签到、发布资源、邀请好友注册,可以获得银币 请注意保管好自己的密码,避免账户资金被盗
查看: 48|回复: 17

[编程交流] 帮助拉伸弹簧和C

[复制链接]

36

主题

161

帖子

125

银币

初露锋芒

Rank: 3Rank: 3Rank: 3

铜币
182
发表于 2022-7-5 22:10:57 | 显示全部楼层 |阅读模式
大家好
 
我想用例程来画弹簧,需要帮助。
 
春天的种类
 
231117gux7ekkkofqm000e.png
 
参数
231118s4bj8pbb6n7m06h7.jpg
 
长度(H)、外径(D)、节距(t)、直径(D)、螺旋角(α=5°~9°)、圈数(n)需要用户输入。
 
如果输入长度(H),则不要输入节距(t)
如果输入节距(t),则不要输入长度(H)
 
输入参数,选择基点,
关键是画弹簧的末端,可能很难。
回复

使用道具 举报

26

主题

145

帖子

122

银币

初露锋芒

Rank: 3Rank: 3Rank: 3

铜币
130
发表于 2022-7-5 22:14:53 | 显示全部楼层
好帖子,希望有人能帮忙!
回复

使用道具 举报

36

主题

161

帖子

125

银币

初露锋芒

Rank: 3Rank: 3Rank: 3

铜币
182
发表于 2022-7-5 22:19:01 | 显示全部楼层
 
谢谢你,阿尔贝托,但似乎没有人担心。
回复

使用道具 举报

5

主题

956

帖子

963

银币

初来乍到

Rank: 1

铜币
35
发表于 2022-7-5 22:22:11 | 显示全部楼层
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-沿路径螺旋&
有什么好主意吗?
 
至少你在命令中尝试了一些东西,它可以帮助其他程序员理解。
您可以用命令和注释起草简单的代码,这些代码实际上无法工作,不用担心,但至少我们知道步骤。
例子:
  1. (defun c:test (/ )
  2. (setq radius [color="red"]??[/color] );  say you put this [color="red"]??[/color] but we can help to do the rest
  3. (setq point [color="red"]??[/color]); tell us what point in comment
  4. (command "helix" ..... )  ; comment what to do this
  5. (command "circle" ...)  ; what to do next
  6. (command "sweep" ....) ; etc..
  7. (command "union" ....)
  8. ...
  9. ...
  10. )

 
 
这个中国食物
 
如果可以手动绘制,是否可以在lisp中进行?
祝你好运
回复

使用道具 举报

5

主题

1334

帖子

1410

银币

限制会员

铜币
-20
发表于 2022-7-5 22:26:49 | 显示全部楼层
我的尝试。。。
 
  1. (defun c:springs ( / el p rmax rmin n ch1 ch2 hmax hmin h pitch helix do ci pl sols ss )
  2. (command "_.UCS" "_W")
  3. (command "_.VIEW" "_SWISO")
  4. (command "_.ZOOM" "_C" "_non" '(0.0 0.0 0.0) "")
  5. (setq p '(0.0 0.0 0.0))
  6. (setq el (entlast))
  7. (initget 7)
  8. (setq rmax (getdist p "\nPick or specify radius of helix : "))
  9. (initget 7)
  10. (setq rmin (getdist "\nPick or specify radius of sweep circle along helix : "))
  11. (while (<= rmax rmin)
  12.    (prompt "\nInvalid radius of sweep circle specification (must be < ") (princ (rtos rmax 2 50)) (prompt " ), please try specifying again...")
  13.    (initget 7)
  14.    (setq rmin (getdist "\nPick or specify radius of sweep circle along helix : "))
  15. )
  16. (initget 7)
  17. (setq n (getreal "\nSpecify number of turns of helix : "))
  18. (while (not (or (= 0.5 (- n (float (fix n)))) (= 0.0 (- n (float (fix n))))))
  19.    (prompt "\nInvalid number of turns of helix (must be whole number, or whole+half number), please try specifying again...")
  20.    (initget 7)
  21.    (setq n (getreal "\nSpecify number of turns of helix : "))
  22. )
  23. (initget "Height Pitch")
  24. (setq ch1 (getkword "\nChoose specification [Height/Pitch] <Height> : "))
  25. (if (null ch1) (setq ch1 "Height"))
  26. (initget "Extension Compression")
  27. (setq ch2 (getkword "\nChoose type [Extension/Compression] <Extension> : "))
  28. (if (null ch2) (setq ch2 "Extension"))
  29. (if (eq ch2 "Extension")
  30.    (if (eq ch1 "Height")
  31.      (progn
  32.        (initget 7)
  33.        (setq hmax (getdist "\nPick or specify height : "))
  34.        (setq h (- hmax (* 4 rmax) (* 4 rmin)))
  35.        (setq hmin (/ h n))
  36.        (while (or (< hmax (* 4 rmax)) (< hmin (* 2 rmin)))
  37.          (prompt "\nInvalid height specification (must be >= ") (princ (rtos (+ (* 4 rmax) (* 2 (+ n 2) rmin)) 2 50)) (prompt "), please try specifying again...")
  38.          (initget 7)
  39.          (setq hmax (getdist "\nPick or specify height : "))
  40.          (setq h (- hmax (* 4 rmax) (* 4 rmin)))
  41.          (setq hmin (/ h n))
  42.        )
  43.        (command "_.HELIX" p rmax rmax "_T" n "_H" hmin)
  44.        (while (> (getvar 'cmdactive) 0) (command ""))
  45.        (setq helix (entlast))
  46.      )
  47.      (progn
  48.        (initget 7)
  49.        (setq pitch (getreal "\nSpecify pitch angle in decimal degrees : "))
  50.        (setq hmin (* 2 pi rmax (/ (sin (cvunit pitch "degree" "radian")) (cos (cvunit pitch "degree" "radian")))))
  51.        (while (not (<= (cvunit (atan (/ rmin (* pi rmax))) "radian" "degree") pitch))
  52.          (prompt "\nInvalid pitch specification (must be >= ") (princ (rtos (cvunit (atan (/ rmin (* pi rmax))) "radian" "degree") 2 50)) (prompt "), please try specifying again...")
  53.          (initget 7)
  54.          (setq pitch (getreal "\nSpecify pich angle in decimal degrees : "))
  55.          (setq hmin (* 2 pi rmax (/ (sin (cvunit pitch "degree" "radian")) (cos (cvunit pitch "degree" "radian")))))
  56.        )
  57.        (command "_.HELIX" p rmax rmax "_T" n "_H" hmin)
  58.        (while (> (getvar 'cmdactive) 0) (command ""))
  59.        (setq helix (entlast))
  60.      )
  61.    )
  62.    (if (eq ch1 "Height")
  63.      (progn
  64.        (initget 7)
  65.        (setq hmax (getdist "\nPick or specify height : "))
  66.        (setq hmin (/ hmax n))
  67.        (while (< hmin (* 2 rmin))
  68.          (prompt "\nInvalid height specification (must be >= ") (princ (rtos (* 2 n rmin) 2 50)) (prompt "), please try specifying again...")
  69.          (initget 7)
  70.          (setq hmax (getdist "\nPick or specify height : "))
  71.          (setq hmin (/ hmax n))
  72.        )
  73.        (command "_.HELIX" p rmax rmax "_T" n "_H" hmin)
  74.        (while (> (getvar 'cmdactive) 0) (command ""))
  75.        (setq helix (entlast))
  76.      )
  77.      (progn
  78.        (initget 7)
  79.        (setq pitch (getreal "\nSpecify pitch angle in decimal degrees : "))
  80.        (setq hmin (* 2 pi rmax (/ (sin (cvunit pitch "degree" "radian")) (cos (cvunit pitch "degree" "radian")))))
  81.        (while (not (<= (cvunit (atan (/ rmin (* pi rmax))) "radian" "degree") pitch))
  82.          (prompt "\nInvalid pitch specification (must be >= ") (princ (rtos (cvunit (atan (/ rmin (* pi rmax))) "radian" "degree") 2 50)) (prompt "), please try specifying again...")
  83.          (initget 7)
  84.          (setq pitch (getreal "\nSpecify pich angle in decimal degrees : "))
  85.          (setq hmin (* 2 pi rmax (/ (sin (cvunit pitch "degree" "radian")) (cos (cvunit pitch "degree" "radian")))))
  86.        )
  87.        (command "_.HELIX" p rmax rmax "_T" n "_H" hmin)
  88.        (while (> (getvar 'cmdactive) 0) (command ""))
  89.        (setq helix (entlast))
  90.      )
  91.    )
  92. )
  93. (setq do (getvar 'delobj))
  94. (setvar 'delobj 1)
  95. (setq ci (entmakex (list '(0 . "CIRCLE") '(10 0.0 0.0 0.0) (cons 40 rmin))))
  96. (command "_.SWEEP" ci "" helix)
  97. (while (> (getvar 'cmdactive) 0) (command ""))
  98. (entdel helix)
  99. (if (eq ch2 "Extension")
  100.    (if (= 0.5 (- n (float (fix n))))
  101.      (progn
  102.        (setq h (* n hmin))
  103.        (command "_.UCS" "_FRONT")
  104.        (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))) "")
  105.        (setq pl (entlast))
  106.        (setq ci (entmakex (list '(0 . "CIRCLE") '(10 0.0 0.0 0.0) (cons 40 rmin))))
  107.        (command "_.SWEEP" ci "" pl)
  108.        (while (> (getvar 'cmdactive) 0) (command ""))
  109.        (entdel pl)
  110.        (command "_.SPHERE" "_non" (list rmax 0.0) rmin)
  111.        (while (> (getvar 'cmdactive) 0) (command ""))
  112.        (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)) "")
  113.        (setq pl (entlast))
  114.        (setq ci (entmakex (list '(0 . "CIRCLE") '(10 0.0 0.0 0.0) (cons 40 rmin))))
  115.        (command "_.SWEEP" ci "" pl)
  116.        (while (> (getvar 'cmdactive) 0) (command ""))
  117.        (entdel pl)
  118.        (command "_.SPHERE" "_non" (list (- rmax) h) rmin)
  119.        (while (> (getvar 'cmdactive) 0) (command ""))
  120.        (command "_.UCS" "_P")
  121.      )
  122.      (progn
  123.        (setq h (* n hmin))
  124.        (command "_.UCS" "_FRONT")
  125.        (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))) "")
  126.        (setq pl (entlast))
  127.        (setq ci (entmakex (list '(0 . "CIRCLE") '(10 0.0 0.0 0.0) (cons 40 rmin))))
  128.        (command "_.SWEEP" ci "" pl)
  129.        (while (> (getvar 'cmdactive) 0) (command ""))
  130.        (entdel pl)
  131.        (command "_.SPHERE" "_non" (list rmax 0.0) rmin)
  132.        (while (> (getvar 'cmdactive) 0) (command ""))
  133.        (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)) "")
  134.        (setq pl (entlast))
  135.        (setq ci (entmakex (list '(0 . "CIRCLE") '(10 0.0 0.0 0.0) (cons 40 rmin))))
  136.        (command "_.SWEEP" ci "" pl)
  137.        (while (> (getvar 'cmdactive) 0) (command ""))
  138.        (entdel pl)
  139.        (command "_.SPHERE" "_non" (list rmax h) rmin)
  140.        (while (> (getvar 'cmdactive) 0) (command ""))
  141.        (command "_.UCS" "_P")
  142.      )
  143.    )
  144.    (if (= 0.5 (- n (float (fix n))))
  145.      (progn
  146.        (setq h (* n hmin))
  147.        (command "_.PLINE" "_non" (list rmax 0.0) "_A" "_S" "_non" (list 0.0 (- rmax)) "_non" (list 0.0 rmax) "")
  148.        (setq pl (entlast))
  149.        (setq ci (entmakex (list '(0 . "CIRCLE") '(10 0.0 0.0 0.0) (cons 40 rmin))))
  150.        (command "_.SWEEP" ci "" pl)
  151.        (while (> (getvar 'cmdactive) 0) (command ""))
  152.        (entdel pl)
  153.        (command "_.PLINE" "_non" (list (- rmax) 0.0 h) "_A" "_S" "_non" (list 0.0 (- rmax) h) "_non" (list 0.0 rmax h) "")
  154.        (setq pl (entlast))
  155.        (setq ci (entmakex (list '(0 . "CIRCLE") '(10 0.0 0.0 0.0) (cons 40 rmin))))
  156.        (command "_.SWEEP" ci "" pl)
  157.        (while (> (getvar 'cmdactive) 0) (command ""))
  158.        (entdel pl)
  159.      )
  160.      (progn
  161.        (setq h (* n hmin))
  162.        (command "_.PLINE" "_non" (list rmax 0.0) "_A" "_S" "_non" (list 0.0 (- rmax)) "_non" (list 0.0 rmax) "")
  163.        (setq pl (entlast))
  164.        (setq ci (entmakex (list '(0 . "CIRCLE") '(10 0.0 0.0 0.0) (cons 40 rmin))))
  165.        (command "_.SWEEP" ci "" pl)
  166.        (while (> (getvar 'cmdactive) 0) (command ""))
  167.        (entdel pl)
  168.        (command "_.PLINE" "_non" (list rmax 0.0 h) "_A" "_S" "_non" (list 0.0 rmax h) "_non" (list 0.0 (- rmax) h) "")
  169.        (setq pl (entlast))
  170.        (setq ci (entmakex (list '(0 . "CIRCLE") '(10 0.0 0.0 0.0) (cons 40 rmin))))
  171.        (command "_.SWEEP" ci "" pl)
  172.        (while (> (getvar 'cmdactive) 0) (command ""))
  173.        (entdel pl)
  174.      )
  175.    )
  176. )
  177. (command "_.UCS" "_P")
  178. (while (setq el (if el (entnext el) (entnext)))
  179.    (setq sols (cons el sols))
  180. )
  181. (setq ss (ssadd))
  182. (foreach sol sols
  183.    (ssadd sol ss)
  184. )
  185. (command "_.UNION" ss "")
  186. (if (eq ch2 "Compression")
  187.    (progn
  188.      (setq el (entlast))
  189.      (command "_.BOX" "_non" (list (- (+ rmax rmin)) (- (+ rmax rmin)) 0.0) "_non" (list (+ rmax rmin) (+ rmax rmin) h))
  190.      (while (> (getvar 'cmdactive) 0) (command ""))
  191.      (command "_.INTERSECT" el (entlast) "")
  192.      (while (> (getvar 'cmdactive) 0) (command ""))
  193.    )
  194. )
  195. (command "_.VSCURRENT" "_C")
  196. (setvar 'delobj do)
  197. (princ)
  198. )
HTH,M.R。
顺便说一句,你哥哥可能是著名的台球运动员丁吗?。。。
回复

使用道具 举报

36

主题

161

帖子

125

银币

初露锋芒

Rank: 3Rank: 3Rank: 3

铜币
182
发表于 2022-7-5 22:30:42 | 显示全部楼层
 
 
你好,hanhphuc
 
非常感谢!我会仔细品尝的。
 
Fooood??这是什么意思?
回复

使用道具 举报

36

主题

161

帖子

125

银币

初露锋芒

Rank: 3Rank: 3Rank: 3

铜币
182
发表于 2022-7-5 22:32:27 | 显示全部楼层
 
你好,马尔科。
我试一下,然后再打给你:-)
 
真 的!你知道吗?丁俊晖?你看过他打球吗?
回复

使用道具 举报

36

主题

161

帖子

125

银币

初露锋芒

Rank: 3Rank: 3Rank: 3

铜币
182
发表于 2022-7-5 22:37:45 | 显示全部楼层
 
你好,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
回复

使用道具 举报

5

主题

1334

帖子

1410

银币

限制会员

铜币
-20
发表于 2022-7-5 22:40:10 | 显示全部楼层
金辉,我又修改代码了。。。请将其复制并粘贴到记事本中,然后再次另存为*。lsp。。。然后再试一次,并遵循重要信息ab高度和螺距值,你们必须输入,以正确的螺旋作出。。。首先输入一些小的距离或角度,然后输入一个比那个大的被提示到ACAD的文本屏幕。。。
 
如果您有什么问题,请再次通知我。。。
M、 R。
回复

使用道具 举报

36

主题

161

帖子

125

银币

初露锋芒

Rank: 3Rank: 3Rank: 3

铜币
182
发表于 2022-7-5 22:45:16 | 显示全部楼层
你好,马尔科。
许多人认为!
我测试了一下,发现有点缺陷。
压缩弹簧,末端重叠。
231122uyjuiqik4bykbyww.png
 
我想可以缩短
231125mcsed6pkv6qvhl7s.png
 
如果不在wcs工作,将如下所示:
231129g8w8ztlaqrr3jrql.png
 
拉伸弹簧,过渡的末端不平滑。
231131rcujeyc88q7axeci.png
231140qhwmm3m2d4dpm0my.png
 
能这样做吗?
231145otfvx8zzmv7jmfb2.png
 
如果困难,可以这样
231148zaux1n67enmbayrn.jpg
 
 
 
再次感谢,马克:拇指支持:
回复

使用道具 举报

发表回复

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

  • 微信公众平台

  • 扫描访问手机版

  • 点击图片下载手机App

QQ|关于我们|小黑屋|乐筑天下 繁体中文

GMT+8, 2025-3-11 06:39 , Processed in 0.785412 second(s), 75 queries .

© 2020-2025 乐筑天下

联系客服 关注微信 帮助中心 下载APP 返回顶部 返回列表