Author Topic: Xref path to DOT DOT  (Read 5690 times)

0 Members and 1 Guest are viewing this topic.

VerticalMojo

  • Guest
Xref path to DOT DOT
« on: March 26, 2004, 03:58:46 PM »
I wanted to know if there is a lisp that can change all my xref paths.

example....


H:\Working Drawings\AD\Xref\FP-002.dwg

to

..\Xref\FP-002.dwg

leaving two periods before the slash....... And would be awsome if it did it to all the xrefs........

If its a big deal no proplem but It would be nice to know....

And yes, I have access to the Full Version of AutoCAD.

Thanks dude.... 8)

Keith™

  • Villiage Idiot
  • Seagull
  • Posts: 16899
  • Superior Stupidity at its best
Xref path to DOT DOT
« Reply #1 on: March 26, 2004, 04:39:55 PM »
Lemme see what I have..... I think I may have something like that...
Proud provider of opinion and arrogance since November 22, 2003 at 09:35:31 am
CadJockey Militia Field Marshal

Find me on https://parler.com @kblackie

VerticalMojo

  • Guest
Xref path to DOT DOT
« Reply #2 on: March 26, 2004, 04:41:57 PM »
Keith you rock :dood:

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
Xref path to DOT DOT
« Reply #3 on: March 26, 2004, 04:51:45 PM »
Keith probably has something better :) , but here are some I scavenged.

Code: [Select]
(defun C:REPATH ()
 (setq xrpmod nil)
 (setq xrefedblock (tblnext "block" t))
 (while xrefedblock
  (if (assoc 1 xrefedblock)
   (progn
    (if (WCMATCH (cdr (assoc 1 xrefedblock)) "*\\*")
    (progn
     (setq Path (cdr (assoc 1 xrefedblock)))
     (setq stringPosition (strlen path))
     (setq stringTest "*")
     (while (/= stringTest (chr 92))
     (setq stringTest (substr path stringPosition 1))
     (setq stringPosition (1- stringPosition))
     );while
     (setq stringPosition (+ stringPosition 2))
     (setq newpath (substr path stringPosition))
     (command "-xref" "p" (cdr (assoc 2 xrefedblock)) newpath)
     (setq xrpmod 1)
    ); progn
    ); if
   ); progn
  ); if
  (setq xrefedblock (tblnext "block"))
 ); While

 (if xrpmod (Alert "Some xrefs have been repathed."))
)



(defun c:Xrpath (/ BLKNAM CNT XNAME)
(prompt "\n[X-REPATH] - Strips all Xref paths.")
(prompt "\nX-REPATH Working... please wait ")

(setq CNT 1)
(while (setq BLKNAM (tblnext "BLOCK" CNT))
(setq CNT nil)
(if (and (/= (assoc 1 BLKNAM) nil)
(> (- (strlen (cdr (assoc 1 BLKNAM))) 4)
(strlen (cdr (assoc 2 BLKNAM)))
)
)
(command ".xref" "path" (cdr (assoc 2 BLKNAM)) (cdr (assoc 2 BLKNAM)) )
)
)
(prompt "\nX-REPATH Done! ")
(princ)
)


;;; To replace drive letter in xref path
;;; It can be modified to change any portion of the path
;;; Drawings must exist on the target drive/directory
;;; Requires (ai_table) function - it is in the file AI_UTILS.LSP
;;; in the ..\support directory
;;;(xrefdrive "x:")
(defun c:repath () ;;(newdrive / xref)
  (setq newdrive (getstring "\nEnter new drive for all xrefs: "))
  (mapcar '(lambda (x)
     (if (eq (logand 4 (cdr (assoc 70
        (setq xref (entget (tblobjname "block" x))))))
        4)
  (command "._xref" "path" (cdr (assoc 2 xref))
  (strcat newdrive (substr (cdr (assoc 3 xref)) 3)))))
  (ai_table "block" 0))
 (princ)
)
I've reached the age where the happy hour is a nap. (°¿°)
Windows 10 core i7 4790k 4Ghz 32GB GTX 970
Please support this web site.

Keith™

  • Villiage Idiot
  • Seagull
  • Posts: 16899
  • Superior Stupidity at its best
Xref path to DOT DOT
« Reply #4 on: March 26, 2004, 10:59:32 PM »
Well, I searched high and low....you spoke too soon....

What I found was a utility that would rename an xref from one name to another...essentially keeping the same path intact, ,but referencing updated files.

For posterity sake here it is...

Code: [Select]

;;;   XREFREN.LSP
;;;   Copyright (C) 2001 BCI Computer Solutions
;;;
;;;   Written by:
;;;   BCI Computer Solutions
;;;   2031 S.W. Fallon Lane
;;;   Lake City FL. 32025
;;;   United States
;;;
;;;   (386)755-3831
;;;   (386)867-0430
;;;   draftsman@se.rr.com
;;;
;;;   Author:  K.E. Blackie
;;;   Date: 11 June 2001
;;;
;;;
;;;   THIS SOFTWARE IS PROVIDED "AS IS" WITHOUT EXPRESS OR IMPLIED
;;;   WARRANTY.  ALL IMPLIED WARRANTIES OF FITNESS FOR ANY PARTICULAR
;;;   PURPOSE AND OF MERCHANTABILITY ARE HEREBY DISCLAIMED.
;;;
;;;
;;;
;;;
;;;
;;;   11 Jun 2001      -- initial development
;;;   19 Jun 2001      -- changed search from friendly name to explicit path and name
;;;
;;;----------------------------------------------------------------------------
;;;   DESCRIPTION
;;;----------------------------------------------------------------------------
;;;   C:XREFREN
;;;
;;;   This function reassociates an existing xref with a new xref in the
;;;   same path as the original xref entity. This is useful in renaming
;;;   xref blocks when the xref name must be modified.
;;;
;;;----------------------------------------------------------------------------
;;; Main function

(defun C:XREFREN (/ oce) ;define main function
  (setq oce (getvar "cmdecho")) ;save current cmdecho state
  (setvar "cmdecho" 0) ;turn cmdecho off
  (setq arg1 (getstring "\nOld xref name: ") ;obtain old xref name
arg2 (getstring "\nNew xref name: ") ;obtain new xref name
  );setq
  (xrefren arg1 arg2) ;call function to modify table
  (setvar "cmdecho" oce) ;reset cmdecho to original setting
  (princ) ;finish nice and pretty
);defun

;;;----------------------------------------------------------------------------

(defun xrefren (arg1 arg2 / filt inslist ndx newname refname refpath newarg1
reftype sset) ;define subfunction and localize variables
  (setq refname (look_for arg1))
;see if old xref is in drawing
  (if refname ;if it is
    (progn ;then do these things as if they were one function
      (setq newarg1 (cdr (assoc 2 refname)))
      (setq reftype (cdr (assoc 70 refname)))
;get the type of block entry
      (if (< 3 reftype) ;if it is indeed an xref and not a regular block
(setq refpath (substr (cdr (assoc 1 refname))
;extract the path where it is
     1 ;from the first few characters of the full path
     (+ (- (strlen (cdr (assoc 1 refname)))
;and remove
   (strlen arg1)
   ;(strlen (cdr (assoc 2 refname)))
;the extension
   4 ;which is the last four characters
);-
     );+
     );substr
     newname (strcat refpath arg2) ;create new name w/old path
);setq
      );if
      (setq filt (list (cons 2 newarg1)));set a filter to select only the old xrefs
      (setq sset (ssget "x" filt))      ;then select them
;      (princ newname)
      (if (not (findfile (strcat newname ".dwg")))
;if we cannot find the new xref in the same path
(progn ;treat the following as one command and....
 (princ (strcat "\nNew xref " arg2 " not found"))
;alert the user
 (setq sset nil) ;then clear the selection set to prevent an error
);progn
      );if
      (if sset ; if we have a selection set, then we know the path and new xref is valid
(progn ; so lets do the following as one command on the group
 (command "xref" "A" newname "0,0" "" "" "")
;associate the new xref to the drawing at 0,0
 (command "erase" (entlast) "");erase it because we only needed to have it in the table
 (setq ndx 0) ;set up a zeroed index counter
 (repeat (sslength sset) ;and repeat the follwing by the number of old xrefs we selected
   (setq inslist (entget (ssname sset ndx)))
;get the entity list of the indexed xref
   (entmod (subst (cons 2 arg2) (assoc 2 inslist) inslist))
;replace the old xref with the new one and modify the entity
   (setq ndx (1+ ndx)) ;increment the counter
 );repeat
);progn
      );if
      (if sset
(progn
          (princ "\nCompleted reassociation of ")
          (princ (rtos (fix (sslength sset))2 0))
 (if (= (sslength sset) 1)
   (princ " xref")
            (princ " xrefs")
 );if  
        );progn
      );if
    );progn
  );if
);defun

;;;----------------------------------------------------------------------------
;;; subfunction look_for
;;; returns list data of an xref table entry from its path, returns nil if
;;; not found

(defun look_for( block / bn found ndx refname rval rval1 ) ;define subroutine
  (setq bn (tblnext "block" t))          ;find block table entry
  (while bn                              ;if we have one, then test it
    (setq found nil)                     ;make sure we don't have anything in found
    (if (setq refname (cdr (assoc 1 bn)));extract the path data
      (progn                             ;then as a single command
        (setq ndx (strlen refname))      ;initialize the counter to the length of the path
        (while (not found)               ;until we find 'found'
          ;read one character at a time and test it starting from the last one first
   (setq rval (substr refname ndx 1))
 (if (= "\\" rval)              ;if we find a path separator
   (progn                       ;execute all of the following
     (setq found (substr refname (1+ ndx)(- (strlen refname) ndx)));extract the name
     (setq found (substr found 1 (- (strlen found) 4)));then remove the extension
   );progn
 );if
          (setq ndx (1- ndx))            ;decrement the counter
 (if (= ndx 0)                  ;if we have reached 0 in our counter
   (setq found T)               ;we haven't found the a true xref so lets keep going
 );if
        );while
      );progn
    );if
    (cond                                ;test the value of found now
;if we placed a marker to break the loop then continue
      ((= found T)(setq bn (tblnext "block")))
      ((= found nil)(setq bn (tblnext "block"))); if there is no found continue
                                ;if we have found the right one break out and notify the user
      ((= (strcase found)(strcase block))(princ (strcat "\nFound Reference: " found))(setq rval1 bn)(setq bn nil))
      (t (setq bn (tblnext "block"))) ;we have something but not what we want so continue
    );cond
  );while
  rval1                               ;explicit return of matching xref list data
);defun


(princ "\n ----- XREFREN ----- Xref Reassociation Utility Ver. 1.0 --> XREFREN to start ")

Proud provider of opinion and arrogance since November 22, 2003 at 09:35:31 am
CadJockey Militia Field Marshal

Find me on https://parler.com @kblackie

pmvliet

  • Guest
Xref path to DOT DOT
« Reply #5 on: March 28, 2004, 05:07:17 PM »
I use to use xpath which is in 2002. Someone tolde me about the extensions that came with 2002 and there is a program called Reference manager. In 2004 it gets installed with the load.
It seems pretty powerful and I have started to use it. It will repath fonts, plotters, reference files, images...

pieter
(still learning it)

ronjonp

  • Needs a day job
  • Posts: 7527
Xref path to DOT DOT
« Reply #6 on: March 29, 2004, 12:43:11 PM »
I have used a program called xRepath. It is not free but it works and it is very very fast. It changes the paths without opening the drawings!? The trial version will let you do 5 drawings at a time.

Check it out:  http://www.intelcad.com/pages/xrepath/

Ron :D

Windows 11 x64 - AutoCAD /C3D 2023

Custom Build PC

SMadsen

  • Guest
Xref path to DOT DOT
« Reply #7 on: April 01, 2004, 06:18:34 AM »
With 2004 came the Reference Manager (on the bonus (?) CD). It's a standalone and it's great for changing paths.

hyposmurf

  • Guest
Xref path to DOT DOT
« Reply #8 on: April 01, 2004, 07:14:39 AM »
Thats first thing I thought dont you use the XREF Manager but I guess as Mojo's on LT he doesnt have that nice facility.

SMadsen

  • Guest
Xref path to DOT DOT
« Reply #9 on: April 01, 2004, 07:33:17 AM »
The Reference Manager is standalone and should work for LT as well, shouldn't it? (I'm LT illiterate)
Anyway, VM's signature says AC2002 and I'm not sure it shipped with that version.

pmvliet

  • Guest
Xref path to DOT DOT
« Reply #10 on: April 01, 2004, 06:32:50 PM »
If you have the install CD you need to install the learning assistant portion of it... or so I was told. Then you can download reference manager off of the AutoDesk Website...

Pieter