Author Topic: Repath xrefs with new path  (Read 23009 times)

0 Members and 1 Guest are viewing this topic.

MP

  • Seagull
  • Posts: 17750
  • Have thousands of dwgs to process? Contact me.
Re: Repath xrefs with new path
« Reply #45 on: July 21, 2006, 07:07:37 PM »
Michael

MyGetFilesFunction?
MySaveAxDbDocument?
MyOpenAxDbDocument?

Gary

Hi Gary. Like I said, it is / was pseudo code (not intended to be executable as is), a framework or outline to use as a coding recipe of sorts.

MyGetFilesFunction is a user supplied function that returns a list of path qualified files that meet a spec.

e.g. given a spec of "c:\\path\\*.dwg" might return --

    (   
        "c:\\path\\drawing1.dwg"
        "c:\\path\\drawing2.dwg"
        "c:\\path\\drawing3.dwg"
    )


MyOpenAxDbDocument is a user supplied function that takes care of creating an creating an ObjectDBX instance and opening the specified document, trapping all potential errors and returning nil if errors are encountered or an AxDbDocument if the instance is successfully created and the drawing successfully opened.

MySaveAxDbDocument is a user supplied function that is responsible for saving an AxDbDocument. As documents opened via ObjectDBX do not support the Save method it means it has to perform some slight of hand to achieve this. For example it might use the SaveAs method to save the document to a temporary file, close the document, and then use vl-file-copy to copy the temp file over the desired file (qualifying / error trapped accordingly as it goes).

Hope this clarifies.
« Last Edit: July 21, 2006, 07:28:51 PM by mp »
Engineering Technologist • CAD Automation Practitioner
Automation ▸ Design ▸ Drafting ▸ Document Control ▸ Client
cadanalyst@gmail.comhttp://cadanalyst.slack.comhttp://linkedin.com/in/cadanalyst

T.Willey

  • Needs a day job
  • Posts: 5251
Re: Repath xrefs with new path
« Reply #46 on: July 21, 2006, 07:30:03 PM »
MySaveAxDbDocument is a user supplied function that is responsible for saving an AxDbDocument. As documents opened via ObjectDBX do not support the Save method it means it has to perform some slight of hand to achieve this. For example it might use the SaveAs method to save the document to a temporary file, close the document, and then use vl-file-copy to copy the temp file over the desired file (qualifying / error trapped accordingly as it goes).

Hope this clarifies.
FYI......
ObjectDBX doesn't have a Save method, but you can use the SaveAs method to the same file name and path as the opened file, so it works like a Save method. (which I'm sure you know Michael)
Tim

I don't want to ' end-up ', I want to ' become '. - Me

Please think about donating if this post helped you.

MP

  • Seagull
  • Posts: 17750
  • Have thousands of dwgs to process? Contact me.
Re: Repath xrefs with new path
« Reply #47 on: July 21, 2006, 07:43:19 PM »
MySaveAxDbDocument is a user supplied function that is responsible for saving an AxDbDocument. As documents opened via ObjectDBX do not support the Save method it means it has to perform some slight of hand to achieve this. For example it might use the SaveAs method to save the document to a temporary file, close the document, and then use vl-file-copy to copy the temp file over the desired file (qualifying / error trapped accordingly as it goes).

Hope this clarifies.
FYI......
ObjectDBX doesn't have a Save method, but you can use the SaveAs method to the same file name and path as the opened file, so it works like a Save method. (which I'm sure you know Michael)

When I first started using ObjectDBX 6 years ago you couldn't use the SaveAs method to save an ObjectDBX document over itself (if memory serves me correctly), hense the slight of hand mention above, but meh, of the things I've lost I miss my mind the most (subtitle, no I didn't know that Tim). Thank you sir, noted for future use (going to have to test this in various versions of AutoCAD next week, only have 2006 here and I confirmed what you noted above).
« Last Edit: July 21, 2006, 07:52:58 PM by mp »
Engineering Technologist • CAD Automation Practitioner
Automation ▸ Design ▸ Drafting ▸ Document Control ▸ Client
cadanalyst@gmail.comhttp://cadanalyst.slack.comhttp://linkedin.com/in/cadanalyst

T.Willey

  • Needs a day job
  • Posts: 5251
Re: Repath xrefs with new path
« Reply #48 on: July 21, 2006, 09:01:10 PM »
MySaveAxDbDocument is a user supplied function that is responsible for saving an AxDbDocument. As documents opened via ObjectDBX do not support the Save method it means it has to perform some slight of hand to achieve this. For example it might use the SaveAs method to save the document to a temporary file, close the document, and then use vl-file-copy to copy the temp file over the desired file (qualifying / error trapped accordingly as it goes).

Hope this clarifies.
FYI......
ObjectDBX doesn't have a Save method, but you can use the SaveAs method to the same file name and path as the opened file, so it works like a Save method. (which I'm sure you know Michael)

When I first started using ObjectDBX 6 years ago you couldn't use the SaveAs method to save an ObjectDBX document over itself (if memory serves me correctly), hense the slight of hand mention above, but meh, of the things I've lost I miss my mind the most (subtitle, no I didn't know that Tim). Thank you sir, noted for future use (going to have to test this in various versions of AutoCAD next week, only have 2006 here and I confirmed what you noted above).
I have used that method on 2004 also.  Just so you know.  Glad I could help you once.  :-D
Tim

I don't want to ' end-up ', I want to ' become '. - Me

Please think about donating if this post helped you.

GDF

  • Water Moccasin
  • Posts: 2081
Re: Repath xrefs with new path
« Reply #49 on: July 24, 2006, 10:35:26 AM »
Thanks

Tim and Michael

One of these days I am going to have to learn this vlisp stuff...

Code: [Select]
MyGetFilesFunction is a user supplied function that returns a list of path qualified files that meet a spec.

e.g. given a spec of "c:\\path\\*.dwg" might return --

    (   
        "c:\\path\\drawing1.dwg"
        "c:\\path\\drawing2.dwg"
        "c:\\path\\drawing3.dwg"
    )

MyOpenAxDbDocument is a user supplied function that takes care of creating an creating an ObjectDBX instance and opening the specified document, trapping all potential errors and returning nil if errors are encountered or an AxDbDocument if the instance is successfully created and the drawing successfully opened.

MySaveAxDbDocument is a user supplied function that is responsible for saving an AxDbDocument. As documents opened via ObjectDBX do not support the Save method it means it has to perform some slight of hand to achieve this. For example it might use the SaveAs method to save the document to a temporary file, close the document, and then use vl-file-copy to copy the temp file over the desired file (qualifying / error trapped accordingly as it goes).

Hope this clarifies.


Tim

Your original routine works great, but sometimes it does not pick and change the xref paths. I was wondering if
Michaels approach would work any better. Since this vl stuff is beyond me, I was hoping you could try combining
Michael's and your routine to see if this would work any better.

Gary
Why is there never enough time to do it right, but always enough time to do it over?
BricsCAD 2020x64 Windows 10x64

T.Willey

  • Needs a day job
  • Posts: 5251
Re: Repath xrefs with new path
« Reply #50 on: July 24, 2006, 11:09:10 AM »
Gary,

  I would have to see some test drawings, so that I can see why it doesn't work.  It could be that the paths are not completely stored.  Can you post a small zip file with some of the drawings?
Tim

I don't want to ' end-up ', I want to ' become '. - Me

Please think about donating if this post helped you.

GDF

  • Water Moccasin
  • Posts: 2081
Re: Repath xrefs with new path
« Reply #51 on: July 24, 2006, 11:49:19 AM »
Gary,

  I would have to see some test drawings, so that I can see why it doesn't work.  It could be that the paths are not completely stored.  Can you post a small zip file with some of the drawings?

Tim

Thanks. Only the titleblock within the sheet files A2-01a thru A2-01c was repathed. The test was for the new
directory location of C:\Jobs\2006\069999 and the original directory of F:\Jobs\2006\060614

- Drawing "C:\Jobs\2006\069999\acad\2436TB.dwg" report
 - Drawing "C:\Jobs\2006\069999\acad\A2-01a.dwg" report
  Xref name: 2436TB
    Xref path C:\Jobs\2006\069999\acad\2436TB.dwg
 - Drawing "C:\Jobs\2006\069999\acad\A2-01b.dwg" report
  Xref name: 2436TB
    Xref path C:\Jobs\2006\069999\acad\2436TB.dwg
 - Drawing "C:\Jobs\2006\069999\acad\A2-01c.dwg" report
  Xref name: 2436TB
    Xref path C:\Jobs\2006\069999\acad\2436TB.dwg
 - Drawing "C:\Jobs\2006\069999\acad\A2-02a.dwg" report
  Xref name: 2436TB
    Xref path C:\Jobs\2006\069999\acad\2436TB.dwg
 - Drawing "C:\Jobs\2006\069999\acad\A2-02b.dwg" report
  Xref name: 2436TB
    Xref path C:\Jobs\2006\069999\acad\2436TB.dwg
 - Drawing "C:\Jobs\2006\069999\acad\A2-02c.dwg" report
  Xref name: 2436TB
    Xref path C:\Jobs\2006\069999\acad\2436TB.dwg

Gary
Why is there never enough time to do it right, but always enough time to do it over?
BricsCAD 2020x64 Windows 10x64

T.Willey

  • Needs a day job
  • Posts: 5251
Re: Repath xrefs with new path
« Reply #52 on: July 24, 2006, 12:10:34 PM »
Gary,

  Run this file, and post the log file created.
Tim

I don't want to ' end-up ', I want to ' become '. - Me

Please think about donating if this post helped you.

GDF

  • Water Moccasin
  • Posts: 2081
Re: Repath xrefs with new path
« Reply #53 on: July 24, 2006, 12:24:23 PM »
Gary,

  Run this file, and post the log file created.

Tim

Still the same, only the titleblock is repathed in each of the xrefs.

 - Drawing "C:\Jobs\2006\069999\acad\2436TB.dwg" report
 - Drawing "C:\Jobs\2006\069999\acad\A2-01a.dwg" report
  Xref name: 2436TB
    Xref path old F:\Jobs\2006\060614\ACAD\2436TB.dwg
    Xref path new C:\Jobs\2006\069999\acad\2436TB.dwg
  Xref name: BL-01
    Xref path old F:\Jobs\2006\060614\ACAD\building\BL-01.dwg
 - Drawing "C:\Jobs\2006\069999\acad\A2-01b.dwg" report
  Xref name: 2436TB
    Xref path old F:\Jobs\2006\060614\ACAD\2436TB.dwg
    Xref path new C:\Jobs\2006\069999\acad\2436TB.dwg
  Xref name: BL-01
    Xref path old F:\Jobs\2006\060614\ACAD\building\BL-01.dwg
 - Drawing "C:\Jobs\2006\069999\acad\A2-01c.dwg" report
  Xref name: 2436TB
    Xref path old F:\Jobs\2006\060614\ACAD\2436TB.dwg
    Xref path new C:\Jobs\2006\069999\acad\2436TB.dwg
  Xref name: BL-01
    Xref path old F:\Jobs\2006\060614\ACAD\building\BL-01.dwg

Gary
Why is there never enough time to do it right, but always enough time to do it over?
BricsCAD 2020x64 Windows 10x64

T.Willey

  • Needs a day job
  • Posts: 5251
Re: Repath xrefs with new path
« Reply #54 on: July 24, 2006, 12:31:33 PM »
Do you see the differences though.
Quote
- Drawing "C:\Jobs\2006\069999\acad\A2-01b.dwg" report
  Xref name: 2436TB
    Xref path old F:\Jobs\2006\060614\ACAD\2436TB.dwg
    Xref path new C:\Jobs\2006\069999\acad\2436TB.dwg
  Xref name: BL-01
    Xref path old F:\Jobs\2006\060614\ACAD\building\BL-01.dwg
The two xref's old paths are not the same.  So now I'm guessing that you want just the beginning of the paths changed?  In other words, whenever the program sees a path of
 F:\Jobs\2006\060614\ACAD\
change it to
C:\Jobs\2006\069999\acad\
no matter what is after it.  And you are picking the path
 F:\Jobs\2006\060614\ACAD\
right?
Tim

I don't want to ' end-up ', I want to ' become '. - Me

Please think about donating if this post helped you.

GDF

  • Water Moccasin
  • Posts: 2081
Re: Repath xrefs with new path
« Reply #55 on: July 24, 2006, 12:50:38 PM »
Correct

- Drawing "C:\Jobs\2006\069999\acad\2436TB.dwg" report
 - Drawing "C:\Jobs\2006\069999\acad\A2-01a.dwg" report
  Xref name: 2436TB
    Xref path old F:\Jobs\2006\060614\ACAD\2436TB.dwg
    Xref path new C:\Jobs\2006\069999\acad\2436TB.dwg
  Xref name: BL-01
    Xref path old F:\Jobs\2006\060614\ACAD\building\BL-01.dwg
 - Drawing "C:\Jobs\2006\069999\acad\A2-01b.dwg" report
  Xref name: 2436TB
    Xref path old F:\Jobs\2006\060614\ACAD\2436TB.dwg
    Xref path new C:\Jobs\2006\069999\acad\2436TB.dwg
  Xref name: BL-01
    Xref path old F:\Jobs\2006\060614\ACAD\building\BL-01.dwg
 - Drawing "C:\Jobs\2006\069999\acad\A2-01c.dwg" report
  Xref name: 2436TB
    Xref path old F:\Jobs\2006\060614\ACAD\2436TB.dwg
    Xref path new C:\Jobs\2006\069999\acad\2436TB.dwg
  Xref name: BL-01
    Xref path old F:\Jobs\2006\060614\ACAD\building\BL-01.dwg


I started over from scratch with drawings copied over from F:\Jobs\2006\060614\acad and
placed them in C:\Jobs\2006\069999\acad and then ran your new routine...picking the old
and then the new folder location.

The tiltleblock resides in the same folder as the sheet files and is repathed. the unit plans
are xrefed into the bulding plan and are not repathed.

Here is the directory structure:

[] F:\Jobs\2006
   [] 060614 <old project folder>
      [] acad <folder for sheet files and titleblock>
         []  building  <folder for building plan>
         []  units  <folder for unit plans>
 
[] C:\Jobs\2006
   [] 069999 <new project folder>
      [] acad <folder for sheet files and titleblock>
         []  building  <folder for building plan>
         []  units  <folder for unit plans>

I hope I am running this right.

Why is there never enough time to do it right, but always enough time to do it over?
BricsCAD 2020x64 Windows 10x64

T.Willey

  • Needs a day job
  • Posts: 5251
Re: Repath xrefs with new path
« Reply #56 on: July 24, 2006, 12:52:29 PM »
Correct

<snip>

I hope I am running this right.
You are.  Here is a new version that should suites your needs.  Let me know

Edit:
Not sure how it will run on nested xrefs, but if it repaths them all, and get the main one right, then hopefully the rest will follow.

I think you might want to set up you future projects with relative paths for xrefs.  Which is kind of what Michael was talking about with the ProjectName stuff.  We used to use the relative paths here, but now we don't, but I think it will work with you folder structure.
« Last Edit: July 24, 2006, 12:55:47 PM by T.Willey »
Tim

I don't want to ' end-up ', I want to ' become '. - Me

Please think about donating if this post helped you.

GDF

  • Water Moccasin
  • Posts: 2081
Re: Repath xrefs with new path
« Reply #57 on: July 24, 2006, 02:36:36 PM »
Tim

I did not pick up the nested xrefs, but it did pick up the building plan. Thank you.
This still a great time saver.

 - Drawing "C:\Jobs\2006\069999\acad\2436TB.dwg" report
 - Drawing "C:\Jobs\2006\069999\acad\A2-01a.dwg" report
  Xref name: 2436TB
    Xref path old F:\Jobs\2006\060614\ACAD\2436TB.dwg
    Xref path new C:\Jobs\2006\069999\acad\2436TB.dwg
  Xref name: BL-01
    Xref path old F:\Jobs\2006\060614\ACAD\building\BL-01.dwg
 - Drawing "C:\Jobs\2006\069999\acad\A2-01b.dwg" report
  Xref name: 2436TB
    Xref path old F:\Jobs\2006\060614\ACAD\2436TB.dwg
    Xref path new C:\Jobs\2006\069999\acad\2436TB.dwg
  Xref name: BL-01
    Xref path old F:\Jobs\2006\060614\ACAD\building\BL-01.dwg
 - Drawing "C:\Jobs\2006\069999\acad\A2-01c.dwg" report
  Xref name: 2436TB
    Xref path old F:\Jobs\2006\060614\ACAD\2436TB.dwg
    Xref path new C:\Jobs\2006\069999\acad\2436TB.dwg
  Xref name: BL-01
    Xref path old F:\Jobs\2006\060614\ACAD\building\BL-01.dwg
 - Drawing "C:\Jobs\2006\069999\ACAD\2436TB.dwg" report
 - Drawing "C:\Jobs\2006\069999\ACAD\A2-01a.dwg" report
  Xref name: 2436TB
    Xref path old C:\Jobs\2006\069999\acad\2436TB.dwg
  Xref name: BL-01
    Xref path old F:\Jobs\2006\060614\ACAD\building\BL-01.dwg
 - Drawing "C:\Jobs\2006\069999\ACAD\A2-01b.dwg" report
  Xref name: 2436TB
    Xref path old C:\Jobs\2006\069999\acad\2436TB.dwg
  Xref name: BL-01
    Xref path old F:\Jobs\2006\060614\ACAD\building\BL-01.dwg
 - Drawing "C:\Jobs\2006\069999\ACAD\A2-01c.dwg" report
  Xref name: 2436TB
    Xref path old C:\Jobs\2006\069999\acad\2436TB.dwg
  Xref name: BL-01
    Xref path old F:\Jobs\2006\060614\ACAD\building\BL-01.dwg
 - Drawing "C:\Jobs\2006\069999\ACAD\2436TB.dwg" report
 - Drawing "C:\Jobs\2006\069999\ACAD\A2-01a.dwg" report
  Xref name: 2436TB
    Xref path old F:\Jobs\2006\060614\ACAD\2436TB.dwg
    Xref path new C:\Jobs\2006\069999\ACAD\2436TB.dwg
  Xref name: BL-01
    Xref path old F:\Jobs\2006\060614\ACAD\building\BL-01.dwg
    Xref path new C:\Jobs\2006\069999\ACAD\building\BL-01.dwg
 - Drawing "C:\Jobs\2006\069999\ACAD\A2-01b.dwg" report
  Xref name: 2436TB
    Xref path old F:\Jobs\2006\060614\ACAD\2436TB.dwg
    Xref path new C:\Jobs\2006\069999\ACAD\2436TB.dwg
  Xref name: BL-01
    Xref path old F:\Jobs\2006\060614\ACAD\building\BL-01.dwg
    Xref path new C:\Jobs\2006\069999\ACAD\building\BL-01.dwg
 - Drawing "C:\Jobs\2006\069999\ACAD\A2-01c.dwg" report
  Xref name: 2436TB
    Xref path old F:\Jobs\2006\060614\ACAD\2436TB.dwg
    Xref path new C:\Jobs\2006\069999\ACAD\2436TB.dwg
  Xref name: BL-01
    Xref path old F:\Jobs\2006\060614\ACAD\building\BL-01.dwg
    Xref path new C:\Jobs\2006\069999\ACAD\building\BL-01.dwg

Gary
Why is there never enough time to do it right, but always enough time to do it over?
BricsCAD 2020x64 Windows 10x64

T.Willey

  • Needs a day job
  • Posts: 5251
Re: Repath xrefs with new path
« Reply #58 on: July 24, 2006, 02:43:43 PM »
I'm not sure how to pick up nested xref's since they are not really pathed from the current drawing.  I guess you could search each xref at it's path, and then change all those xrefs to the new paths also.  If you like I can see if I could code this up.   Let me know.

Glad it works for what you want.  You're welcome.  :-)
Tim

I don't want to ' end-up ', I want to ' become '. - Me

Please think about donating if this post helped you.

GDF

  • Water Moccasin
  • Posts: 2081
Re: Repath xrefs with new path
« Reply #59 on: July 24, 2006, 03:01:03 PM »
I'm not sure how to pick up nested xref's since they are not really pathed from the current drawing.  I guess you could search each xref at it's path, and then change all those xrefs to the new paths also.  If you like I can see if I could code this up.   Let me know.

Glad it works for what you want.  You're welcome.  :-)

Tim

Thanks again for all of your hard work.

Gary
Why is there never enough time to do it right, but always enough time to do it over?
BricsCAD 2020x64 Windows 10x64