可以用反應器實現,前提是畫線和輸入文字必須用定義的函式一次性操作完成.lisp程式碼如下:
(vl-load-com)
(defunc:line_txt(/ptpt1pt2entlinehandtxtvlaobjtmp)
(setqpt1(getpoint"\n指定第一點:"))
(setqpt2(getpoint"\n指定下一點:"))
(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"\n指定高度:"))))
handtxt(appendhandtxt(list(cons721)))
handtxt(appendhandtxt(list(cons730)))
handtxt(appendhandtxt(list(cons50(anglept1pt2))))
handtxt(appendhandtxt(list(cons1(getstring"\n輸入文字:>")))))
(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)))
(setqenttxt(subst(cons50(anglept1pt2))(assoc50enttxt)enttxt)
enttxt(subst(append"(10)pt1)(assoc10enttxt)enttxt)
enttxt(subst(append"(11)pt)(assoc11enttxt)enttxt))
(entmodenttxt)
也可以用屬性塊實現,將文字與直線定義成屬性塊,開啟塊編輯器,在引數選項板中設定點引數和旋轉引數,在動作選項板中定義要執行的動作,……,具體的自己參照屬性塊的做吧。
可以用反應器實現,前提是畫線和輸入文字必須用定義的函式一次性操作完成.lisp程式碼如下:
(vl-load-com)
(defunc:line_txt(/ptpt1pt2entlinehandtxtvlaobjtmp)
(setqpt1(getpoint"\n指定第一點:"))
(setqpt2(getpoint"\n指定下一點:"))
(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"\n指定高度:"))))
handtxt(appendhandtxt(list(cons721)))
handtxt(appendhandtxt(list(cons730)))
handtxt(appendhandtxt(list(cons50(anglept1pt2))))
handtxt(appendhandtxt(list(cons1(getstring"\n輸入文字:>")))))
(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)
)
也可以用屬性塊實現,將文字與直線定義成屬性塊,開啟塊編輯器,在引數選項板中設定點引數和旋轉引數,在動作選項板中定義要執行的動作,……,具體的自己參照屬性塊的做吧。