求一个lisp小程序CAD2次开发
1,按下命令快捷键XXX2,执行命令rectang3,自己给P1和P2,2个点,鼠标点4,OFFSET向内偏移20mm5,连接4个角6,最好转成块放到给的点处。就这些,不...
1,按下命令快捷键XXX
2,执行命令rectang
3,自己给P1和P2,2个点,鼠标点
4,OFFSET向内偏移20mm
5,连接4个角
6,最好转成块放到给的点处。
就这些,不胜感激,。 展开
2,执行命令rectang
3,自己给P1和P2,2个点,鼠标点
4,OFFSET向内偏移20mm
5,连接4个角
6,最好转成块放到给的点处。
就这些,不胜感激,。 展开
1个回答
展开全部
(defun c:sjx()
(vl-load-com)
(setq cm (getvar "cmdecho")) (setvar "cmdecho" 0)
(setq os (getvar "osmode")) (setvar "osmode" 0)
(command "_undo" "be")
(if (setq p1 (getpoint "\np1:"))
(if (setq p2 (getcorner p1 "\np2:"))
(progn
(setq pm (mapcar '* '(0.5 0.5) (mapcar '+ p1 p2)))
(command "_rectang" p1 p2)
(setq ent1 (entlast))
(setq pts1 (mapcar 'cdr (vl-remove-if-not '(lambda(x)(= (car x) 10)) (entget ent1))))
(if (or (< (distance (car pts1) (cadr pts1)) 20.0)
(< (distance (car pts1) (last pts1)) 20.0)
)
(princ "所画矩形无法偏移向内偏移20mm")
(progn
(command "_offset" 20 ent1 pm "")
(setq ent2 (entlast))
(setq pts2 (mapcar 'cdr (vl-remove-if-not '(lambda(x)(= (car x) 10)) (entget ent2))))
(setq i 0)
(repeat 4
(command "_line" (nth i pts1) (nth i pts2) "")
(setq i (1+ i))
)
)
)
)
)
)
(command "_undo" "e")
(setvar "osmode" 0) (setvar "cmdecho" 0)
(princ)
)
(vl-load-com)
(setq cm (getvar "cmdecho")) (setvar "cmdecho" 0)
(setq os (getvar "osmode")) (setvar "osmode" 0)
(command "_undo" "be")
(if (setq p1 (getpoint "\np1:"))
(if (setq p2 (getcorner p1 "\np2:"))
(progn
(setq pm (mapcar '* '(0.5 0.5) (mapcar '+ p1 p2)))
(command "_rectang" p1 p2)
(setq ent1 (entlast))
(setq pts1 (mapcar 'cdr (vl-remove-if-not '(lambda(x)(= (car x) 10)) (entget ent1))))
(if (or (< (distance (car pts1) (cadr pts1)) 20.0)
(< (distance (car pts1) (last pts1)) 20.0)
)
(princ "所画矩形无法偏移向内偏移20mm")
(progn
(command "_offset" 20 ent1 pm "")
(setq ent2 (entlast))
(setq pts2 (mapcar 'cdr (vl-remove-if-not '(lambda(x)(= (car x) 10)) (entget ent2))))
(setq i 0)
(repeat 4
(command "_line" (nth i pts1) (nth i pts2) "")
(setq i (1+ i))
)
)
)
)
)
)
(command "_undo" "e")
(setvar "osmode" 0) (setvar "cmdecho" 0)
(princ)
)
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询