Author Topic: How to change the file name in Xref?  (Read 1970 times)

0 Members and 1 Guest are viewing this topic.

HasanCAD

  • Swamp Rat
  • Posts: 1422
How to change the file name in Xref?
« on: July 11, 2011, 11:58:17 AM »
How can I change the files name in Xrefs?
There is a project has a subfolders each subfolder has files, and and each file has Xref from other subfolders (minimum 1 folder)
By the way this project has 14 zones each zone as a separate project but has to read the areas around.
So I made this complicated net.
And the net is OK, But we want change the files name. That means I have to rebuild the net again.

Is there a faster solution?

HasanCAD

  • Swamp Rat
  • Posts: 1422
Re: How to change the file name in Xref?
« Reply #1 on: July 13, 2011, 06:50:48 AM »
is this a good way
this code gives an error
Code: [Select]
; error: syntax error

Code: [Select]
(defun c:XrefRename ()
  (vl-load-com)

  (setq i 1)
  (if (setq ss (ssget "_X" '((0 . "INSERT") (70 . 0))))
    (repeat (setq i (sslength ss))
      (setq lst (vl-remove-if 'listp (mapcar 'cadr (ssnamex ss))))
      (setq ssObj (ssname lst (setq i (1- i))))
      (setq XrPth (cdr (assoc 1 (entget ssObj)))
    (_replace Arraignment arrangement XrPth)
      )
    )
  )


  (defun _replace (oldtext newtext textstring / i n)
;CAB
    (setq n (strlen newtext))
    (while (setq i (vl-string-search oldtext textstring i))
      (setq textstring
     (vl-string-subst newtext oldtext textstring i)
    i (+ i n)
      )
    )
    textstring
  )
)

ronjonp

  • Needs a day job
  • Posts: 7529
Re: How to change the file name in Xref?
« Reply #2 on: July 13, 2011, 12:20:45 PM »
Just a quick stab in the dark:

Replace:
(_replace Arraignment arrangement XrPth)
With:
(_replace "Arraignment" "arrangement" XrPth)

The _replace function needs strings...

Windows 11 x64 - AutoCAD /C3D 2023

Custom Build PC