Author Topic: how to generate a xref list??  (Read 2751 times)

0 Members and 1 Guest are viewing this topic.

rainier

  • Guest
how to generate a xref list??
« on: July 10, 2007, 10:14:34 PM »

how to generated a list of all xref in a dwg file??

(defun gxref ()
  (princ "\ngenerated xref:  < how to generated it?")
  (princ "\nxref name        status           type          path")
  (princ
    (strcat "\n"
            xrefname "        " xstatus "    "  xtype "    " xpath")
  )

(princ)
)

please help... i just want a lisp of all xref...
(command "-xref" "?" "")  <---  cant generated a status of a xref....

VVA

  • Newt
  • Posts: 166
Re: how to generate a xref list??
« Reply #1 on: July 11, 2007, 04:09:39 AM »
see dxf group 70
Quote
Block-type flags (bit-coded values, may be combined):

0 = Indicates none of the following flags apply
1 = This is an anonymous block generated by hatching, associative dimensioning, other internal operations, or an application
2 = This block has non-constant attribute definitions (this bit is not set if the block has any attribute definitions that are constant, or has no attribute definitions at all)
4 = This block is an external reference (xref)
8 = This block is an xref overlay
16 = This block is externally dependent
32 = This is a resolved external reference, or dependent of an external reference (ignored on input)
64 = This definition is a referenced external reference (ignored
on input)
 

Code: [Select]
(princ "\nxref name        status       type          path")
(while (setq d (tblnext "block" (null d)))
  (setq grp70 (cdr(assoc 70 d)))
  (if (=(logand grp70 4) 4)
    (progn ;_Xref
      (princ
        (strcat "\n"
          (cdr(assoc 2 d))
          "             "
          (if (= (logand 8 grp70) 8) "overlay" "insert ")
          "      "
          (if (= (logand 32 grp70) 32) " load " "unload")
          "     "
          (cdr(assoc 1 d))
          )
        )
      )
    )
  );_while


rainier

  • Guest
Re: how to generate a xref list??
« Reply #2 on: July 11, 2007, 08:59:07 PM »
thanks VVA, wow nice... it solves my problem...

thanks again...

about bit-coded values where do u get those...?? i have a dxf reference guide here... but i dont see it...

Kerry

  • Mesozoic relic
  • Seagull
  • Posts: 11654
  • class keyThumper<T>:ILazy<T>
Re: how to generate a xref list??
« Reply #3 on: July 11, 2007, 09:11:38 PM »
rainer,
This May help you to find it ..

kdub, kdub_nz in other timelines.
Perfection is not optional.
Everything will work just as you expect it to, unless your expectations are incorrect.
Discipline: None at all.

MP

  • Seagull
  • Posts: 17750
  • Have thousands of dwgs to process? Contact me.
Re: how to generate a xref list??
« Reply #4 on: July 11, 2007, 09:18:31 PM »
(On a different tangent and admittedly overkill for now but ...) Sometime down the road the following link may be of interest, especially if you ever delve into ObjectDBX. While it may appear daunting because it is documented ad nauseum c/w with an example, it's but 5 short functions (albeit penned in my typically verbose writing style).

Link.

(Must be logged into theswamp.org for the link resolve).

Cheers.
Engineering Technologist • CAD Automation Practitioner
Automation ▸ Design ▸ Drafting ▸ Document Control ▸ Client
cadanalyst@gmail.comhttp://cadanalyst.slack.comhttp://linkedin.com/in/cadanalyst

rainier

  • Guest
Re: how to generate a xref list??
« Reply #5 on: July 11, 2007, 09:41:16 PM »
thank you Kerry Brown... i have not search that column...  :angel:

oh, question on the part were:

      (if (= (logand 8 grp70) 8 ) "overlay" "insert ")   <<< ----- this part at code of VVA

we cant say that if its "orphaned" .... i need to know it also... thanks
« Last Edit: July 11, 2007, 09:42:59 PM by rainier »

CADDOG

  • Newt
  • Posts: 82
  • wishbonesr
Re: how to generate a xref list??
« Reply #6 on: October 25, 2012, 10:48:30 PM »
A little spin on VVA's
This is pretty much the extent that you can find out (afaik).

Code: [Select]
(princ "\nxref name        status       type          path")
(while (setq d (tblnext "block" (null d)))
  (setq grp70 (cdr(assoc 70 d)))
  (if (=(logand grp70 4) 4)
    (progn ;_Xref
      (princ
        (strcat "\n"
          (cdr(assoc 2 d))
          "             "
          (if (= (logand 8 grp70) 8) "overlay" "insert ")
          "      "
(if (eq 32 (logand 32 grp70))
   (if (ssget "x" (list (cons 0 "INSERT")(assoc 2 d))) ;quick and easy
;from T. Willey's code at: http://www.theswamp.org/index.php?topic=4103.msg103206#msg103206
;more direct ->           (if (and (vla-Item (vla-get-Blocks (vla-get-ActiveDocument (vlax-get-Acad-Object)))
;                               (cdr(assoc 2 d)))
; (assoc 71 (entget (tblobjname "block" (vla-get-Name i))))
; );and
     "LOADED"
     "UNREFERENCED/ORPHANED"
     )
  (if (findfile (assoc 1 d))
    "UNLOADED"
    "NOT FOUND")
  )
          "     "
          (cdr(assoc 1 d))
          )
        )
      )
    )
  );_while

Well, I say that.  You could differentiate between orphaned and unreferenced if you recurse through all xref's and their xref's bulding a list.  If the nested list contains your xref from the first pass, then it's nested and thus orphaned.  That is, if it was marked 'UNREFERENCED/ORPHANED' in the first place.

Here's lee-mac's rendition to get nested xref data, but does a NonNextedXrefList, so you would know it's orphaned if it's not in the list.  Combining these two methods could generate that.
GetXrefNesting expects a vla-object doc.

Code: [Select]
(defun GetXrefNesting ( doc / GetXrefInfo Ent XrefList NonNestedXrefList )
       
        (defun GetXrefInfo ( ent / NestList )
            (foreach i (member '(102 . "{BLKREFS") (entget ent))
                (if (equal (car i) 332)
                    (progn
                        (setq NestedList (cons (cdr i) NestedList))
                        (setq NestList
                            (cons
                                (cons
                                    (cdr i)
                                    (GetXrefInfo (cdr i))
                                )
                                NestList
                            )
                        )
                    )
                )
            )
            NestList
        )
        ;-------------------------------------------------------------------
        (vlax-for i (vla-get-Blocks doc)
            (if
                (and
                    (equal (vla-get-IsXref i) :vlax-true)
                    (setq Ent (vlax-vla-object->ename i))
                )
                (setq XrefList
                    (cons
                        (cons
                            Ent
                            (GetXrefInfo Ent)
                        )
                        XrefList
                    )
                )
            )
        )
        (foreach i XrefList
            (if (not (member (car i) NestedList))
                (setq NonNestedXrefList (cons i NonNestedXrefList))
            )
        )
        NonNestedXrefList
    )
« Last Edit: October 26, 2012, 03:13:27 PM by CADDOG »