在非worl中创建文本对象
我有以下代码,用户点击一个点。它将创建一个重复点和一个文本标签,其中z值为其内容。当在世界坐标系的俯视图中时,这可以很好地工作,但我无法使其在前/右视图或UCS中工作。
我需要向代码中添加什么才能使其正确显示在任何当前视图/ucs中?
(defun c:ptlev ()
(setq la1 (getvar "clayer"))
(setq SnapVal (getvar "osmode"))
(command "luprec" "3")
(command "osmode" "8")
(setq pp (getpoint "\nPick Point: "))
(command "osmode" "0")
(entmake (list(cons0 "TEXT") ;Entity type
(cons1 (rtos (caddr pp)));The string itself
(cons7 "arialn") ;Text style
(cons8 la1) ;Layer name
(cons 10 (polar pp 0.0 0.10)) ;1st Alignment point
(cons 11 (polar pp 0.0 0.05)) ;2nd Alignment point
(cons 40 0.2) ;Text height
(cons 50 0.0) ;Text rotation
(cons 51 0.0) ;Oblique angle
(cons 62 256) ;Colour (256=Bylayer)
(cons 72 0) ;Horizontal text justification
(cons 73 0) ;Vertical text justification
)
)
(command "point" pp)
(command "osmode" SnapVal)
)
我建议如下:
(defun c:ptlev ( / ins ocs pnt )
(while
(setq pnt (getpoint "\nPick point <exit>: ")) ;; UCS point
(setq ins (cons (+ (car pnt) 0.1) (cdr pnt));; UCS Text insertion point
pnt (trans pnt 1 0) ;; WCS point
ocs (trans '(0.0 0.0 1.0) 1 0 t) ;; OCS normal vector
)
(entmake
(list
'(00 . "TEXT");; Entity type
(cons 01 (rtos (caddr pnt))) ;; Z-coordinate of WCS point
(cons 07 (if (tblsearch "style" "arialn") "arialn" (getvar 'textstyle))) ;; Text Style
(cons 10 (trans ins 1 ocs)) ;; OCS insertion point
(cons 50 (angle '(0.0 0.0) (trans (getvar 'ucsxdir) 0 ocs t))) ;; Rotation to match UCS
'(40 . 0.2) ;; Text Height
'(62 . 256) ;; Colour set to ByLayer
(cons 210 ocs) ;; Normal vector of OCS plane
)
)
(entmake
(list
'(00 . "POINT") ;; Entity type
'(62 . 256) ;; Colour set to ByLayer
(cons 010 pnt) ;; WCS point
(cons 210 ocs) ;; For when PDMODE /= 0
)
)
)
(princ)
)
李太棒了,谢谢你的帮助和快速反应
抢劫 不客气,罗伯
页:
[1]