Wildcard Match Layers within a Reactor on Dwg Close

Discussion in 'AutoCAD' started by RKLindner, Oct 5, 2004.

  1. RKLindner

    RKLindner Guest

    I have built a reactor that upon exit from a drawing, it performs a purge, makes sure all layers are on and sets layers to be non-plottable in a specifically named file series that our office uses, otherwise, it just performs a normal exit from the drawing.

    What I am looking for though, is the ability to only set the layers that exist native to the drawing file to be non-plottable, and that all layers in the Xref'd file should be set to plottable. I just can't seem to find the right nudge via the online help, messages here, via google, etc to be able to perform this feat within a reactor.. none of the examples I found seem to deal with stepping thru layers one by one and any code I have even tried has failed miserably. I could easily do it via the command line, but that's of course not an option.

    Could someone please give me a hand with a way to accomplish this?

    Richard

    ;;; save-n-purge.lsp
    (vl-load-com)
    (vl-load-reactors)
    (or MJA:Dwr
    (setq MJA:Dwr (VLR-DWG-Reactor
    nil
    '(:)VLR-beginClose . MeBeginCloseStuff))
    )
    )
    )
    (or MJA:Dmr
    (setq MJA:Dmr (VLR-DocManager-reactor
    nil
    '(:)VLR-documentToBeDestroyed . MeDoCloseStuff))
    )
    )
    )
    (defun MeBeginCloseStuff
    (Rea Arg)
    (if (or (= 0 (getvar "dbmod")) ;senses dbmod changes to database
    (= 8 (getvar "dbmod")) ;and only allows non-database changes
    (= 16 (getvar "dbmod")) ;to affect when changes occur
    (= 20 (getvar "dbmod")) ;see autocad help for dbmod values
    )
    (progn
    (setq acadDocument
    (vla-get-activedocument (vlax-get-acad-object))
    )
    (setq mja-dwgname (getvar "DWGNAME"))
    (setq mja-dwgname (vl-filename-base mja-dwgname))
    (setq mja-dwgnamelen (strlen mja-dwgname)
    mja-dwgname2 (substr mja-dwgname 9 1)
    )
    (cond ; cond 1
    ;;; only works on files with an 12 character filename (aka xc01 files) and
    ;;; with a "X" in the 9th character position
    ((and (= 12 mja-dwgnamelen) (= "x" mja-dwgname2)) ; and 1
    (vla-purgeall acadDocument)
    (vla-zoomextents (vlax-get-acad-object))
    (setq theLayers (vla-get-layers acadDocument))
    (vlax-for item theLayers
    (vlax-put-property item "LayerOn" ':vlax-true)
    ; turns all layers on
    )
    (vlax-for item theLayers
    (vlax-put-property item "Lock" ':vlax-true)
    ; locks all layers
    )

    ;;;***********************************************************
    ;;; would like to filter out exactly what layers are non-plottable, i.e.
    ;;; bypass xref'd layers with a filter such as "*|*"
    ;;; currently it makes all layers in the file set to non-plottable
    ;;;***********************************************************

    (vlax-for item theLayers
    (vlax-put-property item "Plottable" ':vlax-false)
    ; sets certain layers to no-plot
    )
    ;;;************************************************************
    (vla-save acadDocument)
    ) ; end and 1
    ) ;end cond 1
    (princ)
    )
    )
    ) ; end defun MeBeginCloseStuff
    (defun MeDoCloseStuff (Rea Arg)
    (mapcar 'VLR-remove (list MJA:Dmr MJA:Dwr))
    (setq MJA:Dmr nil
    MJA:Dwr nil
    )
    (princ)
    )
    (princ "\nLoaded Save-n-purge Routine")
     
    RKLindner, Oct 5, 2004
    #1
  2. RKLindner

    Jeff Mishler Guest

    Why not condense all of the layer actions like this?

    (vlax-for item theLayers
    (vlax-put-property item "LayerOn" ':vlax-true); turns all layers on
    (vlax-put-property item "Lock" ':vlax-true); locks all layers
    (if (not (vl-string-search "|" (vla-get-name item)))
    (vlax-put-property item "Plottable" ':vlax-false); sets certain layers
    to no-plot
    )
    )
     
    Jeff Mishler, Oct 5, 2004
    #2
  3. RKLindner

    RKLindner Guest

    Why not condense

    because that would have meant I knew what I was doing.. <s>..

    Thank you Jeff for the consolidation of my routine. I am just beginning to dabble into ActiveX, Reactors, etc and have been piecing routines together with tidbits I have found online. I just couldn't grasp how to do this one lilttle part.
     
    RKLindner, Oct 5, 2004
    #3
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.