- 积分
- 6366
- 明经币
- 个
- 注册时间
- 2013-7-3
- 在线时间
- 小时
- 威望
-
- 金钱
- 个
- 贡献
-
- 激情
-
|

楼主 |
发表于 2018-7-12 22:08:41
|
显示全部楼层
非常感谢各位 ,东拼西凑如下,请各位老师指正,谢谢!!!
(defun c:tt ( / Vosmode ent pts pt1 pt2 cpt1 cpt2 clen xlen bl blna ss tmp)
(setq Vosmode (getvar "osmode"))
(setq ent (entsel "\n多边形底边:"))
(setq cpt1 (getpoint "\n多边形顶点:"))
(if (= PoGaoDu nil) (setq PoGaoDu 2000))
(setq tmp (getint (strcat "\n抬起高度(mm)<" (itoa PoGaoDu) ">:")))
(if tmp (setq PoGaoDu tmp) (setq PoGaoDu PoGaoDu))
(setq pts (selpt ent))
(setq pt1 (car pts))
(setq pt2 (cadr pts))
(setq cpt2 (perPoint cpt1 pt1 pt2))
(setq clen (distance cpt1 cpt2))
(setq xlen (sqrt (+ (* clen clen) (* PoGaoDu PoGaoDu))))
(setq bl (/ xlen clen))
(command ".UNDO" "BE")
(if ent
(progn
(setvar "osmode" 0)
(setq blna "BlockName")
(if (= (tblsearch "BLOCK" blna) nil)
(command "-block" blna pt1 ent "")
(command "-block" blna "Y" pt1 ent "")
)
)
)
(command "-insert" blna pt1 "" "" "")
(setq ent (entlast))
(if (= (fix (car pt1)) (fix (car pt2)))
(entmod (append (entget ent) (list (cons 41 bl))))
(entmod (append (entget ent) (list (cons 42 bl))))
)
(command "explode" ent "")
(setq ss (ssget "p"))
(command "._Pedit" "M" SS "" "J" "1" "")
(command "_.chprop" (entlast) "" "_la" (getvar "clayer") "_c" (getvar "cecolor") "")
(if (= (fix (car pt1)) (fix (car pt2)))
(progn
(if (> (fix (car pt1)) (fix (car cpt1)))
(command "_move" (entlast) "" pt1 (strcat "@" (rtos (- xlen clen) 2 5) ",0"))
(command "_move" (entlast) "" pt1 (strcat "@" (rtos (- clen xlen) 2 5) ",0"))
)
)
(progn
(if (> (fix (cadr pt1)) (fix (cadr cpt1)))
(command "_move" (entlast) "" pt1 (strcat "@0," (rtos (- xlen clen) 2 5)))
(command "_move" (entlast) "" pt1 (strcat "@0," (rtos (- clen xlen) 2 5)))
)
)
)
(command ".UNDO" "E")
(if Vosmode (setvar "osmode" Vosmode))
(princ)
) |
|