Author Topic: Repathing xRefs  (Read 1634 times)

0 Members and 1 Guest are viewing this topic.

cmwade77

  • Swamp Rat
  • Posts: 1449
Repathing xRefs
« on: March 25, 2015, 02:16:59 PM »
I have asked similar questions before, but I think I have this narrowed down. I need to repath xRefs without using VLA or VLAX commands.
I have the following code, which works fine on DWFs. I would think that there would be a way to modify this to work with xrefs, I just don't know what to replace "ACAD_DWFDEFINITIONS" with.

Code: [Select]
(and (setq d (dictsearch (namedobjdict) "ACAD_DWFDEFINITIONS"));This is the line I need help with, I don't know how to find xRefs
(setq d (dictsearch (cdr (assoc -1 d)) rName))
(entmod (subst (cons 1 rPath) (assoc 1 d) d))
)

I currently use -xref to repath, the problem is that it won't let me repath xrefs that have been saved with a relative path.

ronjonp

  • Needs a day job
  • Posts: 7533
Re: Repathing xRefs
« Reply #1 on: March 25, 2015, 02:57:19 PM »
Use something like this. This will return a list of enames and associated paths.
Code - Auto/Visual Lisp: [Select]
  1. (defun _getxrefs (/ b bl)
  2.   (while (setq b (tblnext "block" (not b)))
  3.     (and ;;xref path
  4.     (assoc 1 b)
  5.     (setq bl (cons (list (tblobjname "block" (cdr (assoc 2 b))) (cdr (assoc 1 b))) bl))
  6.     )
  7.   )
  8.   bl
  9. )
  10. (_getxrefs)

Windows 11 x64 - AutoCAD /C3D 2023

Custom Build PC

cmwade77

  • Swamp Rat
  • Posts: 1449
Re: Repathing xRefs
« Reply #2 on: March 25, 2015, 03:00:09 PM »
Sorry, I guess I wasn't clear, I can get the list of xRefs no problem, this is actually changing the path of the xRef.

ronjonp

  • Needs a day job
  • Posts: 7533
Re: Repathing xRefs
« Reply #3 on: March 25, 2015, 03:06:33 PM »
Then just entmod your xrefs? In your example you were trying to get xrefs from the (namedobjdict) which they do not reside in.

Windows 11 x64 - AutoCAD /C3D 2023

Custom Build PC

cmwade77

  • Swamp Rat
  • Posts: 1449
Re: Repathing xRefs
« Reply #4 on: March 25, 2015, 03:15:07 PM »
Then just entmod your xrefs? In your example you were trying to get xrefs from the (namedobjdict) which they do not reside in.
Any suggestions on how to make entmod work with changing the xRef path? I have tried before and have yet to succeed, but maybe I was doing something wrong......I'm not sure where the code is though, if I find it, I will post it.

cmwade77

  • Swamp Rat
  • Posts: 1449
Re: Repathing xRefs
« Reply #5 on: March 25, 2015, 05:12:39 PM »
Ok, I found the problem, it was actually nested xRefs, not relative xrefs that was causing the repathing to fail.

ronjonp

  • Needs a day job
  • Posts: 7533
Re: Repathing xRefs
« Reply #6 on: March 25, 2015, 05:17:47 PM »
Glad you got it figured out :)

Windows 11 x64 - AutoCAD /C3D 2023

Custom Build PC