Jump to content

Change XREF Name with specific pattern


pouicpouic

Recommended Posts

Hi,

 

I've got 100 files. Each file has got 300ish XREFS. Xref's names change every week. Part of the xref's name is constant, other part changes. Ex : VISIO_AA_14_A The pattern of this name is VISIO_AA_??_?

 

I would like to :

- 1) Test if the XREF attached is found. If yes -> Nothing.

- 2 ) If not -> Change the xref name with a pattern (exemple : OLD Name : VISIO_AA_14_A New name : VISIO_AB_22)

 

I try jokers : (? or *). With Autocad, it's impossible.

 

The Xrefs files are in the same directory. They never move.

 

Have you got any suggestions?

 

Thanks

Edited by pouicpouic
Link to comment
Share on other sites

Welcome to CADTutor .

 

Your explanations weren't that clear to me at least , so you want to rename back the External Reference as it was before or detach it and reload the new one ?

 

You have given one example of the new name , How should the program know that the old name of this External Reference was so ?

Link to comment
Share on other sites

Hi,

 

I would like to rename back the External Reference with the new name (main exemple : my external reference has a date of the last edition including name of the files).

 

The programme can know the new name of the External Reference if I indicate a pattern with jokers (VISIO_A?_??)

 

My first idea was to link a Xref with a pattern (only few part of the externeral reference names changes). But Autocad doesn't support jokers.

 

So, I don't see how can I do.

Link to comment
Share on other sites

First I don't know what you mean by Jokers ?

Second, there must be a criteria to build the program based on it to rename External files otherwise things would be mixed up .

Link to comment
Share on other sites

Hi,

 

A joker is a wildcard https://en.wikipedia.org/wiki/Wildcard_character

 

A criteria can be a pattern : I prefer to link for example : X_00_00_* in Autocad.

I don't want to link : X_00_00_2014-52-22 and change every day my External Files.

 

I am looking for a way to explain :

 

This file : X_00_00_2014-10-10 has X_00_00_? as pattern. Change the File to have the correct file if you can't find it.

Link to comment
Share on other sites

Methinks you'd do well to instead adopt an 'active' reference methodology, where the documents to be referenced always remain the same name (i.e., X_00_00.dwg).

 

Only when changes are needed is X_00_00.dwg is saved as X_00_00_.dwg, and then are the appropriate changes made to X_00_00.dwg file.

 

Cheers

Link to comment
Share on other sites

Methinks you'd do well to instead adopt an 'active' reference methodology, where the documents to be referenced always remain the same name (i.e., X_00_00.dwg).

 

Only when changes are needed is X_00_00.dwg is saved as X_00_00_.dwg, and then are the appropriate changes made to X_00_00.dwg file.

 

Cheers

 

Definitely agree with you.

 

The bad point, this is a customer methodology. I can't master the way how we manage the external reference names.

Link to comment
Share on other sites

The bad point, this is a customer methodology. I can't master the way how we manage the external reference names.

 

That's unfortunate.

 

Clients, like ourselves, don't know what they don't know... The only thing one could attempt, if not having done so already, is to posit this methodology to the technical lead for the client in a 'hey, I was just curious...' approach.

 

They pay you (err.. your employer), to do the best possible work for them you can, and clients want the most bang for buck (i.e., time is money)... Were you to suggest this, and demonstrate the time savings gained as a result, they just might be inclined to adopt the suggestion.

 

Should they choose to not adopt, despite the time saved, then you have no choice but to adhere... And whomever made that decision on behalf of the client is a w@nker, and should be replaced, so long as they're not also the owner, in which case they default back to just being a w@nker. :rofl:

 

 

 

... My $0.02

Link to comment
Share on other sites

Hi,

 

I found this link :

 

But it is a find-rename fonction.

 

I just need a way to use wildcards in Xref names.

 

@blackbox

You forgot when you are just a designer... So, you dont' directly talk to the customer and have boring session of Xref rename files... They work like that for a long time, ad they don't want to change.

Link to comment
Share on other sites

Hi,

 

I found this link but it is a find/replace fonction in Lisp.

 

Is it a way to use wildcards in Xref Names or change the name with a pattern?

 

If I can't find a XREF, Autocad has to search the other files if I indicate a pattern with wildcards.

 

I am just a designer, my client won't change his methodoly. They're working like that for so many years, so my job will be so boring (80% of my time is changing the name of the Xref)

 

Fred

Link to comment
Share on other sites

Hi fred,

 

as a starting point, and using your exemple

 

'This file : X_00_00_2014-10-10 has X_00_00_? as pattern. Change the File to have the correct file if you can't find it.'

 

perhaps something like this:

 

(vl-load-com)
(defun c:demo (/ base file files name nbase pat pos)
 (vlax-For blk
               (vla-Get-Blocks (vla-Get-ActiveDocument (vlax-Get-Acad-Object)))
   (if (and (= (vla-Get-IsXref blk) :vlax-True)
            (/= (vl-string-search "." (setq file (vla-get-path blk))) 0)
            (not (findfile file))
       )
     (progn
       (setq path  (vl-filename-directory file)
             base  (vl-filename-base file)
             pos   (vl-string-position (ascii "_") base nil T)
             name  (substr base 1 (1+ pos))
             files (vl-directory-files path "*.dwg" 1)
       )
       (foreach x files
         (if (wcmatch x (strcat name "*"))
           (setq nbase x)
         )
       )
       (if nbase
         (progn
           (vl-catch-all-error-p
             (vl-catch-all-apply
               '(lambda () (vla-put-Name blk (vl-filename-base nbase)))
             )
           )
           (vla-put-path blk (strcat path "\\" nbase))
           (vla-reload blk)
         )
       )
     )
   )
 )
 (princ)
)

Hope that helps

Henrique

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...