(defun C:AC(/ en P1 P2 P3 P4 P5)
(COMMAND "UCS" "W")
(setvar "cmdecho" 0)
(setvar "cecolor" "1");改变当前颜色
(setvar "ORTHOMODE" 0);关闭正交
(if (null L)(setq L 2.0))
(if (null W)(setq W 2.0))
(if (null R)(setq R 0.5))
(while ;循环执行
(setq L11 L W11 W R11 R)
(setq T 0)
(while (/= T nil) ;循环设置参数
(princ "\n---绘制穿丝孔---")
(princ (strcat "\n当前设置[ 引线: " (rtos L 2 4) " MM "))
(princ (strcat "偏距: " (rtos W 2 4) " MM "))
(princ (strcat "半径: " (rtos R 2 4) " MM ] "))
(initget "LL WW RR")
(setq en(entsel "\n选择线段或[引线(LL) /偏距(WW) /半径(RR)]"))
(cond
((= en "LL");L
(progn
(setq L(getreal (strcat "\n引线:<" (rtos L 2 4) ">")))
(if (= nil L)(setq L L11))
)
)
((= en "WW");W
(progn
(setq W(getreal (strcat "\n偏距:<" (rtos W 2 4) ">")))
(if (= nil W)(setq W W11))
)
)
((= en "RR");R
(progn
(setq R(getreal (strcat "\n半径:<" (rtos R 2 4) ">")))
(if (= nil R)(setq R R11))
)
)
((/= en "LL")(/= en "WW")(/= en "RR")
(setq T nil)
)
);结束cond
);结束循环设置参数
(if (= en nil)(exit))
(setq e (car en))
(setq enn (entget (car en)))
(setq ol(cdr (assoc 0 enn)))
(if (= ol "LWPOLYLINE")
(progn
(setq n(fix (vlax-curve-getparamatpoint e
(vlax-curve-getclosestpointto e (cadr en)))));点选在多段线上的第几段
(setq n1(vlax-curve-getclosestpointto e (cadr en)));点选的点在多段线上的位置
(setq P1(vlax-curve-getpointatparam e n));第一个端点坐标
(setq P2(vlax-curve-getpointatparam e (1+ n)));第二个端点坐标
))
(command "UCS" "W")
(setvar "cmdecho" 0)
(setq os6 (getvar "cecolor")) ;保存当前图层的颜色值
(setvar "cecolor" "1");改变当前颜色
(setq oldort (getvar "orthomode"))
(setvar "ORTHOMODE" 0);关闭正交
(if (null L)(setq L 2.0))
(if (null W)(setq W 2.0))
(if (null R)(setq R 0.5))
(while ;循环执行
(setq L11 L W11 W R11 R)
(setq T 0)
(while (/= T nil) ;循环设置参数
(princ "\n---绘制穿丝孔---")
(princ (strcat "\n当前设置[ 引线: " (rtos L 2 4) " MM "))
(princ (strcat "偏距: " (rtos W 2 4) " MM "))
(princ (strcat "半径: " (rtos R 2 4) " MM ] "))
(initget "LL WW RR")
(setq en(entsel "\n选择线段或[引线(LL) /偏距(WW) /半径(RR)]"))
(cond
((= en "LL");L
(progn
(setq L(getreal (strcat "\n引线:<" (rtos L 2 4) ">")))
(if (= nil L)(setq L L11))
)
)
((= en "WW");W
(progn
(setq W(getreal (strcat "\n偏距:<" (rtos W 2 4) ">")))
(if (= nil W)(setq W W11))
)
)
((= en "RR");R
(progn
(setq R(getreal (strcat "\n半径:<" (rtos R 2 4) ">")))
(if (= nil R)(setq R R11))
)
)
((/= en "LL")(/= en "WW")(/= en "RR")
(setq T nil)
)
);结束cond
);结束循环设置参数
(if (= en nil)(exit))
(setq e (car en))
(setq enn (entget (car en)))
(setq ol(cdr (assoc 0 enn)))
(if (= ol "LWPOLYLINE")
(progn
(setq n(fix (vlax-curve-getparamatpoint e
(vlax-curve-getclosestpointto e (cadr en)))));点选在多段线上的第几段
(setq n1(vlax-curve-getclosestpointto e (cadr en)));点选的点在多段线上的位置
(setq P1(vlax-curve-getpointatparam e n));第一个端点坐标
(setq P2(vlax-curve-getpointatparam e (1+ n)));第二个端点坐标
))