明经CAD社区

 找回密码
 注册

QQ登录

只需一步,快速开始

搜索
12
返回列表 发新帖
楼主: xmping78

哪位大虾,帮忙三维螺杆

  [复制链接]
发表于 2004-6-3 15:03:00 | 显示全部楼层
提示: 作者被禁止或删除 内容自动屏蔽
发表于 2004-6-3 21:59:00 | 显示全部楼层
这个程序是《Autocad 绘图与三维加模实例》高贵生编著 人民邮电出版的一个例子觉得很好,贴给大家,只供学习。 (defun c:luowen()
(setq d(getreal "螺纹外径="))
(setq r(/ d 2)) ;螺纹半径
(setq tt(getreal "螺距=")) ;螺距
(setq l(getreal "长度=")) ;螺纹度
(setq p0(getpoint "指定基点"))
(setq p01(list (nth 0 p0) (nth 1 p0) (- l (/ tt 1.155))))
(setq p02(list (nth 0 p0) (nth 1 p0) l))
(command "layer" "m" "l1" "c" 1 "" "")
(command "layer" "m" "l2" "c" 2 "" "")
(command "layer" "m" "l3" "c" 252 "" "")
(command "layer" "s" "l1" "")
(command "cylinder" p0 r l) ;创建圆柱
(command "ucs" "o" p0)
(setq e0(entlast))
(setq r0(- 0 r))
(setq t0(/ tt 2))
(setq pr(* pi r))
(setq pr0(- 0 (* pi r)))
(setq pt1(list pr r0 (+ l t0)))
(command "ucs" "o" pt1)
(command "ucs" "y" -90)
(setq p1(list 0 0))
(setq p2(list tt 0))
(setq p3(list (- 0 tt) 0 (* pi d)))
(command "layer" "s" "l3" "")
(command "line" p1 p3 "")
(setq e2(entlast))
(command "polygon" 3 "e" p1 p2) ;绘制正三边形
(setq e1(entlast))
(command "ucs" "w")
(command "extrude" e1 "" "P" e2 "") ;拉伸三棱柱
(setq e3(entlast))
(command "erase" e2 "")
(setq n 30)
(setq i 0)
(setq zl(/ tt n))
(setq zj(/ 360 n))
(setq yd 0)
(while (< yd l) ;循环切制螺纹
(setq i(+ i 1))
(setq yd(* i zl))
(setq p1(list 0 0 l))
(setq p2(list 0 0 (- l yd)))
(command "copy" e3 "" p1 p2) ;复制三棱柱(轴向移动)
(setq e4(entlast))
(command "change" e4 "" "p" "la" "l2" "")
(command "subtract" e0 "" e4 "") ;求差,切割圆柱
(command "rotate" e0 "" p0 zj) ;旋转圆柱
)
(command "erase" e3 "")
(command "cylinder" p01 r r) ;切割倒角
(setq e1(entlast))
(command "cone" p01 r r)
(setq e2(entlast))
(command "subtract" e1 "" e2 "")
(command "subtract" e0 "" e1 "")
(command "line" p0 p02 "")
)
发表于 2004-6-3 22:09:00 | 显示全部楼层
在贴一个自己的希望大家来共同完善 ;=============================
;实体螺纹的生成
; ljc 2004 . 5 . 9
;=============================
(defun C:lw(/)
(setq dr(getreal "小径的半径r1:"))
(setq r(getreal "大径的半径dr:"))
(setq t(getreal "节距"))
(setq n(getint "每圈分段数"))
(setq nn(getint "圈数"))
(setq dfjd (/ 360.0 n)) ;等分角度
(setq delt (/ (* 2.0 pi) n )) ; 等分弧度
(setq j( / t n))
(setq bb(caddr b1))
(setq ang 0 jd 0 jj 0)
(setq osmode(getvar "osmode")) (SETVAR "OSMODE" 0) (setvar "cmdecho" 1)
(chx t (- r dr) )
(chr (list r 0 0 ) 0 )
(setq m1 (entlast) pt1 (list r 0 0))
(repeat nn
(repeat n
(setq jj(+ jj 1))
(setq ang (+ delt ang) jd (+ dfjd jd) )
(setq pt2(list (* r (cos ang))(* r (sin ang))(+ 0(* j jj))))
(command "line" pt1 pt2 "") (setq m3 (entlast))
(chr pt2 jd)
(setq m2 (entlast) )
(command "_extrude" m1 "" "p" m3)
(jq (entlast) pt2 pt1)
(command "erase" m3 "")
(setq m1 m2 pt1 pt2)

)
(print)
)
(command "erase" m1 "")
(command "-purge" "b" "ljcgq" "n") (SETVAR "OSMODE" osmode)
) (defun chx( chk chg / p1 p2 p3 p4) ;chx--齿形 chk齿宽 齿高 chg
(command "ucs" "w" )
(command "ucs" "x" "90" )
(setq p1 (list 0 0 ) p2 (polar p1 (/ pi 2) (/ chk 2) ) p3 (polar p1 0 chg) p4 (polar p1 (/ pi -2) (/ chk 2) ))
(command "pline" p1 p2 p3 p4 "c" )
(command "ucs" "w" )
(command "-block" "ljcgq" (polar p1 0 (- r dr) ) (entlast) "")
) (defun chr( pr ang / ) ;chr插入 pr--插入点 ang--角度
(command "-insert" "ljcgq" pr "" "" ang )
(command "_explode" (entlast) )
) (defun jq( ss pt ptt / ) ;jq--剪切
(command "_slice" ss "" (list 0 0 0 ) (list 0 0 100 ) pt ptt )
)
发表于 2004-6-3 22:10:00 | 显示全部楼层
螺纹面: ;=============================
;立体面螺纹的生成
; ljc 2004 . 5 . 9
;=============================
(defun C:lw(/)
(setq r(getreal "小径的半径r1:"))
(setq dr(getreal "大径的半径dr:"))
(setq t(getreal "节距"))
(setq n(getint "每圈分段数"))
(setq nn(getint "圈数"))
(setq dfjd (/ 360.0 n)) ;等分角度
(setq delt (/ (* 2.0 pi) n )) ; 等分弧度
(setq j( / t n))
(setq bb(caddr b1))
(setq ang 0 jd 0 jj 0)
(setq osmode(getvar "osmode")) (SETVAR "OSMODE" 0) (setvar "cmdecho" 0)
(chx t (- dr r) )
(chr (list r 0 0 ) 0 )
(setq m1 (entlast))
(repeat nn
(repeat n
(setq jj(+ jj 1))
(setq ang (+ delt ang) jd (+ dfjd jd) )
(setq pt2(list (* r (cos ang))(* r (sin ang))(+ 0(* j jj))))
(chr pt2 jd)
(setq m2 (entlast) )
(command "_rulesurf" m1 m2)
(command "erase" m1 "")
(setq m1 m2)

)
(print)
)
(command "erase" m1 "")
(command "-purge" "b" "ljcgq" "n") (SETVAR "OSMODE" osmode)
) (defun chx( chk chg / p1 p2 p3 p4) ;chx--齿形 chk齿宽 齿高 chg
(command "ucs" "w" )
(command "ucs" "x" "90" )
(setq p1 (list 0 0 ) p2 (polar p1 (/ pi 2) (/ chk 2) ) p3 (polar p1 0 chg) p4 (polar p1 (/ pi -2) (/ chk 2) ))
(command "pline" p1 p2 p3 p4 "c" )
(command "ucs" "w" )
(command "-block" "ljcgq" p1 (entlast) "")
) (defun chr( pr ang / ) ;chr插入 pr--插入点 ang--角度
(command "-insert" "ljcgq" pr "" "" ang )
(command "_explode" (entlast) )
)
 楼主| 发表于 2004-6-8 12:04:00 | 显示全部楼层
非常感谢各位高手,这是我发现的最好的CAD网,
 楼主| 发表于 2004-6-8 16:59:00 | 显示全部楼层
能不能画一条立体螺纹线,然后画截面,然后截面沿螺旋线拉伸,得到自己想要的一立体图,然后和光杆相减,得到螺杆?


能否用样条线画螺旋线,我还没找到方法
发表于 2004-6-8 21:11:00 | 显示全部楼层
真得太厉害了
发表于 2004-6-9 07:40:00 | 显示全部楼层
提示: 作者被禁止或删除 内容自动屏蔽
您需要登录后才可以回帖 登录 | 注册

本版积分规则

小黑屋|手机版|CAD论坛|CAD教程|CAD下载|联系我们|关于明经|明经通道 ( 粤ICP备05003914号 )  
©2000-2023 明经通道 版权所有 本站代码,在未取得本站及作者授权的情况下,不得用于商业用途

GMT+8, 2024-11-26 01:40 , Processed in 0.172629 second(s), 18 queries , Gzip On.

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

快速回复 返回顶部 返回列表