原版程序,来自于版主ZZXXQQ;感谢版主大人!
这个程序目前的功能,批量选择圆孔后,可以添加螺纹线;
存在的问题:生成螺纹线的同时,会改掉原始底孔的大小;
希望更改:生成螺纹线的同时,保持原有底孔大小不变;螺纹线实际外径大小无所谓,无需按标注牙孔匹配生成,取值固定为原始底孔大小的1.2倍也行;
- ;圆变螺孔 明经 ZZXXQQ 2010.9.8
- (defun c:lk ()
- (defun mkline (p1 p2 ln)
- (entmake (list '(0 . "LINE") (cons 8 ln) (cons 10 p1) (cons 11 p2)))
- )
- (setvar "CMDECHO" 0)
- (if (and (princ "\n选择要加螺纹的圆 :")
- (setq ss (ssget '((0 . "CIRCLE"))))) (progn
- (setq i 0)
- (repeat (sslength ss)
- (setq en (ssname ss i)
- ent (entget en)
- i (1+ i)
- pc (cdr(assoc 10 ent))
- r (cdr(assoc 40 ent))
- ri (* r 0.9)
- ro (* r 1.1)
- pc1 (polar pc 0 ro)
- pc2 (polar pc pi ro)
- pc3 (polar pc (/ pi 2) ro)
- pc4 (polar pc (/ pi -2) ro)
- an1 (/ pi 3)
- an2 (/ pi -6))
- (if (not (tblsearch "LAYER" "center"))
- (command ".LAYER" "N" "center" "C" 1 "center" "L" "CENTER" "CEN" "")
- )
- (mkline pc1 pc2 "center")
- (mkline pc3 pc4 "center")
- (entmake (list '(0 . "CIRCLE") (assoc 8 ent) (cons 10 pc) (cons 40 ri)))
- (entmake
- (list '(0 . "ARC") (cons 10 pc) (cons 40 r) (cons 50 an1) (cons 51 an2) '(62 . 1))
- )
- (entdel en)
- )
- ))
- (setvar "CMDECHO" 1)
- (princ)
|