CAD螺纹画法#精选.
合集下载
相关主题
- 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
- 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
- 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。
将下面一段代码复制到记事本并另存为“螺纹.lsp”文件,将该"螺纹.lsp"拷贝到你电脑的硬盘里。打开CAD,工具,加载应用程序,选"螺纹.lsp"文件,在命令行输入metric回车,便可以生成螺纹,再另外可以和你的圆柱或者孔进交集或并集,便生成了内螺纹或者外螺纹
;-------------------------------------------------------------------
(setq h6 (list -0.003 -0.004 -0.0045 -0.0055 -0.0065 -0.008 -0.0095 -0.011 -0.0125 -0.0145 -0.016 -0.018 -0.020))
(setq g6 (list -0.005 -0.008 -0.0095 -0.0115 -0.0135 -0.017 -0.0195 -0.023 -0.0265 -0.0295 -0.033 -0.036 -0.0515))
)))))))))))))
(if (= inout "I")
(if (< pitch 0.25) (setq nom1 (+ nom1 (nth n 4H))) ; tolerance field to use depending on pitch
(if (< pitch 0.35) (setq nom1 (+ nom1 (nth n 5H)))
; drawn a little longer and then sliced off to the correct length.
; This program only draws the thread, you're on your own d百度文库awing
; the rest of the screw or internal thread.
(setvar "cmdecho" ocmd)
(setvar "osmode" osm)
(setq *error* olderr)
(princ)
)
(defun c:ISO228 (/ nom pitch length threadangle cpt inout minordiafactor nom1 nom2 size n s olderr)
(initget 3) ; no enter, not zero, not negative
(setq length (getdist "\n螺纹长度: "))
; add tolerance to nominal diameter
(if (<= nom1 3) (setq n 0) ; position in tolerance field depending on nominal diameter
(setq osm (getvar "osmode"))
(setq ocmd (getvar "cmdecho"))
(setq minordiafactor 1.5)
(initget 1 "I E")
(setq inout (getkword "\n内螺纹或外螺纹(I/E): "))
(initget 7) ; no enter, not zero, not negative
(if (<= nom1 6) (setq n 1)
(if (<= nom1 10) (setq n 2)
(if (<= nom1 18) (setq n 3)
(if (<= nom1 30) (setq n 4)
(if (<= nom1 50) (setq n 5)
(if (<= nom1 80) (setq n 6)
))
)
(setq h (* 0.866025 pitch)) ; h=0.866025
(setq nom (+ nom1 (/ h 4))) ; h/8
(setq nom2 (- nom (* h minordiafactor))) ; inside diameter
(setq threadangle (+ 27.5 0)) ; threadangle
(setvar "osmode" 0)
(setvar "cmdecho" 0)
(drawthread nom nom1 nom2 pitch length threadangle cpt)
(princ "\nDone")
(setq size (getkword "\nNominal size, 1/16' to 6' (for example: 1/8 or 1-1/4): "))
(setq size "1") ; demo version only 1
(if (= size "1") (if (= inout "E") (setq nom1 33.069 n 11) (setq nom1 33.568 n 11)))
(initget 1 "I E")
(setq inout (getkword "\n内螺纹al or External thread (I/E): "))
(initget "1/16 1/8 1/4 3/8 1/2 5/8 3/4 7/8 1 1-1/8 1-1/4 1-1/2 1-3/4 2 2-1/4 2-1/2 2-3/4 3 3-1/2 4 4-1/2 5 5-1/2 6")
(if (>= pitch 0.35) (setq nom1 (+ nom1 (nth n 6H)))
)))
)
(if (= inout "E")
(if (< pitch 0.35) (setq nom1 (+ nom1 (nth n h6)))
(if (>= pitch 0.35) (setq nom1 (+ nom1 (nth n g6)))
(setq nom1 (getdist "\n螺纹外径: "))
(initget 7) ; no enter, not zero, not negative
(setq pitch (getreal "\n螺距: "))
(initget 1) ; no enter
(setq cpt (getpoint "起始圆心坐标: "))
(if (<= nom1 120) (setq n 7)
(if (<= nom1 180) (setq n 8)
(if (<= nom1 250) (setq n 9)
(if (<= nom1 315) (setq n 10)
(if (<= nom1 400) (setq n 11)
(if (<= nom1 500) (setq n 12)
;;;;(setq olderr *error*
;;;; *error* myerror)
(setq osm (getvar "osmode"))
(setq ocmd (getvar "cmdecho"))
(setq minordiafactor 1.6666666667)
(Princ "\nThread according to DIN ISO 228, NEN 176")
;
; There is no error trapping or anything like that.
;
; The program works by creating a single thread
; and then arraying it out to the proper length. The threads are
(setq h (* 0.96049 pitch)) ; h according to ISO 228
(setq nom (+ nom1 (/ h 3))) ; biggest outside diameter
(setq nom2 (- nom (* h minordiafactor))) ; inside diameter
; All running osnaps are turned off as well.
;-------------------------------------------------------------------
(setq 4H (list 0.0015 0.002 0.002 0.0025 0.003 0.0035 0.004 0.005 0.006 0.007 0.008 0.009 0.010))
; - Gas thread straight inside thread only, ISO 7-1 (equal to DIN 2999 and NEN 3258)
; - Metric inside and outside thread, NEN 81 and NEN 1870, geometrically 100% correct
(setq 5H (list 0.002 0.0025 0.003 0.004 0.0045 0.0055 0.0065 0.0075 0.009 0.010 0.0115 0.0125 0.0135))
(setq 6H (list 0.003 0.004 0.0045 0.0055 0.0065 0.008 0.0095 0.011 0.0125 0.0145 0.016 0.018 0.020))
; THREAD.LSP Creates 3D solid (ACIS) threads. 01/9/1999
;
; Corrected
;
; written by: Robbert Teggelove
;
;-------------------------------------------------------------------
;
; Note, the threads created by this can make for some rather big files,
; so make sure your system is up to it. Also, it might take a while
; to union all of the single threads together so be patient.
(setvar "osmode" osm)
(setvar "cmdecho" ocmd)
(setq *error* olderr)
(princ)
)
; Next routine makes metric thread according to NEN 1870
(defun c:Metric (/ nom pitch length threadangle cpt inout minordiafactor nom1 nom2 ocmd osm 4H 5H 6H h6 g6 tol)
;
;-------------------------------------------------------------------
(defun myerror (s)
(if (/= s "function cancelled") (princ (strcat "\nError: " s)))
;
; This is a way to make 3D solid external threads in
; AutoCAD R13 and R14.
; You can make threads according to:
; - ISO 228 (equal to DIN 228 and NEN 176)
(setq pitch (/ 25.4 n))
(initget 1) ; no enter
(setq cpt (getpoint "Start center point: "))
(initget 3) ; no enter, not zero
(setq length (getdist "\nTotal thread length in Y direction: "))
;-------------------------------------------------------------------
; Gets the nominal size, tpi, and total length
; then calculates a bunch of geometry points.
;-------------------------------------------------------------------
(setq h6 (list -0.003 -0.004 -0.0045 -0.0055 -0.0065 -0.008 -0.0095 -0.011 -0.0125 -0.0145 -0.016 -0.018 -0.020))
(setq g6 (list -0.005 -0.008 -0.0095 -0.0115 -0.0135 -0.017 -0.0195 -0.023 -0.0265 -0.0295 -0.033 -0.036 -0.0515))
)))))))))))))
(if (= inout "I")
(if (< pitch 0.25) (setq nom1 (+ nom1 (nth n 4H))) ; tolerance field to use depending on pitch
(if (< pitch 0.35) (setq nom1 (+ nom1 (nth n 5H)))
; drawn a little longer and then sliced off to the correct length.
; This program only draws the thread, you're on your own d百度文库awing
; the rest of the screw or internal thread.
(setvar "cmdecho" ocmd)
(setvar "osmode" osm)
(setq *error* olderr)
(princ)
)
(defun c:ISO228 (/ nom pitch length threadangle cpt inout minordiafactor nom1 nom2 size n s olderr)
(initget 3) ; no enter, not zero, not negative
(setq length (getdist "\n螺纹长度: "))
; add tolerance to nominal diameter
(if (<= nom1 3) (setq n 0) ; position in tolerance field depending on nominal diameter
(setq osm (getvar "osmode"))
(setq ocmd (getvar "cmdecho"))
(setq minordiafactor 1.5)
(initget 1 "I E")
(setq inout (getkword "\n内螺纹或外螺纹(I/E): "))
(initget 7) ; no enter, not zero, not negative
(if (<= nom1 6) (setq n 1)
(if (<= nom1 10) (setq n 2)
(if (<= nom1 18) (setq n 3)
(if (<= nom1 30) (setq n 4)
(if (<= nom1 50) (setq n 5)
(if (<= nom1 80) (setq n 6)
))
)
(setq h (* 0.866025 pitch)) ; h=0.866025
(setq nom (+ nom1 (/ h 4))) ; h/8
(setq nom2 (- nom (* h minordiafactor))) ; inside diameter
(setq threadangle (+ 27.5 0)) ; threadangle
(setvar "osmode" 0)
(setvar "cmdecho" 0)
(drawthread nom nom1 nom2 pitch length threadangle cpt)
(princ "\nDone")
(setq size (getkword "\nNominal size, 1/16' to 6' (for example: 1/8 or 1-1/4): "))
(setq size "1") ; demo version only 1
(if (= size "1") (if (= inout "E") (setq nom1 33.069 n 11) (setq nom1 33.568 n 11)))
(initget 1 "I E")
(setq inout (getkword "\n内螺纹al or External thread (I/E): "))
(initget "1/16 1/8 1/4 3/8 1/2 5/8 3/4 7/8 1 1-1/8 1-1/4 1-1/2 1-3/4 2 2-1/4 2-1/2 2-3/4 3 3-1/2 4 4-1/2 5 5-1/2 6")
(if (>= pitch 0.35) (setq nom1 (+ nom1 (nth n 6H)))
)))
)
(if (= inout "E")
(if (< pitch 0.35) (setq nom1 (+ nom1 (nth n h6)))
(if (>= pitch 0.35) (setq nom1 (+ nom1 (nth n g6)))
(setq nom1 (getdist "\n螺纹外径: "))
(initget 7) ; no enter, not zero, not negative
(setq pitch (getreal "\n螺距: "))
(initget 1) ; no enter
(setq cpt (getpoint "起始圆心坐标: "))
(if (<= nom1 120) (setq n 7)
(if (<= nom1 180) (setq n 8)
(if (<= nom1 250) (setq n 9)
(if (<= nom1 315) (setq n 10)
(if (<= nom1 400) (setq n 11)
(if (<= nom1 500) (setq n 12)
;;;;(setq olderr *error*
;;;; *error* myerror)
(setq osm (getvar "osmode"))
(setq ocmd (getvar "cmdecho"))
(setq minordiafactor 1.6666666667)
(Princ "\nThread according to DIN ISO 228, NEN 176")
;
; There is no error trapping or anything like that.
;
; The program works by creating a single thread
; and then arraying it out to the proper length. The threads are
(setq h (* 0.96049 pitch)) ; h according to ISO 228
(setq nom (+ nom1 (/ h 3))) ; biggest outside diameter
(setq nom2 (- nom (* h minordiafactor))) ; inside diameter
; All running osnaps are turned off as well.
;-------------------------------------------------------------------
(setq 4H (list 0.0015 0.002 0.002 0.0025 0.003 0.0035 0.004 0.005 0.006 0.007 0.008 0.009 0.010))
; - Gas thread straight inside thread only, ISO 7-1 (equal to DIN 2999 and NEN 3258)
; - Metric inside and outside thread, NEN 81 and NEN 1870, geometrically 100% correct
(setq 5H (list 0.002 0.0025 0.003 0.004 0.0045 0.0055 0.0065 0.0075 0.009 0.010 0.0115 0.0125 0.0135))
(setq 6H (list 0.003 0.004 0.0045 0.0055 0.0065 0.008 0.0095 0.011 0.0125 0.0145 0.016 0.018 0.020))
; THREAD.LSP Creates 3D solid (ACIS) threads. 01/9/1999
;
; Corrected
;
; written by: Robbert Teggelove
;
;-------------------------------------------------------------------
;
; Note, the threads created by this can make for some rather big files,
; so make sure your system is up to it. Also, it might take a while
; to union all of the single threads together so be patient.
(setvar "osmode" osm)
(setvar "cmdecho" ocmd)
(setq *error* olderr)
(princ)
)
; Next routine makes metric thread according to NEN 1870
(defun c:Metric (/ nom pitch length threadangle cpt inout minordiafactor nom1 nom2 ocmd osm 4H 5H 6H h6 g6 tol)
;
;-------------------------------------------------------------------
(defun myerror (s)
(if (/= s "function cancelled") (princ (strcat "\nError: " s)))
;
; This is a way to make 3D solid external threads in
; AutoCAD R13 and R14.
; You can make threads according to:
; - ISO 228 (equal to DIN 228 and NEN 176)
(setq pitch (/ 25.4 n))
(initget 1) ; no enter
(setq cpt (getpoint "Start center point: "))
(initget 3) ; no enter, not zero
(setq length (getdist "\nTotal thread length in Y direction: "))
;-------------------------------------------------------------------
; Gets the nominal size, tpi, and total length
; then calculates a bunch of geometry points.