马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。
您需要 登录 才可以下载或查看,没有账号?立即注册
×
最近用反应器制作了个动态坐标显示的东西,可惜只能照猫画虎做个连接到点实体的对象反应器来实现,无法做个自身随位置改变而改变的反应器。请相关高手伸出援助之手。下面放上我 的lisp代码和操作效果。奇怪的是如果同时移动点和文字,而文字会在原来的位置和新移动到的位置显示两个实体,用regen刷新后原来位置上的就消失了。- (vl-load-com)
- (defun c:bb ()
- (setq e-pt (car (entsel "\n 点")))
- (setq e-text (car (entsel "\n 文字")))
- (setq el-pt (entget e-pt)
- str (strcat "X="
- (rtos (cadr (assoc 10 el-pt)) 2 3)
- " Y="
- (rtos (caddr (assoc 10 el-pt)) 2 3)
- )
- el-text (entget e-text)
- jb (list (cdr (assoc 5 el-text)))
- obj-pt (list (vlax-ename->vla-object e-pt))
- )
- (setq
- vrl (vlr-pers
- (vlr-object-reactor obj-pt jb '((:vlr-modified . c-2l)))
- )
- )
- (princ)
- (setq el-text (subst (cons 1 str) (assoc 1 el-text) el-text))
- (entmod el-text)
- (setq loop T)
- (while loop
- (setq code (grread T 8)
- mod (car code)
- val (cadr code)
- )
- (cond
- ((= 5 mod)
- (setq el-pt (subst (cons 10 val) (assoc 10 el-pt) el-pt))
- (entmod el-pt)
- (command "regen")
- )
- ((or (= 3 mod) (= 25 mod)) (setq loop nil))
- )
- )
- )
- (defun c-2l (notifier-object
- reactor-object
- parameter-list
- /
- )
- (setq p (vlax-safearray->list
- (vlax-variant-value
- (vla-get-Coordinates notifier-object)
- )
- )
- )
- (setq str (strcat "X=" (rtos (car p) 2 3) " Y=" (rtos (cadr p) 2 3)))
- (setq e (handent (car (vlr-data reactor-object)))) ;获取文本图元名
- (setq el (entget e))
- (setq el (subst (vl-list* 1 str) (assoc 1 el) el))
- (entmod el) ;更新文本图元表
- )
|