is xref unloaded?

Discussion in 'AutoCAD' started by Daron, Mar 16, 2005.

  1. Daron

    Daron Guest

    when examining a block with tblnext, assoc 70 isn't telling me if it's
    loaded or unloaded. the following xref is unloaded:
    ((0 . "BLOCK") (2 . "X_aFlor-Floor01") (70 . 12) (4 . "") (10 0.0 0.0 0.0)
    (1 .
    "..\\a-Plans\\X_aFlor-Floor01.dwg") (-2 . <Entity name: 7e39c360>))

    help states that
    4 = This block is an external reference (xref)
    8 = This block is an xref overlay

    anyone have a suggestion?

    thanks
    daron
     
    Daron, Mar 16, 2005
    #1
  2. Daron,

    I'm pretty sure that you can check the XRefDatabase property of the block object - if it throws an error then the xref is unloaded.

    The folowing fragment shouldl build a list of unloaded xref names - (vl-load-com)
    (vlax-map-Collection (vla-get-Blocks (vla-get-ActiveDocument (vlax-get-acad-object)))
    '(lambda (b)
    (if (and
    (= (vla-get-IsXRef b) :vlax-true)
    (vl-catch-all-error-p (vl-catch-all-apply 'vla-get-XRefDatabase (list b)))
    );and
    (setq lst (append lst (list (vla-get-Name b))))
    );if
    )
    )

    Peter
     
    petersciganek, Mar 16, 2005
    #2
  3. Daron

    Daron Guest

    Peter,

    thanks, works like a champ. interesting observation...

    upon opening the drawing with the xref in question unloaded, LST gives me
    that xref name as expected.

    if i reload that xref and run the code again, it still thinks the xref is
    unloaded. (ever if i set LST to nil before running again)

    inversely, if the xref is loaded upon opening the drawing, LST returns nil
    as expected. unload the xref and run the code again. LST is still nil.

    does something need to be released here?

    thanks for your help,
    daron
     
    Daron, Mar 16, 2005
    #3
  4. Yes, Daron - I had noticed that but haven't yet figured out a way to update the XRefDatabase property after an xref has been loaded/unloaded.

    Typically, after running a couple of commands the attempt to return the property does throw the exception - occasionally I switch back and forth between paperspace/modelspace. Maybe you need to dig into the database object - check some properties or try calling some methods to see if they are missing or at least acting differently than a loaded xref. Maybe someone else in this NG has a solution?

    Peter
     
    petersciganek, Mar 18, 2005
    #4
  5. Daron

    alex Guest

    i have been trying to understand this but the new vlax stuff eludeds me.
    and good books on how to use it?

    my goal is to write a routine called xru that updates only the currently
    loaded xrefs. the unloaded ones get no action.

    so far i only get one xref to show up in the list var lst.

    Thanks, alex
     
    alex, Mar 21, 2005
    #5
  6. Alex,

    The online help is fairly good on this subject (at least, I was able to make sense of most of the functions). The key, though is to become familiar with the autocad object model which means that you need to enter the world of VBA. Type VBAIDE ant the command line hit the F2 button - each object (e.g. line, arc, lwpolyline) is listed with properties and associated methods. With vlisp you access these properties with vla-put-[property] and vla-get-[property] . That, at any rate is a start...

    Note - to load the vlisp functions you need to call (vl-.load-com) first.

    One way to deal with your situation, though, might be to create a list all loaded and VISIBLE (i.e. - selectable) xrefs with something like this:

    (setq filt "")
    (vlax-map-Collection (vla-get-Blocks (vla-get-ActiveDocument (vlax-get-acad-object)))
    '(lambda (b)
    (if (= (vla-get-IsXRef b) :vlax-true)
    (setq filt (strcat filt (vla-get-Name b) ","))
    );if
    )
    )
    which will return a string of xref names divided by a comma - then create a selection set -

    (setq ss (ssget "_X" (list (cons 0 "INSERT") (cons 2 filt))))

    From this selection set you can build a list of xref names that you can then iterate through to reload. Of course you could also just reload all xrefs with (command "_-xref" "_re" "*") if it doesn't slow you down too much...


    Hope this helps to get you started,

    Peter
     
    petersciganek, Mar 22, 2005
    #6
  7. Daron

    alex Guest

    thanks a lot.
    alex
     
    alex, Mar 22, 2005
    #7
  8. Daron

    alex Guest

    This works the same as the (command "xref" "r" "*") command.
    i was not able to find a property to test if the xref was in a loaded or
    unloaded state.
    oh well....
    may i will make a routine that lets you put ones in a list and they get
    reloaded and it can be stored as xdata.

    (DEFUN C:XRU ()
    (setq filt "")
    (vlax-map-Collection (vla-get-Blocks (vla-get-ActiveDocument
    (vlax-get-acad-object)))
    '(lambda (b)
    (if (= (vla-get-IsXRef b) :vlax-true)
    (setq filt (strcat filt (vla-get-Name b) ","))
    );if
    )
    )

    (setq ss (ssget "_X" (list (cons 0 "INSERT") (cons 2 filt))))
    (command "xref" "r" filt)
    (princ))
     
    alex, Mar 22, 2005
    #8
  9. Daron

    Daron Guest

    Alex,

    in Peter's original reply to me, LST returns the name of any unloaded xrefs.

    daron
     
    Daron, Mar 22, 2005
    #9
  10. Alex - you still need to derive the list of loaded and selectable xrefs from the selection set - you then pass this list to the command. You are currently just passing the list of all xrefs to the reload command.

    Peter
     
    petersciganek, Mar 23, 2005
    #10
  11. Daron

    alex Guest

    thanks, i will look at it again.


     
    alex, Mar 23, 2005
    #11
  12. Daron

    alex Guest

    correct. so far i have not been able to figure out how to test if it is
    loaded. i thought the errror trap was a way of adding unloaded ones to the
    lst list. but that always comes up nil.
    I was unable to find any kind of property that would tell me if it was
    loaded or not even looking in VBA.
    not sure what to do now.
     
    alex, Mar 24, 2005
    #12
  13. Alex,

    I finally got around to checking this routine - it seems that ssget "X" will also select unloaded xrefs so that is no solution either. If I think of anything else I'll post it here.

    Peter
     
    petersciganek, Mar 29, 2005
    #13
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.