CAD_LISP

Autocad_Lisp洗長孔、3D長孔

這巨集很好用,在加工件繪製時,這個長條孔,在活動式加工件時最廣泛用到的。

因為繪製麻煩 (畫兩個圓?一個方? 然後交集?

先前有在網路上搜尋到,現在網路資源也消失了,在此更新並改良。

其功用為: 立體長條孔

輸入直徑、長度、方向角度、擠出高度 = 3D立體長條孔

其code如下

熱鍵可自定義,預設為clh

(setq g 0)
(defun c:clh(/ p1 p2 p3 p4 p5 p6 p7 p8 s pc v w1 L1 g1 OS)
       (setq OS(getvar "OSMODE"))
       (setvar "cmdecho" 0)
       (setq v (getvar "clayer"))
       (setq w1 w)(setq L1 L)(setq g1 g)
       (setvar "OSMODE" 1207)
       (setq pc(getpoint "長圓孔的中心點:"))(terpri)
 (prompt "長圓孔總寬度(圓的直徑)<")(princ w)(prompt ">:")(setq w (getdist pc))(terpri)
 (if (= w nil) (setq w w1))
 (prompt "長圓孔總長度(<")(princ L)(prompt ">:")(setq L (getdist pc))(terpri)
 (if (= L nil) (setq L L1))
 (prompt "角度(0,0=橫向,0,270=直向<")(princ (/ (* g 180.0) pi))(prompt ">:")(setq g (getangle pc))(terpri)
 (if (= g nil) (setq g g1))
 (setq s (* (getvar "dimlfac") 1.5))
 (setq p1(polar pc (+ g (/ pi 2)) (+ (/ w 2) s)))
 (setq p2(polar pc (- g (/ pi 2)) (+ (/ w 2) s)))
 (setq p3(polar pc g (+ (/ L 2) s)))
 (setq p4(polar pc (+ g pi) (+ (/ L 2) s)))
 (setq p5(polar pc (+ (atan (/ w 2) (/ (- L w) 2)) g)
                   (expt (+ (expt (/ (- L w) 2) 2) (expt (/ w 2) 2)) 0.5)))
 (setq p6(polar p5 (+ g pi) (- L w)))
 (setq p7(polar p6 (- g (/ pi 2)) w))
 (setq p8(polar p5 (- g (/ pi 2)) w))
 (setvar "OSMODE" 0)
(setvar "CLAYER" "0")
 (command "arc" p6 "E" p7 "R" (/ w 2))
 (command "arc" p8 "E" p5 "R" (/ w 2))
(command "line" p5 p6 "")
 (command "_.pedit" "_M" p5 p6 p7 p8  "" "Y" "_join" "" "")
  (command "line" p7 p8 "")
  (command "_.pedit" "_M"  p8 p5   "" "Y" "_join" "" "")
  (command "_extrude" "_M" p8 "" "" )
  (setvar "CLAYER" V)
 (setvar "OSMODE" OS)
 (princ)
)

發佈留言

發佈留言必須填寫的電子郵件地址不會公開。 必填欄位標示為 *