Resetting xrefs to original colors?

Discussion in 'AutoCAD' started by The real JD, Feb 12, 2004.

  1. The real JD

    The real JD Guest

    Hi all,

    I have a group of xrefs that all the layers for the xref were changed to a
    specific color. I want to change the xref colors back to the original colors
    that show in the original drawing. Instead of detaching and reattaching the
    xrefs to reset the color, is there a routine to do that? TIA
     
    The real JD, Feb 12, 2004
    #1
  2. The real JD

    The real JD Guest

    Jeff,

    That's very cool. Thanks.
    Seems to work as long as the xref is not currently open.
    I get an error if an xref is open.
    Don't know if that's how it's supposed work.

    Thanks again. This will totally save me time. :)
     
    The real JD, Feb 13, 2004
    #2
  3. The real JD

    Jeff Mishler Guest

    Yeah, I didn't think to add that check for the drawing being open. I use
    ObjectDBX and it doesn't work with drawings currently open in a drawing
    editor.
    It will also fail if the xref path can't be resolved with my search
    method. Most xref's can be found, but there are a few that have some
    really wierd paths that it doesn't find.....

    Glad you like it otherwise....
    Jeff
     
    Jeff Mishler, Feb 13, 2004
    #3
  4. Why a routine? (Unless you want to maintain visibility control.) Turning
    VisRetain off, saving, and reopening the file is enough.

    --
    R. Robert Bell, MCSE
    www.AcadX.com


    Hi all,

    I have a group of xrefs that all the layers for the xref were changed to a
    specific color. I want to change the xref colors back to the original colors
    that show in the original drawing. Instead of detaching and reattaching the
    xrefs to reset the color, is there a routine to do that? TIA
     
    R. Robert Bell, Feb 13, 2004
    #4
  5. The real JD

    The real JD Guest

    A routine would allow me to select one xref and reset the colors without
    losing the settings for other xrefs within the drawing. Plus it keeps the
    freeze thaw states of the xrefs too!

    When you have easily half a dozen xrefs in drawing and you just want to
    reset one, a routine like this is of great benefit.

    Long answer i guess.. when I coulda just said, "yeah i want to keep
    visretain within the drawing"

    Got a deadline to meet. Another late night.
    Cheers
     
    The real JD, Feb 13, 2004
    #5
  6. Thought that might be case!

    --
    R. Robert Bell, MCSE
    www.AcadX.com


    A routine would allow me to select one xref and reset the colors without
    losing the settings for other xrefs within the drawing. Plus it keeps the
    freeze thaw states of the xrefs too!

    When you have easily half a dozen xrefs in drawing and you just want to
    reset one, a routine like this is of great benefit.

    Long answer i guess.. when I coulda just said, "yeah i want to keep
    visretain within the drawing"

    Got a deadline to meet. Another late night.
    Cheers
     
    R. Robert Bell, Feb 13, 2004
    #6
  7. The real JD

    Joe Burke Guest

    There's another way to do this. Subject: "reload xref symbologly" dated 10/26/2003 in
    this NG.

    I don't know if my last version there works as well Jeff's solution. It doesn't use
    ObjectDBX. So the xref can be open.

    Joe Burke
     
    Joe Burke, Feb 13, 2004
    #7
  8. The real JD

    martin Guest

    Hi,

    Which command does start the application?

    Regards,

    miran
     
    martin, Feb 14, 2004
    #8
  9. The real JD

    Jeff Mishler Guest

    Sorry, I should've posted that as well.

    First, unzip the 2 files to a folder in the Acad support path. Next, in
    Acad, load the xref_sync lisp file, like this: (load "xref_sync")
    Then type at the command line: xr_sync

    Jeff
     
    Jeff Mishler, Feb 14, 2004
    #9
  10. The real JD

    The real JD Guest

    Could repost related code?
    I'm having trouble going back that far with my newsreader...
    Google searching the group doesn't bring it up either..
     
    The real JD, Feb 16, 2004
    #10
  11. The real JD

    Huw Guest

  12. The real JD

    Joe Burke Guest

    Huw,

    Thanks for the pointer to that thread. My last post there is probably not what I'm
    using now, as follows.

    JD,

    As I said, this may or may not work as well as Jeff's solution. The only advantage
    I'm aware of is the xref can be open because it doesn't use ObjectDBX. Other than
    that, Jeff's solution is more elegant. On the other hand, it's not unusal you'd want
    to do this when the xref is open. In fact, that may be the more typical case.

    Whatever, I appreciate your original question. I think what these functions are
    trying to do is something AutoDesk should include in some form.

    Let me know if you find any problems with the code below.

    Regards
    Joe Burke

    ;; 10/26/2003 revised 12/11/2003
    ;; with thanks to John Uhden for his assistance
    ;; reload xref symbology: layer color, linetype and lineweight
    ;; while preserving current on/off, freeze/thaw,
    ;; locked/unlocked, plot/no plot states in the active file

    (defun c:XrefReloadSymbology ( / *Error* *acad* *doc* *layers*
    *blocks* ent xname onlst frzlst locklst plotlst path )
    (vl-load-com)
    (defun *Error* (Msg)
    (cond
    ((or (not Msg)
    (member Msg '("console break"
    "Function cancelled"
    "quit / exit abort"))))
    ((princ (strcat "\nError: " Msg))))
    (setvar "visretain" 1)
    (vla-endundomark *doc*)
    (princ)
    ) ;end

    (setq *acad* (vlax-get-acad-object)
    *doc* (vla-get-activedocument *acad*)
    *blocks* (vla-get-blocks *doc*)
    )
    (vla-startundomark *doc*)
    (while
    (or
    (not (setq ent (car (entsel "\nSelect xref to reload symbology: "))))
    (not (vlax-Property-Available-p (vlax-ename->vla-object ent) 'Path))
    )
    (princ "\nMissed pick or xref not selected, try again: ")
    ) ;while
    (setq xname (cdr (assoc 2 (entget ent))))
    (setvar "visretain" 1)
    ;first update/reload with visretain on
    (vla-reload (vla-item *blocks* xname))
    (if (setq path (get-xref-path xname)) ;xref was found somewhere
    (progn
    (setq *layers* (vla-get-layers *doc*))
    (setq str (strcase (strcat xname "|*")))
    ;store current xref layer status in lists
    (vlax-for x *layers*
    (if (wcmatch (strcase (vla-get-name x)) str)
    (setq pair (cons (vla-get-name x) (vla-get-layeron x))
    onlst (cons pair onlst)
    pair (cons (vla-get-name x) (vla-get-freeze x))
    frzlst (cons pair frzlst)
    pair (cons (vla-get-name x) (vla-get-lock x))
    locklst (cons pair locklst)
    pair (cons (vla-get-name x) (vla-get-plottable x))
    plotlst (cons pair plotlst)
    )
    )
    ) ;for
    (setvar "visretain" 0)
    ;reload with visretain off to update
    ;layer color, linetype and lineweight
    (vla-reload (vla-item *blocks* xname))
    ;now restore previous on/off, freeze/thaw,
    ;locked/unlocked, plot/no plot status
    (foreach x onlst
    (vla-put-layeron (vla-item *layers* (car x)) (cdr x)))
    (foreach x frzlst
    (vla-put-freeze (vla-item *layers* (car x)) (cdr x)))
    (foreach x locklst
    (vla-put-lock (vla-item *layers* (car x)) (cdr x)))
    (foreach x plotlst
    (vla-put-plottable (vla-item *layers* (car x)) (cdr x)))
    (princ (strcat "\nReloaded from: " path))
    ) ;progn
    (princ "\nXref not found ") ;else
    ) ;if
    (*Error* nil)
    (princ)
    ) ;end

    ;; If an xref is not found in the saved path AutoCAD searches
    ;; the whole support path. By Stephan Koster 2001
    (defun get-xref-path (blockname / data path saved_path pos)
    (cond ((not (setq data (tblsearch "block" blockname))))
    ;; Does the block exist
    ((/= (logand (cdr (assoc 70 data)) 4) 4))
    ;; Is it an xref
    ((and (setq saved_path (cdr (assoc 1 data)))
    (setq path (findfile saved_path))
    ;; Can it be found on the saved path
    )
    )
    ((not (setq pos (vl-string-position (ascii "\\") saved_path 1 T))))
    (T (setq path (findfile (substr saved_path (+ pos 2)))))
    ;; Can it be found somewhere else in the search path
    )
    path
    )

    http://discussion.autodesk.com/thread.jspa?messageID=1191220
     
    Joe Burke, Feb 17, 2004
    #12
  13. The real JD

    tectonic Guest

    Jeff,
    Thoughts on getting this "xref-sync" to work. I am using 2004.

    It loads fine; but when i select the xref to reload i get a "run-time error '13' type mismatch"

    When the debugger opens it highlights this line:
    Set dbxDoc = GetInterfaceObject("ObjectDBX.AxDbDocument.16")

    that line is on the SyncButton


    Any help would be appreciated.

    thanks,
    Jon
     
    tectonic, Dec 8, 2004
    #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.