xref hierachy tree?

Discussion in 'AutoCAD' started by mattis, Aug 4, 2003.

  1. mattis

    mattis Guest

    How do I find out which xrefs are nested and which ones aren't? I want a list of xref names that are on the top level (not the lower level stuff).
     
    mattis, Aug 4, 2003
    #1
  2. mattis

    mattis Guest

    There's no way to do this with tblsearch or tblnext?
     
    mattis, Aug 4, 2003
    #2
  3. mattis

    Rudy Tovar Guest

    You can (ssget "x" <filters>) then return the names, and 'tblsearch' all the
    components.

    Just so you know, you'll have to create a reoccurring loop to get the nested
    'insert'.
    --
    Rodolfo Tovar
    www.Cadentity.com
    AUTODESK
    Authorized Developer
    MASi
    (Modulated Architectural Symbols Innovated)
    Version 2.01
    6 yrs Time Tested and it Works....
    1st components should be available Sept. 1, 2003.....
     
    Rudy Tovar, Aug 4, 2003
    #3
  4. mattis

    Jeff Mishler Guest

    This was posted over a year ago and I find it quite handy, Jeff

    ;;; Stephan Koster 2002, posted to adesk customization
    ;;; newsgroup on 4/21/2002
    (defun XrefTree (/ nested_p build_retlist firstLevelXrefs name
    nested-xrefs nestList xrefDBase retList i
    )
    (defun nested_p (blockname / tn tmp)
    (and (setq tn (tblobjname "block" blockname))
    (setq tmp (entget tn))
    (setq tmp (cdr (assoc 330 tmp)))
    (setq tmp (entget tmp))
    (not (member '(102 . "{BLKREFS") tmp))
    )
    )
    ;;;
    (defun build_retlist(name / next)
    (setq retList (cons (cons i name) retList))
    (and (setq next (cdr (assoc name nestList)))
    (setq i (1+ i))
    (foreach z next (build_retlist z))
    (setq i (1- i))
    )
    )
    ;;;
    (vlax-for x (vla-get-blocks (vla-get-activedocument
    (vlax-get-acad-object)))
    (if (= (vla-get-isXref x) :vlax-true)
    (progn
    (setq name (vla-get-Name x))
    (or (nested_p name)
    (setq firstLevelXrefs (cons name firstLevelXrefs))
    )
    (setq nested-xrefs (list name))
    (setq xrefDBase (vl-catch-all-apply 'vla-get-xrefdatabase (list x)))
    (or (vl-catch-all-error-p xrefDBase)
    (vlax-for xx (vla-get-Blocks xrefDBase)
    (if (= (vla-get-isXref xx) :vlax-true)
    (setq nested-xrefs (cons (vla-get-Name xx) nested-xrefs))
    )
    )
    )
    (if (cdr nested-xrefs)
    (setq nestList (cons (reverse nested-xrefs) nestList))
    )
    )
    )
    )
    (foreach x firstLevelXrefs
    (setq i 0)
    (build_retlist x)
    )
    (reverse retList)
    )
    ;;;
    (defun c:XrefTree()
    (foreach x (XrefTree)
    (repeat (* 2 (car x)) (princ " "))
    (princ (cdr x))
    (princ "\n")
    )
    (princ)
    )



    list of xref names that are on the top level (not the lower level stuff).
     
    Jeff Mishler, Aug 5, 2003
    #4
  5. mattis

    mattis Guest

    Wow! Works nice! I wish I could understand that vla and vlax stuff. Thanks Jeff!
     
    mattis, Aug 5, 2003
    #5
Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.