Author Topic: Change xref name  (Read 687 times)

0 Members and 1 Guest are viewing this topic.

renkor

  • Newt
  • Posts: 27
Change xref name
« on: August 30, 2018, 01:44:45 PM »
Hello,

I'd like to know if there is a way to change multiple xref names without opening each drawing.

I know there is a tool called Reference Manager From the Start Menu of your pc. You can change the paths but not the name, so...anyone knows a way to change the xref names (not paths) of 50 drawings without opening, for example? I mean the xref name inside autocad drawings (no paths and no reference name at all)

thanks in advance.

MP

  • Seagull
  • Posts: 17454
Re: Change xref name
« Reply #1 on: August 30, 2018, 02:11:52 PM »
Almost trivial via ObjectDBX if you're familiar with same. I wrote, but cannot share, an eTransmit like utility based on ObjectDBX that collects and remaps all linked xrefs, images, pdfs, dgns yada. If you search the forum there's likely applicable examples. Cheers.
\|// Set goal. Experiment tirelessly until
|Oo| practice has become expertise.  Loop.
|- | LinkedIn | Dropbox

renkor

  • Newt
  • Posts: 27
Re: Change xref name
« Reply #2 on: August 31, 2018, 11:34:43 AM »
Hello,

I will look for that in the forum.

Thanks.

ribarm

  • Water Moccasin
  • Posts: 2128
  • Marko Ribar, architect
Re: Change xref name
« Reply #3 on: August 31, 2018, 12:22:25 PM »
I thought eTransmit could do that without need for coding... Sorry if I am mistaking...
Marko Ribar, d.i.a. (graduated engineer of architecture)

:)

M.R. on Youtube

renkor

  • Newt
  • Posts: 27
Re: Change xref name
« Reply #4 on: September 01, 2018, 03:18:58 PM »
I thought eTransmit could do that without need for coding... Sorry if I am mistaking...

Hello, how would be that?

ribarm

  • Water Moccasin
  • Posts: 2128
  • Marko Ribar, architect
Re: Change xref name
« Reply #5 on: September 03, 2018, 09:17:47 AM »
I thought eTransmit could do that without need for coding... Sorry if I am mistaking...

Hello, how would be that?

Nevermind, try this - I cobbled it quickly and it worked for me... In my opinion you don't need ObjectDBX adventure...

Code - Auto/Visual Lisp: [Select]
  1. (defun c:xren ( / AT:ListSelect adoc bl bll xrl pthl pth xrn nam fullpth )
  2.  
  3.  
  4.   (defun AT:ListSelect ( title label height width multi lst / fn fo d item f )
  5.     ;; List Select Dialog (Temp DCL list box selection, based on provided list)
  6.     ;; title - list box title
  7.     ;; label - label for list box
  8.     ;; height - height of box
  9.     ;; width - width of box
  10.     ;; multi - selection method ["true": multiple, "false": single]
  11.     ;; lst - list of strings to place in list box
  12.     ;; Alan J. Thompson, 09.23.08 / 05.17.10 (rewrite)
  13.     (setq fo (open (setq fn (vl-filename-mktemp "" "" ".dcl")) "w"))
  14.     (foreach x (list (strcat "list_select : dialog { label = \"" title "\"; spacer;")
  15.                      (strcat ": list_box { label = \"" label "\";" "key = \"lst\";")
  16.                      (strcat "allow_accept = true; height = " (vl-princ-to-string height) ";")
  17.                      (strcat "width = " (vl-princ-to-string width) ";")
  18.                      (strcat "multiple_select = " multi "; } spacer; ok_cancel; }")
  19.                )
  20.       (write-line x fo)
  21.     )
  22.     (close fo)
  23.     (new_dialog "list_select" (setq d (load_dialog fn)))
  24.     (start_list "lst")
  25.     (mapcar (function add_list) lst)
  26.     (end_list)
  27.     (setq item (set_tile "lst" "0"))
  28.     (action_tile "lst" "(setq item $value)")
  29.     (setq f (start_dialog))
  30.     (unload_dialog d)
  31.     (vl-file-delete fn)
  32.     (if (= f 1)
  33.       (mapcar '(lambda ( n ) (nth n lst)) (read (strcat "(" item ")")))
  34.     )
  35.   )
  36.  
  37.   (if (= 1 (getvar 'dwgtitled))
  38.     (progn
  39.       (while (setq bl (tblnext "BLOCK" (null bl)))
  40.         (setq bll (cons (cdr (assoc 2 bl)) bll))
  41.       )
  42.       (foreach bl bll
  43.         (if (= (vla-get-isxref (vla-item (vla-get-blocks adoc) bl)) :vlax-true)
  44.           (setq xrl (cons bl xrl))
  45.         )
  46.       )
  47.       (foreach xr xrl
  48.         (setq pthl (cons (vla-get-path (vla-item (vla-get-blocks adoc) xr)) pthl))
  49.       )
  50.       (if pthl
  51.         (progn
  52.           (while (null pth)
  53.             (setq pth (car (AT:ListSelect "RENAME XREF" "Select Xref to rename:" 25 50 "false" pthl)))
  54.           )
  55.           (setq xrn (vl-filename-base pth))
  56.           (setq nam (car xrl))
  57.           (while (tblsearch "BLOCK" nam)
  58.             (if (/= nam (car xrl))
  59.               (alert "Specified filename already exist in DWG blocks database... Please specify different filename...")
  60.             )
  61.             (setq nam (lisped "TYPE NEW FILENAME WITHOUT EXTENSION"))
  62.           )
  63.           (if (= "." (substr pth 1 1))
  64.             (setq fullpth (strcat (getvar 'dwgprefix) (substr pth 3)))
  65.           )
  66.           (if fullpth
  67.             (vl-file-copy fullpth (strcat (vl-filename-directory fullpth) "\\" nam ".dwg"))
  68.             (vl-file-copy pth (strcat (vl-filename-directory pth) "\\" nam ".dwg"))
  69.           )
  70.           (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")))
  71.           (vl-cmdf "_.-RENAME" "_B" xrn nam)
  72.           (if fullpth
  73.             (vl-file-delete fullpth)
  74.             (vl-file-delete pth)
  75.           )
  76.         )
  77.         (prompt "\nDWG don't have XREF entities attached...")
  78.       )
  79.     )
  80.     (alert "DWG isn't saved yet... Save DWG and restart routine again...")
  81.   )
  82.   (princ)
  83. )
  84.  

M.R.
« Last Edit: September 03, 2018, 02:03:18 PM by ribarm »
Marko Ribar, d.i.a. (graduated engineer of architecture)

:)

M.R. on Youtube

renkor

  • Newt
  • Posts: 27
Re: Change xref name
« Reply #6 on: September 03, 2018, 11:49:03 AM »
Hello,

thanks for replying. I tried the code and it displays an automatition error. not applicable.

However, i coud find a solution in the forum.

Thanks!

ribarm

  • Water Moccasin
  • Posts: 2128
  • Marko Ribar, architect
Re: Change xref name
« Reply #7 on: September 03, 2018, 12:08:02 PM »
I've modified it once again... Not sure what happens at your side, what could yeld such error... Still if you found solution that works for you, I am glad you did find it...
I only tried to help as much as I can, so thanks for testing my version...
(if you find fix, we'll be grateful if you present us your discovery...)
Regards, M.R.
Marko Ribar, d.i.a. (graduated engineer of architecture)

:)

M.R. on Youtube

ribarm

  • Water Moccasin
  • Posts: 2128
  • Marko Ribar, architect
Re: Change xref name
« Reply #8 on: September 03, 2018, 02:06:32 PM »
I think I discovered where error occur... The problem was my checking of 'path property - even block has it, but it's not applicable... I've changed that line among some others to do checking with (vla-get-isxref) function... I suppose that now shouldn't be problems - for me it works very well...

Regards, M.R.
Marko Ribar, d.i.a. (graduated engineer of architecture)

:)

M.R. on Youtube

renkor

  • Newt
  • Posts: 27
Re: Change xref name
« Reply #9 on: September 04, 2018, 12:06:04 PM »
Hello

I appreciate your effort, of course, dont doubt it. Looking for some time here in the forum (i think i found it here), i tested a very interesting tool. It's a dll file, so write "netload" inside autocad, select the file and then write myxrefmanager. Test it

pd: the error also could be the language (i dont have english autocad, so i have had to recode some lisps to fit my language)

Thanks.