马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。
您需要 登录 才可以下载或查看,没有账号?立即注册
x
[sell](defun c:XDTB_DimLnCoord ( / an base dir e etxt g h inx key pt scl ss tf txt xdir ydir) (defun _keyword (key)
(cond
((= key "H")
(if (setq h (getreal (xdrx_prompt "\n输入字高<" #coords_txtheight
">:" t
)
)
)
(setq #coords_txtheight h)
)
)
((= key "G")
(initget 2)
(if (setq h (getint (xdrx_prompt "\n输入遮罩边距系数(字高比值)<" #XD_GLOBAL_VAR_LAYOUTOFFSET ">:" t)))
(setq #XD_GLOBAL_VAR_LAYOUTOFFSET (abs h))
)
)
)
(_prompt)
)
(defun _prompt ()
(xdrx_prompt "\n当前设置: 字高(" #coords_txtheight ") | 遮罩边距(" #XD_GLOBAL_VAR_LAYOUTOFFSET ")")
)
(if (not #coords_txtheight)
(setq #coords_txtheight 3.0)
)
(if (not #XD_GLOBAL_VAR_LAYOUTOFFSET)
(setq #XD_GLOBAL_VAR_LAYOUTOFFSET 5)
)
(xdrx_begin)
(_prompt)
(setq tf t)
(setq scl (* (xd::var:getscaleratio) (xd::var:getratio)))
(while (and
tf
(xdrx_initget "H G")
(setq e (xdrx_entsel "\n拾取线上一点[字高(H)/遮罩边距(G)]<退出>:" '
((0 . "LINE,LWPOLYLINE"))
)
)
)
(setq txt nil dir nil)
(cond
((= (type e) 'STR)
(_keyword e)
)
((= (type e) 'LIST)
(setq pt (cadr e)
e (car e)
xdir (getvar "ucsxdir")
ydir (getvar "ucsydir")
)
(if (xdrx_object_isa e "AcDbPolyline")
(progn
(setq inx (xd::polyline:onsegat e (setq pt
(xdrx_curve_getclosestpoint e
(trans pt 1 0)
)
)
)
)
(if (setq g (xdrx_getpropertyvalue e "linesegat" inx))
(progn
(mapcar
'set
'(dir an)
(xdge::getpropertyvalue g "direction" "angle")
)
(xdge::free g)
)
(xdrx_prompt "\n选择了弧线段,请选择直线段,重试.")
)
)
(progn
(setq dir (cadr (xdrx_entity_getecs e))
pt (trans pt 1 0)
an (xdrx_getpropertyvalue e "angle")
)
)
)
(if dir
(progn
(cond
((xdrx_vector_IsParallel xdir dir)
(setq p (trans pt 0 1))
(setq txt (strcat "X=" (if (and (= 0 (cadr p))(>= (car p) 0)) "-" "") (rtos (cadr p) 2 (getvar "luprec"))))
)
((xdrx_vector_IsParallel ydir dir)
(setq txt (strcat "Y=" (rtos (car (trans pt 0 1)) 2 (getvar "luprec"))))
)
(t
(xdrx_prompt "\n选点所在线与当前坐标系X,Y轴不平行,重试.")
)
)
(if txt
(progn
(setq an (xd::geom:angleformat an))
(setq ss (ssadd))
(xd::text:init 1)
(setq etxt (xdrx_text_make pt txt (* scl #coords_txtheight)
an
)
)
(XD::Text:AdjustAlignMent (entlast) 1 2)
(ssadd (entlast) ss)
(setq base (trans (xd::geom:get9pt (entlast) 5) 1 0))
;|
(xdrx_circle_make base (/ #coords_txtheight 5))
(ssadd (entlast) ss)
|;
(xdrx_block_make (strcat "XLineCoord-"
(xdrx_getpropertyvalue
(entlast)
"handle"
)
) ss base t
)
(xdrx_insert_appendwipeout (entlast)
(/ (* scl #coords_txtheight) #XD_GLOBAL_VAR_LAYOUTOFFSET) t
)
(xdrx_entity_move (entlast) (xdrx_getpropertyvalue
(entlast) "position"
) pt
)
(xdrx_block_Text2Attribute (entlast))
(xdrx_object_regen e)
)
)
)
)
)
(t
(setq tf nil)
)
)
)
(xdrx_end)
(princ)
)
[/sell] |