Author Topic: Not found xrefs  (Read 3810 times)

0 Members and 1 Guest are viewing this topic.

wizman

  • Bull Frog
  • Posts: 290
Not found xrefs
« on: November 20, 2011, 02:24:12 PM »
Dear all,

Is there any way i can list "not found" xrefs? Thanks.

Regards,

Ron

Lee Mac

  • Seagull
  • Posts: 12915
  • London, England
Re: Not found xrefs
« Reply #1 on: November 20, 2011, 04:15:34 PM »
Maybe:

Code: [Select]
(defun XrefsNotFound ( / a b )
    (while (setq a (tblnext "BLOCK" (null a)))
        (if
            (and
                (= 4 (logand 4 (cdr (assoc 70 a))))
                (not (findfile (cdr (assoc 1 a))))
            )
            (setq b (cons (cdr (assoc 2 a)) b))
        )
    )
    b
)

wizman

  • Bull Frog
  • Posts: 290
Re: Not found xrefs
« Reply #2 on: November 20, 2011, 07:35:57 PM »
thanks lee, i'll have to try it later at office.


regards,

ron

wizman

  • Bull Frog
  • Posts: 290
Re: Not found xrefs
« Reply #3 on: November 20, 2011, 10:23:19 PM »
Much appreciated Thanks! this works  Lee.

pBe

  • Bull Frog
  • Posts: 402
Re: Not found xrefs
« Reply #4 on: November 21, 2011, 08:06:12 AM »
Maybe:....

There there was me thinking the only way to do that is thru "AcDbBlockTableRecord"

Code: [Select]
(vlax-for itm (vla-get-blocks (vla-get-ActiveDocument (vlax-get-acad-object)))
  (if (and (eq (vla-get-objectname itm) "AcDbBlockTableRecord")
   (eq (vla-get-IsXRef itm) :vlax-true)
   (vl-catch-all-error-p
     (vl-catch-all-apply
       'vla-get-XRefDatabase
       (list
itm
       )
     )
   )
      )
    (princ (strcat "\nXref Not Found: " (vla-get-name itm)))
  )(princ)
)

Quick thinking Lee

wizman

  • Bull Frog
  • Posts: 290
Re: Not found xrefs
« Reply #5 on: November 21, 2011, 12:00:50 PM »
Thanks Pat, much appreciated. i can test it tomorrow.

Regards,

Ron

jaydee

  • Guest
Re: Not found xrefs
« Reply #6 on: November 21, 2011, 09:39:38 PM »
Hi.
Is there any ways to tell the different between UNLOADED and NOT FOUND Xrefs, assuming the Unloaded xrefs also Not found in paths.

Say i open a drawing that have issues with pathing (hense not found) and get a list of all Not found xrefs only (exclude the unloaded one). Then after fixing the paths, i want to apply reload to only those previous not found xrefs.
I want to do all this via lisp.

Thnakyou

pBe

  • Bull Frog
  • Posts: 402
Re: Not found xrefs
« Reply #7 on: November 22, 2011, 02:44:14 AM »
Hi.
Is there any ways to tell the different between UNLOADED and NOT FOUND Xrefs, assuming the Unloaded xrefs also Not found in paths.

Thnakyou

In that case

Code: [Select]
(vlax-for itm (vla-get-blocks (vla-get-ActiveDocument (vlax-get-acad-object)))
  (if (and (eq (vla-get-objectname itm) "AcDbBlockTableRecord")
   (eq (vla-get-IsXRef itm) :vlax-true)
   (vl-catch-all-error-p
     (vl-catch-all-apply
       'vla-get-XRefDatabase
       (list
itm
       )
     )
   )
      )
    (princ (strcat "\nXref "(if (assoc 71
      (entget (tblobjname "BLOCK" (vla-get-name itm))))
                      "Unloaded: "
      "Not Found: ") (vla-get-name itm)))
  )(princ)
)

Then after fixing the paths,

Manually? if not use this to get the path for XreF Reload (that is if the files exist / not renamed or worse deleted)
Code: [Select]
(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)))
      )
    )
  )
)


pBe

  • Bull Frog
  • Posts: 402
Re: Not found xrefs
« Reply #8 on: November 22, 2011, 03:52:27 AM »
Thanks Pat, much appreciated. i can test it tomorrow.

Regards,

Ron

Cheers Ron  :-D

Jaydee raised a good point determining "status", there's more than just unloaded/not found, there's also orphaned <xref attached not overlay>
« Last Edit: November 22, 2011, 03:56:15 AM by pBe »

jaydee

  • Guest
Re: Not found xrefs
« Reply #9 on: November 22, 2011, 06:41:11 AM »
Thankyou pBe
This is perfect. I have been looking for this code for a while and most lead me to autolisp xref bit flag 70 and seems like the unloaded and the not found xrefs having the same bit flags.

Very much appriciated

Heres the mod codes that suit me just for the Not found Xrefs
Code: [Select]
(defun CheckNfXrefs ()

(vlax-for itm (vla-get-blocks (vla-get-ActiveDocument (vlax-get-acad-object)))
  (if
    (and
      (eq (vla-get-objectname itm) "AcDbBlockTableRecord")
      (eq (vla-get-IsXRef itm) :vlax-true)
        (vl-catch-all-error-p
          (vl-catch-all-apply
            'vla-get-XRefDatabase
              (list
      itm
              )
          )
       )
   )

     (if
       (not
         (assoc 71
           (entget (tblobjname "BLOCK" (vla-get-name itm)))
         )
       )
          (setq notfoundxrefs (cons (vla-get-name itm) notfoundxrefs))
     )
   )
 )
)
and the main function
Code: [Select]
(defun c:test ()
(CheckNfXrefs)
==> paths fixing code goes here
for me its simply providing the projectname and add the project search path folders.

  (if notfoundxrefs
    (foreach x notfoundxrefs (command "-xref" "reload" x))
  )
(princ)
)




Lee Mac

  • Seagull
  • Posts: 12915
  • London, England
Re: Not found xrefs
« Reply #10 on: November 22, 2011, 06:47:53 AM »
Much appreciated Thanks! this works  Lee.

Excellent  :-)

Cheers guys.