马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。
您需要 登录 才可以下载或查看,没有账号?立即注册
×
- (defun c:xren ( / AT:ListSelect adoc bl bll xrl pthl pth xrn nam fullpth )
-
- (vl-load-com)
-
- (defun AT:ListSelect ( title label height width multi lst / fn fo d item f )
- ;; List Select Dialog (Temp DCL list box selection, based on provided list)
- ;; title - list box title
- ;; label - label for list box
- ;; height - height of box
- ;; width - width of box
- ;; multi - selection method ["true": multiple, "false": single]
- ;; lst - list of strings to place in list box
- ;; Alan J. Thompson, 09.23.08 / 05.17.10 (rewrite)
- (setq fo (open (setq fn (vl-filename-mktemp "" "" ".dcl")) "w"))
- (foreach x (list (strcat "list_select : dialog { label = \"" title "\"; spacer;")
- (strcat ": list_box { label = \"" label "\";" "key = \"lst\";")
- (strcat "allow_accept = true; height = " (vl-princ-to-string height) ";")
- (strcat "width = " (vl-princ-to-string width) ";")
- (strcat "multiple_select = " multi "; } spacer; ok_cancel; }")
- )
- (write-line x fo)
- )
- (close fo)
- (new_dialog "list_select" (setq d (load_dialog fn)))
- (start_list "lst")
- (mapcar (function add_list) lst)
- (end_list)
- (setq item (set_tile "lst" "0"))
- (action_tile "lst" "(setq item $value)")
- (setq f (start_dialog))
- (unload_dialog d)
- (vl-file-delete fn)
- (if (= f 1)
- (mapcar '(lambda ( n ) (nth n lst)) (read (strcat "(" item ")")))
- )
- )
-
- (if (= 1 (getvar 'dwgtitled))
- (progn
- (setq adoc (vla-get-activedocument (vlax-get-acad-object)))
- (while (setq bl (tblnext "BLOCK" (null bl)))
- (setq bll (cons (cdr (assoc 2 bl)) bll))
- )
- (foreach bl bll
- (if (= (vla-get-isxref (vla-item (vla-get-blocks adoc) bl)) :vlax-true)
- (setq xrl (cons bl xrl))
- )
- )
- (foreach xr xrl
- (setq pthl (cons (vla-get-path (vla-item (vla-get-blocks adoc) xr)) pthl))
- )
- (if pthl
- (progn
- (while (null pth)
- (setq pth (car (AT:ListSelect "RENAME XREF" "Select Xref to rename:" 25 50 "false" pthl)))
- )
- (setq xrn (vl-filename-base pth))
- (setq nam (car xrl))
- (while (tblsearch "BLOCK" nam)
- (if (/= nam (car xrl))
- (alert "Specified filename already exist in DWG blocks database... Please specify different filename...")
- )
- (setq nam (lisped "TYPE NEW FILENAME WITHOUT EXTENSION"))
- )
- (if (= "." (substr pth 1 1))
- (setq fullpth (strcat (getvar 'dwgprefix) (substr pth 3)))
- )
- (if fullpth
- (vl-file-copy fullpth (strcat (vl-filename-directory fullpth) "\\" nam ".dwg"))
- (vl-file-copy pth (strcat (vl-filename-directory pth) "\\" nam ".dwg"))
- )
- (vl-cmdf "_.-XREF" "_P" xrn (if fullpth (strcat (vl-string-right-trim (strcat (vl-filename-base pth) ".dwg") pth) nam ".dwg") (strcat (vl-filename-directory pth) "\\" nam ".dwg")))
- (vl-cmdf "_.-RENAME" "_B" xrn nam)
- (if fullpth
- (vl-file-delete fullpth)
- (vl-file-delete pth)
- )
- )
- (prompt "\nDWG don't have XREF entities attached...")
- )
- )
- (alert "DWG isn't saved yet... Save DWG and restart routine again...")
- )
- (princ)
- )
|