Jump to content

Recommended Posts

Posted

Hi friends

I need LISP to change xref (from one folder to another folder - location path change) in all drawings at time. some times my copied folder (xref) shown in older xref, All dwgs very difficult to change from (found at) xref dialog box.

Advance thanks

venki

Posted

I'm using acad2004 only.pls send LISP urgent,bcoz I need to change 82 dwgs

 

thanks

Posted

pls find the xref LISP error.i attached the image file.I need to change the xref from the server folder

 

thanks

xref issue.jpg

Posted (edited)

See if this works for you

 

UPDATED

(defun c:FindMe (/ LM:FindFile Blks blk NewPath XrefFile)
(vl-load-com)
(defun LM:FindFile ( file directory )
 (cond
   ( (findfile (strcat (setq directory (vl-string-right-trim "\\" directory)) "\\" file)) )
   (
     (vl-some
       (function
         (lambda ( dir )
           (LM:FindFile file (strcat directory "\\" dir))
         )
       )
       (vl-remove "." (vl-remove ".." (vl-directory-files directory nil -1)))
     )
   )
 )
)      
(setq Blks (vla-get-blocks (vla-get-activedocument (vlax-get-acad-object))))      
(while (setq blk (tblnext "block" (not blk)))
     (if (and [color=blue][b](= 4 (logand 4 (cdr (assoc 70 blk))))
[/b][/color]               (setq NewPath
                         (LM:FindFile
                               (strcat (cdr (assoc 2 blk))
                                       ".dwg")
                              [b][color=blue] "Y:\\VENKI\ST11\\"[/color][/b]))
              )
           (progn (setq XrefFile (vla-item Blks (cdr (assoc 2 blk))))
                  (vla-put-path XrefFile NewPath)
                  (vla-reload XrefFile))
           )
     )
     )     

 

The container folder is where the code will look for the existing Xref Name on your drawing. Xref name should be the same name as before and only the path is different.

 

kudos to LeeMac for LM:FindFile routine

Edited by pBe
Update Code
Posted
See if this works for you

 

(defun c:FindMe (/ LM:FindFile Blks blk NewPath XrefFile)
(vl-load-com)
(defun LM:FindFile ( file directory )
 (cond
   ( (findfile (strcat (setq directory (vl-string-right-trim "\\" directory)) "\\" file)) )
   (
     (vl-some
       (function
         (lambda ( dir )
           (LM:FindFile file (strcat directory "\\" dir))
         )
       )
       (vl-remove "." (vl-remove ".." (vl-directory-files directory nil -1)))
     )
   )
 )
)      
(setq Blks (vla-get-blocks (vla-get-activedocument (vlax-get-acad-object))))      
(while (setq blk (tblnext "block" (not blk)))
     (if (and (or (= (cdr (assoc 70 blk)) 12)
                  (= (cdr (assoc 70 blk)) 4))
              (setq NewPath
                         (LM:FindFile
                               (strcat (cdr (assoc 2 blk))
                                       ".dwg")
                               [color=blue]"P:\\SERVER_PATH\\CONTAINER_FOLER\\"[/color]))
              )
           (progn (setq XrefFile (vla-item Blks (cdr (assoc 2 blk))))
                  (vla-put-path XrefFile NewPath)
                  (vla-reload XrefFile))
           )
     )
     )

 

The container folder is where the code will look for the existing Xref Name on your drawing. Xref name should be the same name as before and only the path is different.

 

kudos to LeeMac for LM:FindFile routine

 

 

 

 

******************************

 

Good evening!

 

Still ur Lisp not working, waht I need to change xref in drawing new folder

I attached the dwg (procedure) for ur reference that need to me.

 

thanks

venki

xref path issue.dwg

Posted (edited)

Did you change this

"P:\\SERVER_PATH\\CONTAINER_FOLER\\"

to

"Y:\\VENKI\ST11\\"

EDIT: I just thought of something, The Xref is currently on the drawing but you want to repath?

And theres me thinking the XREF is not found hence (= (cdr (assoc 70 blk)) 12)

See Updated CODE

 

 

AND Since you know where the files are located:

 

[color=blue][b](defun c:FindMe  (/ Blks blk pth XrefFile)
     (vl-load-com)
     (setq Blks (vla-get-blocks
                      (vla-get-activedocument
                            (vlax-get-acad-object))))[/b][/color]
[color=blue][b]      (while (setq blk (tblnext "block" (not blk)))
           (if (and (= 4 (logand 4 (cdr (assoc 70 blk))))
                    (wcmatch
                          (setq cp (cdr (assoc 1 blk)))
                          "*\\VENKI\\ST10*")
                    )
                 (progn (setq fn (fnsplitl cp))
                        (vl-mkdir
                              (setq pth  (strcat (vl-string-subst
                                                       "ST11"
                                                       "ST10"
                                                       (car fn)))))
                        (vl-file-copy
                              cp
                              (setq pth (strcat pth
                                                (cadr fn)
                                                (caddr fn))))
                        (setq XrefFile
                                   (vla-item
                                         Blks
                                         (cdr (assoc 2 blk))))
                        (vla-put-path XrefFile pth)
                        (vla-reload XrefFile))
                 )
           )
     )[/b][/color]

 

Otherwise use the first code to dig into sub folders.

 

EDIT:

Code Updated: to include file copy.

Edited by pBe
vl-file-copy
Posted
Did you change this

"P:\\SERVER_PATH\\CONTAINER_FOLER\\"

to

"Y:\\VENKI\ST11\\"

 

 

EDIT: I just thought of something, The Xref is currently on the drawing but you want to repath?

And theres me thinking the XREF is not found hence (= (cdr (assoc 70 blk)) 12)

 

See Updated CODE

 

AND Since you know where the files are located:

 

(defun c:FindMe  (/ Blks blk NewPath XrefFile)
     (vl-load-com)
     (setq Blks (vla-get-blocks
                      (vla-get-activedocument
                            (vlax-get-acad-object))))
     (while (setq blk (tblnext "block" (not blk)))
           (if (and (= 4 (logand 4 (cdr (assoc 70 blk))))
                    (wcmatch
                          (setq cp (cdr (assoc 1 blk)))
                          "*\\VENKI\\ST10*")
                    (setq NewPath
                               (findfile
                                     (vl-string-subst
                                           "ST11"
                                           "ST10"
                                           cp)))
                    )
                 (progn (setq XrefFile
                                   (vla-item
                                         Blks
                                         (cdr (assoc 2 blk))))
                        (vla-put-path XrefFile NewPath)
                        (vla-reload XrefFile))
                 )
           )
     )

 

Otherwise use the first code to dig into sub folders.

 

 

 

*************************

Hi

Good evening!

 

I appreciated to spend the time for this issue, sorry to say still can’t work. I would checked what u send latest updated LISP followed by server path folder ST11

"Y:\\VENKI\ST11\\"))

below error displayed & I attached last updated lisp from you

command: findme

findme nil

ok again I explain.i need to copy my ST10 folder into ST11 in same server, that inside folder drawings (ST11) need to show xref in same folder (ST11).

 

 

 

Thanks

venki

Findme.lsp

Posted

i have similar problem, there is a folder in server. Im copying this folder to my desktop. I open the main file, and i see the paths are still on server, i want to change all paths as my desktop. is there any way to do it? thank you all!

Posted
i have similar problem, there is a folder in server. Im copying this folder to my desktop. I open the main file, and i see the paths are still on server, i want to change all paths as my desktop. is there any way to do it? thank you all!

By using Reference Manager program it comes with AutoCAD

Posted
By using Reference Manager program it comes with AutoCAD

 

thank you asos2000, i wouldn't know this.

Posted

Hello! friends

Attached LISP I collected from lisp site, this one excellent works for my xref path change (replace another xref) in copied folder, but the problem is I need to open all dwgs and replaced xref one by one, this one also take so much of time .pls anyone to change this LISP to apply all drawings (64 dwgs) in folder. My xref file name CHI-TBLK in old folder ST10 and new folder ST11. Now I need to change my xref in new folder ST11 (after copy my folder ST10 into ST11 xref path shown in ST10.

My working folder…server

I need to change xref @

Y:\venki\ST11

This is very urgent

Thanks

venki

replace xref.lsp

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...