全站数据
8 4 2 0 5 8 1

谁可以给我一些CAD的好用LISP程序

IT爱好者的圈子 | 简单学习,快乐成才!         
问题更新日期:2024-10-11 19:32:50

问题描述

谁可以给我一些CAD的好用LISP程序求高手给解答
精选答案
最佳答案

可以用反应器实现,前提是画线和输入文字必须用定义的函数一次性操作完成.lisp代码如下:

(vl-load-com)

(defunc:line_txt(/ptpt1pt2entlinehandtxtvlaobjtmp)

(setqpt1(getpoint

"

指定第一点:

"))

(setqpt2(getpoint

"

指定下一点:

"))

(setqpt(list(/(+(carpt1)(carpt2))2)(/(+(cadrpt1)(cadrpt2))2)(/(+(caddrpt1)(caddrpt2))2)))

(command

"._line

"pt1pt2

"

")

(setqentline(entlast))

(setqvlaobj(cons(vlax-ename->vla-objectentline)'()));;将直线转换为vla对象

(setqhandtxt'((0.

"text

"))

handtxt(appendhandtxt(list(append'(10)pt1)))

handtxt(appendhandtxt(list(append'(11)pt)))

handtxt(appendhandtxt(list(cons40(getdist

"

指定高度:

"))))

handtxt(appendhandtxt(list(cons721)))

handtxt(appendhandtxt(list(cons730)))

handtxt(appendhandtxt(list(cons50(anglept1pt2))))

handtxt(appendhandtxt(list(cons1(getstring

"

输入文字:>

")))))

(entmakehandtxt)

(setqhandtxt(cdr(assoc5(entget(entlast)))))

(vlr-pers(vlr-object-reactorvlaobjhandtxt'((:vlr-modified.linemodefy))))

)

(defunlinemodefy(entlineenttxtparameter-list/ptpt1pt2)

(setqenttxt(entget(handent(vlr-dataenttxt))))

(setqentline(entget(vlax-vla-object->enameentline)))

(setqpt1(cdr(assoc10entline))pt2(cdr(assoc11entline)))

(setqpt(list(/(+(carpt1)(carpt2))2)(/(+(cadrpt1)(cadrpt2))2)(/(+(caddrpt1)(caddrpt2))2)))

(setqenttxt(subst(cons50(anglept1pt2))(assoc50enttxt)enttxt)

enttxt(subst(append'(10)pt1)(assoc10enttxt)enttxt)

enttxt(subst(append'(11)pt)(assoc11enttxt)enttxt))

(entmodenttxt)

)

也可以用属性块实现,将文字与直线定义成属性块,打开块编辑器,在参数选项板中设定点参数和旋转参数,在动作选项板中定义要执行的动作,……,具体的自己参照属性块的做吧。