本帖最后由 edata 于 2014-7-30 18:02 编辑
- ;;图形内链接跳转
- ;;code by edata @ mjtd.com 2014-7-30
- ;;首次执行将选择提示选择对象并关联对象
- ;;再次选择关联的对象将相互跳转
- ;;关联跳转
- (defun c:tt(/ ss en en2 en2_h5 en_h5 sk_link)
- (prompt "\n请选择关联对象:")
- (if(setq ss(ssget ":E:S" ));'((0 . "*text"))))
- (progn
- (setq en(ssname ss 0))
- (setq en_h5(sk_dxf en 5))
- (if(and (setq sk_link(vlax-ldata-get (vlax-ename->vla-object en) "sk_hplink")) (entget (handent sk_link)))
- (progn
- (prompt "\n执行跳转.")
- (setvar 'cmdecho 0)
- (command "zoom" "o" (ssadd(handent sk_link)) "")
- (setvar 'cmdecho 1)
- )
- (progn
- (if(setq en2(car(entsel "\n该对象无链接,请选择链接对象:")))
- (progn
- (setq en2_h5(sk_dxf en2 5))
- (vlax-ldata-put (vlax-ename->vla-object en) "sk_hplink" en2_h5)
- (vlax-ldata-put (vlax-ename->vla-object en2) "sk_hplink" en_h5)
- (prompt "\n链接完成.")
- )
- )
- )
- )
- )
- )
- (princ)
- )
- ;;关联删除
- (defun c:tt2(/ ss en sk_link en2)
- (prompt "\n请选择需要删除关联的对象:")
- (if(setq ss(ssget));'((0 . "*text"))))
- (while(setq en(ssname ss 0))
- (if(setq sk_link(vlax-ldata-get (vlax-ename->vla-object en) "sk_hplink"))
- (progn
- (prompt "\r删除........")
- (setq en2 (handent sk_link))
- (vlax-ldata-delete (vlax-ename->vla-object en) "sk_hplink")
- (and (entget en2) (vlax-ldata-delete (vlax-ename->vla-object en2) "sk_hplink"))
- (prompt "\r删除完成....")
- )
- (prompt "\r没有发现链接.")
- )
- (setq ss (ssdel en ss))
- )
- )
- (princ)
- )
- ;;dxf组码获取函数
- (defun sk_dxf(ent code)(cdr(assoc code (entget ent))))
|