求助大神
求助大神帮忙更改下轴网和轴号线性、字体跟随CAD设定好的图层和字体来变换后续几个收集的源码一起分享
; =============================================
; | 轴线自动生成软件 |
; | 板本: V1.0 作者: 尉迟俊岭 |
; =============================================
(defun C:ax(/ lay len_x num_x test propt dis_x kj_x len_y num_y dis_y kj_y
pt dis pt1 pt2 pt3 pt4 pt5 pt6 pt11 pt22 pth1 pth2 ptt ptz1
ptz2 dx dxx dy dyy i txt dxt dyt)
(setvar "CMDECHO" 0)
(setq lay (getvar "clayer"))
(command "color" "bylayer")
(command "layer" "m" "dimax" "c" "g" "dimax" "lt" "continuous" "" "")
(command "layer" "m" "axis" "c" "red" "axis" "lt" "dhx100" "" "")
(command "STYLE" "complex" "complex" "0" "1" "0" "n" "n" "n")
(command "STYLE" "xw" "txt" "0" ".8" "0" "n" "n" "n")
(setq len_x 0 num_x 1 test T)
(while test
(setq propt (strcat "请输入第" (itoa num_x) "开间尺寸<ENTER结束>: "))
(initget 6)
(setq dis_x (getreal propt))
(if (= dis_x nil)
(setq test nil)
(progn
(setq len_x (+ len_x dis_x))
(if (= 1 num_x) (setq kj_x (list dis_x))
(progn
(setq kj_x (append kj_x (list dis_x)))
)
)
(setq num_x (1+ num_x))
)
)
)
(setq len_y 0 num_y 1 test T)
(while test
(setq propt (strcat "请输入第" (itoa num_y) "进深尺寸<ENTER结束>: "))
(initget 6)
(setq dis_y (getreal propt))
(if (= dis_y nil)
(setq test nil)
(progn
(setq len_y (+ len_y dis_y))
(if (= 1 num_y) (setq kj_y (list dis_y))
(progn
(setq kj_y (append kj_y (list dis_y)))
)
)
(setq num_y (1+ num_y))
)
)
)
(setq pt (getpoint "\n请输入轴线左下角点<10000,10000>: "))
(if (= pt nil) (setq pt '(10000 10000)))
(setq dis (getreal "\n请输入轴线至尺寸线的距离<4500>: "))
(if (= dis nil) (setq dis 5700) (setq dis (+ dis 1200)))
(setq pt1 pt)
(setq dy (cadr pt1))
(setq dx (car pt1))
(setq dx (- dx dis))
(setq dxx (+ dx len_x dis dis))
(setq pt1 (list dxdy))
(setq pt2 (list dxx dy))
(setq pt11 (list (+ dx1200) dy))
(setq pt22 (list (- dxx 1200) dy))
(setq ptz1 (list (+ dx500) dy))
(setq ptz2 (list (- dxx 500) dy))
(command "line" pt1 pt2 "")
(command "layer" "s" "dimax" "")
(command "circle" (list (- dx400) dy) 400)
(command "circle" (list (+ dxx 400) dy) 400)
(setq pth1 (polar pt1 3.463 632.5))
(setq pth2 (polar pt2 5.500 282.8))
(command "text" "s" "complex" ^c)
(command "text" "j" "f" pth1 (polar pth1 0 400) 400 "A")
(command "text" "j" "f" pth2 (polar pth2 0 400) 400 "A")
(command "text" "s" "xw" ^c)
(command "layer" "s" "axis" "")
(setq i 0)
(repeat (- num_y 1)
(setq dy (+ dy (nth i kj_y)))
(setq pt1 (list dx dy))
(setq pt2 (list dxx dy))
(setq pt3 (list (+ dx1200) dy))
(setq pt4 (list (- dxx 1200) dy))
(command "line" pt1 pt2 "")
(command "layer" "s" "dimax" "")
(command "circle" (list (- dx400) dy) 400)
(command "circle" (list (+ dxx 400) dy) 400)
(setq pth1 (polar pt1 3.463 632.5))
(setq pth2 (polar pt2 5.500 282.8))
(command "text" "s" "complex" ^c)
(cond ((= 0 i) (setq txt "B"))
((= 1 i) (setq txt "C"))
((= 2 i) (setq txt "D"))
((= 3 i) (setq txt "E"))
((= 4 i) (setq txt "F"))
((= 5 i) (setq txt "G"))
((= 6 i) (setq txt "H"))
((= 7 i) (setq txt "J"))
((= 8 i) (setq txt "K"))
((= 9 i) (setq txt "L"))
((= 10 i) (setq txt "M"))
((= 11 i) (setq txt "N"))
((= 12 i) (setq txt "P"))
((= 13 i) (setq txt "Q"))
((= 14 i) (setq txt "R"))
((= 15 i) (setq txt "S"))
((= 16 i) (setq txt "T"))
((= 17 i) (setq txt "U"))
((= 18 i) (setq txt "V"))
((= 19 i) (setq txt "W"))
((= 20 i) (setq txt "X"))
((= 21 i) (setq txt "Y"))
((= 22 i) (setq txt "Z"))
)
(command "text" "j" "f" pth1 (polar pth1 0 400) 400 txt)
(command "text" "j" "f" pth2 (polar pth2 0 400) 400 txt)
(command "text" "s" "xw" ^c)
(command "line" pt11 pt3 "")
(if (= 0 i)
(progn
(setq pt5 (polar pt11 (* pi 1.75) 70.7))
(setq pt6 (polar pt5 (* pi 0.75) 141.4))
(command "pline" pt5 "w" 50 50 pt6 "")
)
)
(setq pt5 (polar pt3 (* pi 1.75) 70.7))
(setq pt6 (polar pt5 (* pi 0.75) 141.4))
(command "pline" pt5 "w" 50 50 pt6 "")
(setq dyt (cadr pt11))
(setq dxt (car pt11))
(setq ptt (list (- dxt 115) (+ dyt (/ (nth i kj_y) 2))))
(command "text" "c" ptt 300 90 (rtos (nth i kj_y) 2 0))
(setq pt11 pt3)
(command "line" pt22 pt4 "")
(if (= 0 i)
(progn
(setq pt5 (polar pt22 (* pi 1.75) 70.7))
(setq pt6 (polar pt5 (* pi 0.75) 141.4))
(command "pline" pt5 "w" 50 50 pt6 "")
)
)
(setq pt5 (polar pt4 (* pi 1.75) 70.7))
(setq pt6 (polar pt5 (* pi 0.75) 141.4))
(command "pline" pt5 "w" 50 50 pt6 "")
(setq dyt (cadr pt22))
(setq dxt (car pt22))
(setq ptt (list (- dxt 115) (+ dyt (/ (nth i kj_y) 2))))
(command "text" "c" ptt 300 90 (rtos (nth i kj_y) 2 0))
(setq pt22 pt4)
(command "layer" "s" "axis" "")
(setq i (+ i 1))
)
(command "layer" "s" "dimax" "")
(command "line" ptz1 (polar ptz1 (* pi 0.5) len_y) "")
(setq pt5 (polar ptz1 (* pi 1.75) 70.7))
(setq pt6 (polar pt5 (* pi 0.75) 141.4))
(command "pline" pt5 "w" 50 50 pt6 "")
(setq ptz1 (polar ptz1 (* pi 0.5) len_y))
(setq pt5 (polar ptz1 (* pi 1.75) 70.7))
(setq pt6 (polar pt5 (* pi 0.75) 141.4))
(command "pline" pt5 "w" 50 50 pt6 "")
(setq dyt (cadr ptz1))
(setq dxt (car ptz1))
(setq ptt (list (- dxt 115) (- dyt (/ len_y 2))))
(command "text" "c" ptt 300 90 (rtos len_y 2 0))
(command "line" ptz2 (polar ptz2 (* pi 0.5) len_y) "")
(setq pt5 (polar ptz2 (* pi 1.75) 70.7))
(setq pt6 (polar pt5 (* pi 0.75) 141.4))
(command "pline" pt5 "w" 50 50 pt6 "")
(setq ptz2 (polar ptz2 (* pi 0.5) len_y))
(setq pt5 (polar ptz2 (* pi 1.75) 70.7))
(setq pt6 (polar pt5 (* pi 0.75) 141.4))
(command "pline" pt5 "w" 50 50 pt6 "")
(setq dyt (cadr ptz2))
(setq dxt (car ptz2))
(setq ptt (list (- dxt 115) (- dyt (/ len_y 2))))
(command "text" "c" ptt 300 90 (rtos len_y 2 0))
(command "layer" "s" "axis" "")
(setq pt1 pt) ;Y向轴线
(setq dy (cadr pt1))
(setq dx (car pt1))
(setq dy (- dy dis))
(setq dyy (+ dy len_y dis dis))
(setq pt1 (list dx dy))
(setq pt2 (list dx dyy))
(setq pt11 (list dx (+ dy1200)))
(setq pt22 (list dx (- dyy 1200)))
(setq ptz1 (list dx (+ dy500)))
(setq ptz2 (list dx (- dyy 500)))
(command "line" pt1 pt2 "")
(command "layer" "s" "dimax" "")
(command "circle" (list dx (- dy400)) 400)
(command "circle" (list dx (+ dyy 400)) 400)
(setq pth1 (polar pt1 4.391 632.5))
(setq pth2 (polar pt2 2.356 282.8))
(command "text" "s" "complex" ^c)
(command "text" "j" "f" pth1 (polar pth1 0 400) 400 "1")
(command "text" "j" "f" pth2 (polar pth2 0 400) 400 "1")
(command "text" "s" "xw" ^c)
(command "layer" "s" "axis" "")
(setq i 0)
(repeat (- num_x 1)
(setq dx (+ dx (nth i kj_x)))
(setq pt1 (list dx dy))
(setq pt2 (list dx dyy))
(setq pt3 (list dx (+ dy1200)))
(setq pt4 (list dx (- dyy 1200)))
(command "line" pt1 pt2 "")
(command "layer" "s" "dimax" "")
(command "circle" (list dx (- dy400)) 400)
(command "circle" (list dx (+ dyy 400)) 400)
(setq pth1 (polar pt1 4.391 632.5))
(setq pth2 (polar pt2 2.356 282.8))
(command "text" "s" "complex" ^c)
(command "text" "j" "f" pth1 (polar pth1 0 400) 400 (rtos (+ i 2) 2 0))
(command "text" "j" "f" pth2 (polar pth2 0 400) 400 (rtos (+ i 2) 2 0))
(command "text" "s" "xw" ^c)
(command "line" pt11 pt3 "")
(if (= 0 i)
(progn
(setq pt5 (polar pt11 (* pi 1.25)70.7))
(setq pt6 (polar pt5(* pi 0.25) 141.4))
(command "pline" pt5 "w" 50 50 pt6 "")
)
)
(setq pt5 (polar pt3 (* pi 1.25) 70.7))
(setq pt6 (polar pt5 (* pi 0.25) 141.4))
(command "pline" pt5 "w" 50 50 pt6 "")
(setq dyt (cadr pt11))
(setq dxt (car pt11))
(setq ptt (list(+ dxt (/ (nth i kj_x) 2)) (+ dyt 115)))
(command "text" "c" ptt 300 0 (rtos (nth i kj_x) 2 0))
(setq pt11 pt3)
(command "line" pt22 pt4 "")
(if (= 0 i)
(progn
(setq pt5 (polar pt22 (* pi 1.25) 70.7))
(setq pt6 (polar pt5 (* pi 0.25) 141.4))
(command "pline" pt5 "w" 50 50 pt6 "")
)
)
(setq pt5 (polar pt4 (* pi 1.25) 70.7))
(setq pt6 (polar pt5 (* pi 0.25) 141.4))
(command "pline" pt5 "w" 50 50 pt6 "")
(setq dyt (cadr pt22))
(setq dxt (car pt22))
(setq ptt (list (+ dxt (/ (nth i kj_x) 2)) (+ dyt 115)))
(command "text" "c" ptt 300 0 (rtos (nth i kj_x) 2 0))
(setq pt22 pt4)
(command "layer" "s" "axis" "")
(setq i (+ i 1))
)
(command "layer" "s" "dimax" "") ;标注总尺寸
(command "line" ptz1 (polar ptz1 0 len_x) "")
(setq pt5 (polar ptz1 (* pi 1.25) 70.7))
(setq pt6 (polar pt5 (* pi 0.25) 141.4))
(command "pline" pt5 "w" 50 50 pt6 "")
(setq ptz1 (polar ptz1 0 len_x))
(setq pt5 (polar ptz1 (* pi 1.25) 70.7))
(setq pt6 (polar pt5 (* pi 0.25) 141.4))
(command "pline" pt5 "w" 50 50 pt6 "")
(setq dyt (cadr ptz1))
(setq dxt (car ptz1))
(setq ptt (list (- dxt (/ len_x 2)) (+ dyt 115)))
(command "text" "c" ptt 300 0 (rtos len_x 2 0))
(command "line" ptz2 (polar ptz2 0 len_x) "")
(setq pt5 (polar ptz2 (* pi 1.25) 70.7))
(setq pt6 (polar pt5 (* pi 0.25) 141.4))
(command "pline" pt5 "w" 50 50 pt6 "")
(setq ptz2 (polar ptz2 0 len_x))
(setq pt5 (polar ptz2 (* pi 1.25) 70.7))
(setq pt6 (polar pt5 (* pi 0.25) 141.4))
(command "pline" pt5 "w" 50 50 pt6 "")
(setq dyt (cadr ptz2))
(setq dxt (car ptz2))
(setq ptt (list (- dxt (/ len_x 2)) (+ dyt 115)))
(command "text" "c" ptt 300 0 (rtos len_x 2 0))
(command "layer" "s" lay "")
(command "zoom" "e")
(princ "\n应使用<<改轴线线型>>将轴线线型由点划线改为连续,出图前")
(princ "\n再使用此功能改回.否则在以后的操作中可能捕捉不到轴线交点!")
(princ)
)
页:
[1]