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

0 Members and 1 Guest are viewing this topic.

T.Willey

  • Needs a day job
  • Posts: 5251
Re: Repath xrefs with new path
« Reply #15 on: July 20, 2006, 05:31:41 PM »
What it does is save the preview image for the darwing.  If you save with ObjectDBX you lose the preview.
Tim

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

Please think about donating if this post helped you.

T.Willey

  • Needs a day job
  • Posts: 5251
Re: Repath xrefs with new path
« Reply #16 on: July 20, 2006, 05:45:54 PM »
Here is the link to the thread on the Adesk Ng where Tony T. posted his arx.  Just look for his post.
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 #17 on: July 21, 2006, 11:04:39 AM »
Tim

This is beyond my abilities, so I am willing to pay you for this routine. What i want is to select all of my sheet files
within a directory and repath all of the xrefs with a new path. The differnce for each drawing path is illustrated
by the following example in bold:

F:\Jobs\2005\050212\acad\job-data\Cover.dwg
F:\Jobs\2006\060614\acad\job-data\Cover.dwg

The routine using objectdbx would repath all of the attached xrefs with the new saved path. I don't want to
rely on using Thumbnailer16.arx <Thumbnailer17.arx ?>.

The routine would have to use wildcards <I quess> for each drawings path:
F:\Jobs\2006\060614\acad\<wildcard>.dwg

This would save me tons of time, sense we routinely copy whole projects over to a new directory when
starting a new job that is similar.

How about $200.00 for your efferts if this can be done.

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

drizzt

  • Guest
Re: Repath xrefs with new path
« Reply #18 on: July 21, 2006, 11:09:49 AM »
Man! I really need to get a better understanding of lisp! This looks like it could be really usefull!

MP

  • Seagull
  • Posts: 17750
  • Have thousands of dwgs to process? Contact me.
Re: Repath xrefs with new path
« Reply #19 on: July 21, 2006, 11:11:30 AM »
Warning: One would be well advised to check the terms of use of any third party utilities used in the execution of any commercial work.
Engineering Technologist • CAD Automation Practitioner
Automation ▸ Design ▸ Drafting ▸ Document Control ▸ Client
cadanalyst@gmail.comhttp://cadanalyst.slack.comhttp://linkedin.com/in/cadanalyst

drizzt

  • Guest
Re: Repath xrefs with new path
« Reply #20 on: July 21, 2006, 11:13:34 AM »
Quote
Warning: One would be well advised to check the terms of use of any third party utilities used in the execution of any commercial work.

understood!

T.Willey

  • Needs a day job
  • Posts: 5251
Re: Repath xrefs with new path
« Reply #21 on: July 21, 2006, 11:16:34 AM »
Warning: One would be well advised to check the terms of use of any third party utilities used in the execution of any commercial work.
Here is the header in his ReadMe file.  Thanks for the warning Michael.  I don't usually write code to get paid for it, it's just fun.
Quote
Thumbnailer.arx  Copyright 2005  www.caddzone.com

   Thumbnailer ActiveX Server Documentation

   Library:   Thumbnailer.arx

   Class:     Application

   ProgID:    "Thumbnailer.Application"

   Reference: "Thumbnailer 1.0 Type Library"

   Requirements:  AutoCAD 2004-2006

   Terms and conditions of use:

      This software may be used and freely distributed,
      provided this notice and the copyright notice
      displayed by the application when it loads, is not
      removed, altered, or concealed.

      This software is not warranted to be free of defects.
      Any and all use of this software is undertaken at the
      risk of the user. The author is not responsible for
      any loss resulting directly or indirectly from the
      use of this software.

      Your use of this software constitutes your acceptance
      of these terms and conditions.

Gary,

  Let me see what I can do.
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 #22 on: July 21, 2006, 11:25:22 AM »
Warning: One would be well advised to check the terms of use of any third party utilities used in the execution of any commercial work.
Here is the header in his ReadMe file.  Thanks for the warning Michael.  I don't usually write code to get paid for it, it's just fun.
Quote
Thumbnailer.arx  Copyright 2005  www.caddzone.com

   Thumbnailer ActiveX Server Documentation

   Library:   Thumbnailer.arx

   Class:     Application

   ProgID:    "Thumbnailer.Application"

   Reference: "Thumbnailer 1.0 Type Library"

   Requirements:  AutoCAD 2004-2006

   Terms and conditions of use:

      This software may be used and freely distributed,
      provided this notice and the copyright notice
      displayed by the application when it loads, is not
      removed, altered, or concealed.

      This software is not warranted to be free of defects.
      Any and all use of this software is undertaken at the
      risk of the user. The author is not responsible for
      any loss resulting directly or indirectly from the
      use of this software.

      Your use of this software constitutes your acceptance
      of these terms and conditions.

Gary,

  Let me see what I can do.

Tim

That is why I don't want to rely on any third party programs. No Thumbnailer.arx or any other third party routines.
I am not paying for the routine, think of it as paying for your time. And yes I am serious about reimburseing you
for your efferts. You can post it to this forum for all to use. I still want to pay you anyway.

Thanks

I thought all work was commercial...

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

MP

  • Seagull
  • Posts: 17750
  • Have thousands of dwgs to process? Contact me.
Re: Repath xrefs with new path
« Reply #23 on: July 21, 2006, 11:29:14 AM »
Thumbnailer.arx  Copyright 2005  www.caddzone.com ...

Label me surprised. While I don't use TT's stuff I recall posts of his on the ngs years ago where he included terms to the effect of "can only be used for non commercial work / in-house works"; adviseable to ensure one understands and is in compliance with any such terms.

Edit: Now just provided as a general warning to all since Gary indicated he isn't interested in employing third party utils.
Engineering Technologist • CAD Automation Practitioner
Automation ▸ Design ▸ Drafting ▸ Document Control ▸ Client
cadanalyst@gmail.comhttp://cadanalyst.slack.comhttp://linkedin.com/in/cadanalyst

GDF

  • Water Moccasin
  • Posts: 2081
Re: Repath xrefs with new path
« Reply #24 on: July 21, 2006, 11:32:04 AM »
Tim

This is beyond my abilities, so I am willing to pay you for this routine. ...

Quick question Gary, and to be clear my inquirey has nothing to do with the coinage above, nor is it to take away potential work from Tim (who can most certainly code anything you need) but have you looked into exploiting the system variable ProjectName to repath the xrefs?

I repathed about 5000 drawings a couple years ago using said variable inside a wrapper of sorts (a lisp program).

Form the help <quote>If an xref or image is not found at the original path, the project paths associated with the project name are searched. If the xref or image is not found there, the AutoCAD search path is searched ...</quote>.

Need more info?

Michael

I am not familiar with this var or how to use it. When we start a new project that is very similar to one in the past,
we copy the whole directory over to a new one. So yes I quess the ProjectName is all that changes.

One of these days I will learn how to use AutoCAD to its full potiential. I've given up on lisping <did I say that right>.

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

MP

  • Seagull
  • Posts: 17750
  • Have thousands of dwgs to process? Contact me.
Re: Repath xrefs with new path
« Reply #25 on: July 21, 2006, 11:36:42 AM »
Carp. I deleted that post Gary because (despite my attempts to pen to the contrary) it reads like I'm trying to take a gig from Tim.

So let me say this -- Tim knows about said variable and more, so I'm going to voluntarilly back off and let Tim have dibs at any responses; trying to do the honourable thing here.
Engineering Technologist • CAD Automation Practitioner
Automation ▸ Design ▸ Drafting ▸ Document Control ▸ Client
cadanalyst@gmail.comhttp://cadanalyst.slack.comhttp://linkedin.com/in/cadanalyst

GDF

  • Water Moccasin
  • Posts: 2081
Re: Repath xrefs with new path
« Reply #26 on: July 21, 2006, 11:42:40 AM »
Carp. I deleted that post Gary because (despite my attempts to pen to the contrary) it reads like I'm trying to take a gig from Tim.

So let me say this -- Tim knows about said variable and more, so I'm going to voluntarilly back off and let Tim have dibs at any responses; trying to do the honourable thing here.

Michael

No problem, Tim has helped me so much in the past already, that I owe him. There comes a point in time
when you have to bring out the check book. This routine will save me tons of time. AutoCAD's
"Refernce Manager" is crap and the express tool does not do what I want. I don't care if the preview image
is not saved, that part is easily fixed.

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 #27 on: July 21, 2006, 11:52:40 AM »
Carp. I deleted that post Gary because (despite my attempts to pen to the contrary) it reads like I'm trying to take a gig from Tim.

So let me say this -- Tim knows about said variable and more, so I'm going to voluntarilly back off and let Tim have dibs at any responses; trying to do the honourable thing here.
It's all good Michael.  I wasn't going to take Gary's money, as I fill my skills are not that good yet, likes yours and many others who share their code here.  I don't use the ProjectName variable, so if you want to explain it, be my guest.  From what I understand is, it is like a relative path, and will keep the xref path until that folder.
Tim

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

Please think about donating if this post helped you.

T.Willey

  • Needs a day job
  • Posts: 5251
Re: Repath xrefs with new path
« Reply #28 on: July 21, 2006, 12:01:48 PM »
Try this Gary.

Code: [Select]
(defun c:RepathXref (/ *error* OldPath NewPath DwgList dbxApp Opened)

(defun *error* (msg)

(prompt (strcat "\n  Error--> " msg))
(if Opened
 (close Opened)
)
(if dbxApp
 (progn
  (vlax-release-object dbxApp)
  (setq dbxApp nil)
 )
)
)
;-------------------------------------------------------------------------------------------
(defun Directory-Dia ( Message / sh folder folderobject result)
;; By Tony Tanzillo
;; Modified by Tim Willey

  (vl-load-com)
  (setq sh
     (vla-getInterfaceObject
        (vlax-get-acad-object)
        "Shell.Application"
     )
  )


  (setq folder
     (vlax-invoke-method
         sh
         'BrowseForFolder
         (vla-get-HWND (vlax-get-Acad-Object))
         Message
         0
      )
  )
  (vlax-release-object sh)


  (if folder
     (progn
        (setq folderobject
           (vlax-get-property folder 'Self)
        )
        (setq result
           (vlax-get-property FolderObject 'Path)
        )
        (vlax-release-object folder)
        (vlax-release-object FolderObject)
        (if (/= (substr result (strlen result)) "\\")
          (setq result (strcat result "\\"))
          result
        )
     )
  )
)
;----------------------------------------------------------------------------
(defun RePathXref (Doc OldPath NewPath / SaveChanges OldDir DwgName)

(vlax-for Lo (vla-get-Layouts Doc)
 (vlax-for Obj (vla-get-Block Lo)
  (if
   (and
    (= (vla-get-ObjectName Obj) "AcDbBlockReference")
    (vlax-property-available-p Obj 'Path)
    (setq OldDir (strcat (vl-filename-directory (vla-get-Path Obj)) "\\"))
    (setq DwgName (strcat (vl-filename-base (vla-get-Path Obj)) ".dwg"))
    (or
     (= (strcat OldDir) (strcase OldPath))
     (= (strcase OldDir) (strcase OldPath))
    )
   )
   (progn
    (vla-put-Path Obj (strcat NewPath DwgName))
    (write-line (strcat "  Xref name: " (vla-get-Name Obj)) Opened)
    (write-line (strcat "    Xref path " (vla-get-Path Obj)) Opened)
    (setq SaveChanges T)
   )
  )
 )
)
(if SaveChanges
; (SaveAsEx (vla-get-FullName Doc))
 (vla-SaveAs Doc (vla-get-FullName Doc))
)
)
;-----------------------------------------------------------------------------------

(if
 (and
  (setq OldPath (Directory-dia "Select OLD path of drawings."))
  (setq NewPath (Directory-dia "Select NEW path for drawings."))
  (setq DwgList (vl-directory-files NewPath "*.dwg" 1))
  (setq dbxApp
   (if (< (atoi (setq oVer (substr (getvar "acadver") 1 2))) 16)
    (vla-GetInterfaceObject (vlax-get-acad-object) "ObjectDBX.AxDbDocument")
    (vla-GetInterfaceObject (vlax-get-acad-object) (strcat "ObjectDBX.AxDbDocument." oVer))
   )
  )
  (setq Opened (open (strcat NewPath "RepathXref.txt") "a"))
 )
 (foreach Dwg DwgList
  (setq SaveChanges nil)
  (if (vl-catch-all-error-p (vl-catch-all-apply 'vla-Open (list dbxApp (strcat Newpath Dwg))))
   (write-line (strcat "\n+++ Could not open \"" NewPath Dwg "\"") Opened)
   (progn
    (write-line (strcat " - Drawing \"" NewPath Dwg "\" report") Opened)
    (RePathXref dbxApp OldPath NewPath)
   )
  )
 )
)
(if Opened
 (progn
  (close Opened)
  (initget "Yes No")
  (if (= (getkword "\n Open log file [<Y>es/No]: ") "No")
   (prompt (strcat "n Log file location: " NewPath "RepathXref.txt"))
   (startapp "notepad.exe" (strcat NewPath "RepathXref.txt"))
  )
 )
)
(if dbxApp
 (progn
  (vlax-release-object dbxApp)
  (setq dbxApp nil)
 )
)
(princ)
)
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 #29 on: July 21, 2006, 12:18:39 PM »
Tim

Command: REPATHXREF
  Error--> ActiveX Server returned the error: unknown name: FullName
Command:

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