Minor Tweak to existing macro...

Discussion in 'AutoCAD' started by calpolyarc, Jul 21, 2004.

  1. calpolyarc

    calpolyarc Guest

    I have a button with the following macro (which I have to credit David Koch for) assigned to it:

    (if (minusp (cdr (assoc 62 (entget (tblobjname "LAYER" "a-elev-hatch"))))) (command "._layer" "_ON" "a-elev-hatch" "") (command "._layer" "_OFF" "a-elev-hatch" "") )

    If my 'a-elev-hatch' layer is 'on', this routine turns it off, if the layer is 'off', the routine turns it on. It's like a layer light switch.

    I tried to apply the same concept to a different scenario by replacing "a-elev-hatch" with "*surf-hatch" but it didn't like the ' * ' (I think). My goal is to be able to turn on/off my "A-Surf-Hatch" layer even if the layer is in an xref, that's why I added the ' * ', because in the xref the layer name will have the name of the root drawing before it. Is this possible? Do I need a lisp routine instead of a macro? Am I making any sense? Thanks.
     
    calpolyarc, Jul 21, 2004
    #1
  2. calpolyarc

    dblaha Guest

    Try this:

    (setq this_layer (tblnext "layer" T))(while this_layer(if (vl-string-search "surf-hatch" (setq lname (cdr (assoc 2 this_layer))))(if (minusp (cdr (assoc 62 this_layer)))(command "._layer" "_ON" lname "")(command "._layer" "_OFF" lname "")))(setq this_layer (tblnext "layer")))
     
    dblaha, Jul 21, 2004
    #2
  3. calpolyarc

    calpolyarc Guest

    Got another one for you if you're up for it! :) I posted it in a new thread titled "Tab and Down Arrow in lisp? Grread?" Thanks! BTW: that surface hatch toggle lisp has been very helpful.
     
    calpolyarc, Aug 4, 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.