Author Topic: Finding out which drawings a file is xreffed into  (Read 9328 times)

0 Members and 1 Guest are viewing this topic.

jonesy

  • SuperMod
  • Seagull
  • Posts: 15568
Finding out which drawings a file is xreffed into
« on: August 12, 2008, 10:22:31 AM »
If I have a drawing that is used as a base xref. Is there any way I can find out which drawings use this base drawing as an xref.
I am trying to track which drawings will change when I change this "baseplan" (I think I can do this if we use Projectwise, but I am trying to find out if it can be done without that software)

Many thanks
T :)
Thanks for explaining the word "many" to me, it means a lot.

architecture68-raff

  • Swamp Rat
  • Posts: 599
  • Strange things are afoot at the Circle-K.
Re: Finding out which drawings a file is xreffed into
« Reply #1 on: August 12, 2008, 10:30:19 AM »
I have always used the search function in Design Center.  Change the "Look for" box to xrefs.  Seems to work fine for me.

I have seen others do it in VBA as well.
Chicago, Illinois
ADT 2005, Revit Architecture 2009, Sketchup 7

jonesy

  • SuperMod
  • Seagull
  • Posts: 15568
Re: Finding out which drawings a file is xreffed into
« Reply #2 on: August 12, 2008, 11:10:13 AM »
I have always used the search function in Design Center.  Change the "Look for" box to xrefs.  Seems to work fine for me.

I have seen others do it in VBA as well.
Andy,
Thanks for your reply, I had great hopes that this would work for me, but I must be doing something wrong as I cannot get it to find any xrefs if I pick xrefs in the pulldown box... :(
Thanks for explaining the word "many" to me, it means a lot.

Gliderider

  • Guest
Re: Finding out which drawings a file is xreffed into
« Reply #3 on: August 12, 2008, 11:43:52 AM »
It's hasn't failed me yet, are you searching as  illustrated?

New Shooz

  • Guest
Re: Finding out which drawings a file is xreffed into
« Reply #4 on: August 12, 2008, 11:47:59 AM »
This was a request of mine over @ CADTutor; and I got a lot of help from LCE at the time. He said it was still in development, as he was trying to add support for images/OLE's/etc.
Not heard anything of it in the past month however

jonesy

  • SuperMod
  • Seagull
  • Posts: 15568
Re: Finding out which drawings a file is xreffed into
« Reply #5 on: August 12, 2008, 11:54:36 AM »
It's hasn't failed me yet, are you searching as  illustrated?
Yes that is how I was searching. I did find (with blocks) that it wasnt searching the sub-directories, even tho the box was ticked. If I can get to work this out, it will be a great help to me, so I will carry on "playing"
Thanks for explaining the word "many" to me, it means a lot.

T.Willey

  • Needs a day job
  • Posts: 5251
Re: Finding out which drawings a file is xreffed into
« Reply #6 on: August 13, 2008, 11:32:27 AM »
I have a lisp that i can post if you still need it.  I would have to find all the subs, so if its not needed I won't go through the trouble.   :-)
Tim

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

Please think about donating if this post helped you.

jonesy

  • SuperMod
  • Seagull
  • Posts: 15568
Re: Finding out which drawings a file is xreffed into
« Reply #7 on: August 13, 2008, 01:49:36 PM »
I have a lisp that i can post if you still need it.  I would have to find all the subs, so if its not needed I won't go through the trouble.   :-)
Thanks Tim

If you have the time, it would be much appreciated... but the critical drawing has been sorted. However, I know I'm going to have more of these to do in the future.

(in other words... no rush, but I would like to try it at some point)
Thanks for explaining the word "many" to me, it means a lot.

T.Willey

  • Needs a day job
  • Posts: 5251
Re: Finding out which drawings a file is xreffed into
« Reply #8 on: August 13, 2008, 03:03:31 PM »
This should work.  I just did a quick rewrite, and did some quick tests, so if it doesn't let me know.  Dialog is attached.

Code: [Select]
(defun c:XrefFind (/ *error* FindXrefs CkStr DirPath DwgList DiaRtn Opened dbxApp oVer tempFile)
   
    (defun *error* (msg)
       
        (if dbxApp (vlax-release-object dbxApp))
        (setq dbxApp nil)
        (if Opened (close Opened))
        (if msg
            (prompt (strcat "\n Error --> " msg))
        )
    )
    ;----------------------------------------------------------
    (defun FindXrefs (doc str / tempName tempList)
       
        (vlax-for i (vla-get-Blocks doc)
            (if
                (and
                    (= (vla-get-IsXref i) :vlax-true)
                    (or
                        (wcmatch (strcase (setq tempName (vla-get-Name i))) (strcase str))
                        (= str "")
                    )
                )
                (setq tempList (cons tempName tempList))
            )
        )
        tempList
    )
    ;-------------------------------------------------
    (defun Directory-Dia ( Message / sh folder folderobject result)
    ;; By Tony Tanzillo
    ;; Modified by Tim Willey
    ;; 16 Will let you type in the path
    ;; 64 Will let you create a new folder

    (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 ; This is the bit number to change.
    )
    )
    (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 MultiSelect (Listof Message Toggle / DiaLoad tmpStr tmpTog tmpList)

    (setq DiaLoad (load_dialog "MyDialogs.dcl"))
    (if (new_dialog "MultiSelect" DiaLOad)
    (progn
    (start_list "listbox" 3)
    (mapcar 'add_list Listof)
    (end_list)
    (if Message
    (set_tile "text1" Message)
    )
    (if (not Toggle)
    (mode_tile "toggle1" 1)
    )
    (mode_tile "listbox" 2)
    (action_tile "accept"
    "(progn
    (setq tmpStr (get_tile \"listbox\"))
    (if Toggle
    (setq tmpTog (get_tile \"toggle1\"))
    )
    (done_dialog 1)
    )"
    )
    (action_tile "cancel" "(done_dialog 0)")
    (if (= (start_dialog) 1)
    (progn
    (if tmpStr
    (setq tmpList (read (strcat "(" tmpStr ")")))
    )
    (if (= tmpTog "1")
    (cons T tmpList)
    tmpList
    )
    )
    )
    )
    )
    )
    ;----------------------------------------------------------------
    (if
        (and
            (setq CkStr (getstring "\n Enter name to check for [*]: "))
            (setq DirPath (Directory-Dia "Select directory to search for xrefs."))
            (setq DwgList (vl-directory-files DirPath "*.dwg" 1))
            (setq DwgList (vl-sort DwgList '(lambda (a b) (< (strcase a) (strcase b)))))
            (setq DiaRtn (MultiSelect DwgList "Select all." T))
            (setq Opened (open (setq tempFile (strcat Dirpath "XrefFindReport.txt")) "w"))
            (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))
                )
            )
        )
        (if (= (type (car DiaRtn)) 'INT)
            (foreach i (mapcar '(lambda (x) (strcat DirPath (nth x DwgList))) DiaRtn)
                (if (vl-catch-all-error-p (vl-catch-all-apply 'vla-Open (list dbxApp i)))
                    (write-line (strcat "++ Error opening file: " i "\n") Opened)
                    (if (setq XrFound (FindXrefs dbxApp CkStr))
                        (progn
                            (write-line (strcat "- " i) Opened)
                            (foreach j XrFound
                                (write-line j Opened)
                            )
                            (write-line "\n" Opened)
                        )
                    )
                )
            )
            (foreach i (mapcar '(lambda (x) (strcat DirPath x)) DwgList)
                (if (vl-catch-all-error-p (vl-catch-all-apply 'vla-Open (list dbxApp i)))
                    (write-line (strcat "++ Error opening file: " i "\n") Opened)
                    (if (setq XrFound (FindXrefs dbxApp CkStr))
                        (progn
                            (write-line (strcat "- " i) Opened)
                            (foreach j XrFound
                                (write-line (strcat "    " j) Opened)
                            )
                            (write-line "\n" Opened)
                        )
                    )
                )
            )
        )
    )
    (prompt (strcat "\n Log file: " tempFile))
    (*error* nil)
    (princ)
)
Tim

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

Please think about donating if this post helped you.

jonesy

  • SuperMod
  • Seagull
  • Posts: 15568
Re: Finding out which drawings a file is xreffed into
« Reply #9 on: August 13, 2008, 03:32:20 PM »
Thanks Tim

I'll take a look when I go to work on Monday (yippeee... I'm done for the week)

Thanks for the VERY quick response

T :-)
Thanks for explaining the word "many" to me, it means a lot.

T.Willey

  • Needs a day job
  • Posts: 5251
Re: Finding out which drawings a file is xreffed into
« Reply #10 on: August 13, 2008, 03:34:16 PM »
Thanks Tim

I'll take a look when I go to work on Monday (yippeee... I'm done for the week)

Thanks for the VERY quick response

T :-)
No far!   :cry:

If you want it to search all drawings in the directory selected, and all drawings in all the sub-directories, then it will need to be changed, but that shouldn't be hard to do if this works as is now.

Have a nice long weekend Tracy.
Tim

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

Please think about donating if this post helped you.

jonesy

  • SuperMod
  • Seagull
  • Posts: 15568
Re: Finding out which drawings a file is xreffed into
« Reply #11 on: August 13, 2008, 03:44:42 PM »
If you want it to search all drawings in the directory selected, and all drawings in all the sub-directories, then it will need to be changed, but that shouldn't be hard to do if this works as is now.
I'll give it a good test-drive on Monday and see how it all works
Quote
Have a nice long weekend Tracy.
I will do... I'm looking forward to seeing my daughter.. (she's staying at Grandmas while its the school holidays)
Thanks for explaining the word "many" to me, it means a lot.

T.Willey

  • Needs a day job
  • Posts: 5251
Re: Finding out which drawings a file is xreffed into
« Reply #12 on: August 13, 2008, 05:24:39 PM »
Okay, so I got bored, and wanted to see how easy it would be, and it wasn't very hard to do.

Code: [Select]
(defun c:XrefFindv02 (/ *error* FindXrefs GetAllFiles CkStr DirPath DwgList DiaRtn Opened dbxApp oVer tempFile)
    ; This will search the directory selected, and all subdirectories to find the xref name entered.
    ;  The xref name is not case sensitive, and can be entered as a partial string; ie *-a-*
    ;    will work.
    ;  The text file will be placed in the directory selected, and it will only list drawings that had
    ;    xref names match the string, or had an error upon opening.
   
    (defun *error* (msg)
       
        (if dbxApp (vlax-release-object dbxApp))
        (setq dbxApp nil)
        (if Opened (close Opened))
        (if msg
            (prompt (strcat "\n Error --> " msg))
        )
    )
    ;----------------------------------------------------------
    (defun FindXrefs (doc str / tempName tempList)
       
        (vlax-for i (vla-get-Blocks doc)
            (if
                (and
                    (= (vla-get-IsXref i) :vlax-true)
                    (or
                        (wcmatch (strcase (setq tempName (vla-get-Name i))) (strcase str))
                        (= str "")
                    )
                )
                (setq tempList (cons tempName tempList))
            )
        )
        tempList
    )
    ;-------------------------------------------------
    (defun Directory-Dia ( Message / sh folder folderobject result)
    ;; By Tony Tanzillo
    ;; Modified by Tim Willey
    ;; 16 Will let you type in the path
    ;; 64 Will let you create a new folder

    (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 ; This is the bit number to change.
    )
    )
    (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 GetAllFiles (dir ext / FileList)
        (if (/= (substr dir (strlen dir)) "\\")
            (setq dir (strcat dir "\\"))
        )
        (if (setq tempList (vl-directory-files dir ext 1))
            (setq FileList (append FileList (mapcar '(lambda (x) (strcat dir x)) tempList)))
        )
        (if (setq tempList (cddr (vl-directory-files dir "*" -1)))
            (foreach i tempList
                (setq FileList (append FileList (GetAllFiles (strcat dir i) ext)))
            )
        )
        FileList
    )
    ;----------------------------------------------------------------
    (if
        (and
            (setq CkStr (getstring "\n Enter name to check for [*]: "))
            (setq DirPath (Directory-Dia "Select directory to search for xrefs."))
            (setq DwgList (GetAllFiles DirPath "*.dwg"))
            (setq Opened (open (setq tempFile (strcat Dirpath "XrefFindReport.txt")) "w"))
            (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))
                )
            )
        )
        (foreach i DwgList
            (if (vl-catch-all-error-p (vl-catch-all-apply 'vla-Open (list dbxApp i)))
                (write-line (strcat "++ Error opening file: " i "\n") Opened)
                (if (setq XrFound (FindXrefs dbxApp CkStr))
                    (progn
                        (write-line (strcat "- " i) Opened)
                        (foreach j XrFound
                            (write-line (strcat "    " j) Opened)
                        )
                        (write-line "\n" Opened)
                    )
                )
            )
        )
    )
    (prompt (strcat "\n Log file: " tempFile))
    (*error* nil)
    (princ)
)
Tim

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

Please think about donating if this post helped you.

ronjonp

  • Needs a day job
  • Posts: 7529
Re: Finding out which drawings a file is xreffed into
« Reply #13 on: August 13, 2008, 06:23:16 PM »
That's pretty slick Tim  :-)

Windows 11 x64 - AutoCAD /C3D 2023

Custom Build PC

T.Willey

  • Needs a day job
  • Posts: 5251
Re: Finding out which drawings a file is xreffed into
« Reply #14 on: August 13, 2008, 06:51:04 PM »
That's pretty slick Tim  :-)
Thanks Ron.
Tim

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

Please think about donating if this post helped you.