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

xref report

3 REPLIES 3
Reply
Message 1 of 4
Anonymous
346 Views, 3 Replies

xref report

Has anybody got a lisp program to generate a xref report. I know about designcenter  and use it a lot but I would like to be able to send the report a text file. Unfortunately I do not not always use the latest Autocad versions and so would need it to work from versions from Autocad 2009.

 

Thanks in advance

3 REPLIES 3
Message 2 of 4
3wood
in reply to: Anonymous

You can try Reference Manager.

RM.png

 

(Start->All programs->Autodesk->AutoCAD 2009->Reference Manager)

Message 3 of 4
hmsilva
in reply to: Anonymous


@Anonymous wrote:

Has anybody got a lisp program to generate a xref report. I know about designcenter  and use it a lot but I would like to be able to send the report a text file. Unfortunately I do not not always use the latest Autocad versions and so would need it to work from versions from Autocad 2009.

 

Thanks in advance


As a "demo"...

(defun c:demo (/ fn lst of)
  (vl-load-com)
  (vlax-For blk
	    (vla-Get-Blocks (vla-Get-ActiveDocument (vlax-Get-Acad-Object)))
    (if	(= (vla-Get-IsXref blk) :vlax-True)
      (setq lst (cons (vla-get-path blk) lst))
    )
  )
  (if lst
    (progn
      (setq fn (strcat (getvar 'DWGPREFIX)
		       (vl-filename-base (getvar 'DWGNAME))
		       " - XRefs.txt"
	       )
      )
      (setq of (open fn "w"))
      (foreach l lst
	(write-line l of)
      )
      (close of)
      (startapp "notepad" fn)
    )
  )
  (princ)
)

 

HTH

Henrique

EESignature

Message 4 of 4
BlackBox_
in reply to: Anonymous

Here's one I wrote many, many moons ago:

 

(vl-load-com)

(defun c:BatchFindXref (/ *error* _WriteXrefData acApp acDocs oShell oFolder path dwgs
                        filePath dbxDoc file doc ok
                       )
  (princ "\rBATCHFINDEXREF ")

  (defun *error* (msg)
    (if file
      (close file)
    )
    (if oShell
      (vlax-release-object oShell)
    )
    (if dbxDoc
      (vlax-release-object dbxDoc)
    )
    (cond ((not msg))                                                   ; Normal exit
          ((member msg '("Function cancelled" "quit / exit abort")))    ; <esc> or (quit)
          ((princ (strcat "\n** Error: " msg " ** ")))                  ; Fatal error, display it
    )
    (princ)
  )

  (defun _WriteXrefData (doc)
    (vlax-for x (vla-get-blocks doc)
      (if (= :vlax-true (vla-get-isxref x))
        (progn
          (or ok (setq ok T))
          (write-line
            (strcat dwg
                    ","
                    (vla-get-name x)
                    ".dwg,"
                    (vla-get-path x)
            )
            file
          )
        )
      )
    )
  )
  
  (if
    (and
      (setq acApp (vlax-get-acad-object))
      (setq acDocs (vla-get-documents acApp))
      (setq oShell (vla-getinterfaceobject acApp "Shell.Application"))
      (setq oFolder (vlax-invoke
                      oShell
                      'BrowseForFolder
                      (vla-get-hwnd acApp)
                      "Select folder to search:"
                      0
                      (+ 1 64 256)
                    )
      )
      (setq path (vlax-get-property
                   (vlax-get-property oFolder 'Self)
                   'Path
                 )
      )
      (setq dwgs (vl-directory-files path "*.dwg" 1))
      (setq filePath
             (strcat
               (vl-filename-directory
                 (vl-filename-mktemp)
               )
               "\\Batch Find Xref Report_"
               (menucmd
                 "M=$(edtime,$(getvar,date),YYYY-MO-DD)"
               )
               ".csv"
             )
      )
      (princ "\nWorking, please wait...")
      (princ)
      (setq dbxDoc (vla-getinterfaceobject
                     acApp
                     (strcat "ObjectDBX.AxDbDocument."
                             (substr (getvar 'acadver) 1 2)
                     )
                   )
      )
    )
     (progn
       (setq file (open filePath "w"))
       (write-line "Directory Searched:" file)
       (write-line path file)
       (write-line "" file)
       (write-line "Host Drawing:,Reference Name:,Saved Path:" file)
       (foreach dwg dwgs
         (cond
           ((not
              (vl-catch-all-error-p
                (setq doc
                       (vl-catch-all-apply
                         'vla-item
                         (list (vla-get-documents acApp) dwg)
                       )
                )
              )
            )
            (_WriteXrefData doc)
           )
           ((not
              (vl-catch-all-error-p
                (vl-catch-all-apply
                  'vla-open
                  (list dbxDoc (strcat path "\\" dwg))
                )
              )
            )
            (_WriteXrefData dbxDoc)
           )
           ((write-line
              (strcat dwg ",Unable to open drawing. ")
              file
            )
           )
         )
       )
       (princ "Done.")
       (if ok
         (vlax-invoke oShell 'open filePath)
         (prompt "\n** No surfaces found ** ")
       )
     )
     (cond
       (filePath
        (prompt
          "\n** Unable to create \"ObjectDBX.AxDbDocument\" Object ** "
        )
       )
       (path (prompt "\n** No drawings found ** "))
       (oShell (prompt "\n** No folder selected ** "))
       (acDocs
        (prompt
          "\n** Unable to create \"Shell.Application\" Object ** "
        )
       )
     )
  )
  (*error* nil)
)

 



"How we think determines what we do, and what we do determines what we get."

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

Post to forums  

Autodesk Design & Make Report

”Boost