Visual LISP, AutoLISP and General Customization
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Xref relative path Lisp

15 REPLIES 15
Reply
Message 1 of 16
Anonymous
10115 Views, 15 Replies

Xref relative path Lisp

Hey guys,

 

Because we soon going to change our server, all our path will change and so I'm trying to set all my xref-path from absolute to relative path.

I already searched the web for a soultion, but didn't find any good ones, that would help me.

 

I'd like to do this with lisp, so everytime I open a file it runs this and checks if it and changes the path to relative.

I don't know if there is a easier way to do this for many files at once without opening them...maybe with the referencemanager?

 

thanks for your help guys!

klingi

15 REPLIES 15
Message 2 of 16
David.Pullin
in reply to: Anonymous

I'm using 2014, and this works:

 

command line:

-xr;T;*:R;

 

I don't think the pathtype was this easily changed before 2014 though.

 

That would set all of the xrefs to a relative path in the given file.  Keep in mind that this would not "fix" your nested references.  You could set this as a button with a macro, or create a stand alone lisp. This function could maybe be added to your acaddoc.lsp so that it runs when you open the file but I'm not sure.  I don't like things like to run without my specific input, as there will inevitably be files that you don't want updated.

 

Another option, that I have no experience with, would be to run a script on your files to fix this all in an automated fashion.

 

 

Message 3 of 16
Anonymous
in reply to: David.Pullin

Thank you,

I know that command from acad2014, but we mostly use 2010 and there it doesn't have this solution built in.

So I guess I would need to work with a automated script the runs over all file... Smiley Frustrated

or at least a Lisp the runs everytime I open a file...

Message 4 of 16
hmsilva
in reply to: Anonymous

Hi klingi,

using AC2010, occur to me two options for accomplish that task...

Please note that the codes are quick and dirty, and were written only to demonstrate a way to accomplish that task...

 

FULLY UNTESTED!!!

I don´t have AutoCAD in this laptop...

Is advisable to create a dwg's set for testing purposes!

 

In both options I use Lee Mac's LM:XRef:Full->Relative routine to create the relative path string.

 

First option:

using a script file with a call to a routine that will change the path, and to process multiple dwg's you can use Autodesk ScriptPro (it's free).

The code is the attached rpath.lsp if the code is pre-loaded (via acaddoc.lisp, or with a load function) the script file can be as simple as:

rpath

<<<< empty line

 

Second option:

Using ObjectDBX.

Please pay attention that using ObjectDBX environment, the dwg's will lose the preview thumbnail...

To run the attached rpath1.lsp, open a new dwg and run de rpath1, ensuring that none of dwg's to processing is open, the code will process an entire directory.

 

I would prefer the first option!

HTH

Henrique

EESignature

Message 5 of 16
Anonymous
in reply to: hmsilva

Thanks henrique,

 

I already came across Lee's script will searching trough the net, but didn't get it work.

 

Now I tried your first method, which already runs over the selected test files with the lisp inclueded, but doesn't seam to work properly:

; error: no function definition: LM:XREF:FULL->RELATIVE

 

any clue what I'm doing wrong?

cheers Klingi

Message 6 of 16
hmsilva
in reply to: Anonymous

Sorry Klingi,

my previous rpath.lsp had a typo...Smiley Embarassed

Try the attached one.

 

HTH

Henrique

EESignature

Message 7 of 16
Anonymous
in reply to: hmsilva

next problem! 😉

error: to many arguments

 

I tried to run the Lisp without the script to test it, but it didn't work...

Message 8 of 16
hmsilva
in reply to: Anonymous

This side. without errors...

 

Command: appload
rpathV01.LSP successfully loaded.

 Command: RPATH

_.qsave

Command:

 

Henrique

EESignature

Message 9 of 16
Anonymous
in reply to: hmsilva

hmm...

 

I'm going to test it and try to figure out my problem.

thanks for now henrique. Smiley Happy

Message 10 of 16
Anonymous
in reply to: hmsilva

Hi-

Any chance this is working? I have an issue where all of our xrefs are full path but need to be switched all over to relative.

 

I would love some help on this if possible.

 

UPDATED:It seems like rpath is working, but only after xref's are reloaded. ANy way to automate this?

 

THanks in advance.

Message 11 of 16
john.uhden
in reply to: Anonymous

Attached is my X-PATH.lsp, which will remove absolute paths from both Xrefs and Images if they are found anywhere in the AutoCAD search path, which includes the current drawing's path.  It has both error and undo controls.

 

I personally think that xrefs should reside with their parent drawings.  That's why I wrote it.

 

After loading, use the command either X-PATH or X-P.

 

 

John F. Uhden

Message 12 of 16
Anonymous
in reply to: john.uhden

Hello John,

sorry. It's not working.


@john.uhden wrote:

Attached is my X-PATH.lsp, which will remove absolute paths from both Xrefs and Images if they are found anywhere in the AutoCAD search path, which includes the current drawing's path.  It has both error and undo controls.

 

I personally think that xrefs should reside with their parent drawings.  That's why I wrote it.

 

After loading, use the command either X-PATH or X-P.

 

 


 

Message 13 of 16
john.uhden
in reply to: Anonymous

Could you please describe the symptoms that represent in what way(s) it is not working?  Perhaps an error message?

John F. Uhden

Message 14 of 16
Edwin.Saez
in reply to: john.uhden

@john.uhden,

 

The lisp that you attached does not work.

 

Command: X-PATH
0 xrefs repathed

 

only that message comes out, and it does not change any absolute path to relative XREFs.

Edwin Saez


LinkedIn / AutoCAD Certified Professional


EESignature



 


Si mi respuesta fue una solución para usted, por favor seleccione "Aceptar Solución", para que también sirva a otro usuarios.

Message 15 of 16
john.uhden
in reply to: Edwin.Saez

In post #7 I wrote, "Attached is my X-PATH.lsp, which will remove absolute paths from both Xrefs and Images if they are found anywhere in the AutoCAD search path, which includes the current drawing's path."

 

So if the xrefs were not "found anywhere in the AutoCAD search path, which includes the current drawing's path," then it will not change their paths.

 

Might it be that you have xrefs scattered around and that you want them to be located in the same folder as the current drawing?  That can be done but it would require either copying or moving the xref to the current drawing's folder.  My X-PATH routine was not written to do that.

John F. Uhden

Message 16 of 16
paullimapa
in reply to: Edwin.Saez

You can also try this one which I found and written by: Mark McDonough

 

 

Area Object Link | Attribute Modifier | Dwg Setup | Feet-Inch Calculator
Layer Apps | List on Steroids | VP Zoom Scales | Exchange App Store


Paul Li
IT Specialist
@The Office
Apps & Publications | Video Demos

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report

”Boost