Results 1 to 7 of 7

Thread: Layer search upon each drawing OPEN

  1. #1
    All AUGI, all the time
    Join Date
    2003-10
    Posts
    706
    Login to Give a bone
    0

    Default Layer search upon each drawing OPEN

    Is there a niffty way to search a drawing for a specific layer upon opening a drawing and determine whether or not the layer is OFF/ON or FROZEN/THAWED? I've done the table search thing for "LAYERS" but the layer I want will always be embedded inside of an xref so it's impossible to know what the prefix of the layer name will be. I've tried wildcards in the "LAYER NAME" portion but they didn't work... at least the way I used them. Any suggestions?

  2. #2
    All AUGI, all the time Avatart's Avatar
    Join Date
    2004-06
    Location
    Upsidedown in dreamtown
    Posts
    927
    Login to Give a bone
    0

    Default Re: Layer search upon each drawing OPEN

    To do this automatically, you would need some sort of reactor. Personally I am not too keen on reactors, if you getthem worng they can make one hell of a mess of you drawings.

    What have you done re wildcard searching the layer table?
    ^^ Ceci n'est pas une post ^^

  3. #3
    AUGI Addict
    Join Date
    2005-08
    Posts
    1,043
    Login to Give a bone
    0

    Default Re: Layer search upon each drawing OPEN

    If you want to check upon opening a drawing, you just need to have the routine autoload, and run it. You can have it autoload serval different ways. If the layer if going to be in a xref ALWAYS, then maybe something like

    Code:
    (defun LayExist (LayName)
    
    (vl-catch-all-error-p
     (vl-catch-all-apply
      '(lambda ()
       (vlax-for Lay (vla-get-Layers (vla-get-ActiveDocument (vlax-get-Acad-Object)))
        (if (wcmatch (strcase (vla-get-Name Lay)) (strcase (strcat "*|" LayName)))
         (exit)
        )
       )
      )
     )
    )
    )

    Edit: Didn't see the other part.
    Code:
    (defun LayExist (LayName)
    
    (vl-catch-all-error-p
     (vl-catch-all-apply
      '(lambda ()
       (vlax-for Lay (vla-get-Layers (vla-get-ActiveDocument (vlax-get-Acad-Object)))
        (if (wcmatch (strcase (vla-get-Name Lay)) (strcase (strcat "*|" LayName)))
          (progn
           (prompt (strcat "\n Layer on status = " (vl-princ-to-string (vla-get-LayerOn Lay))))
           (prompt (strcat "\n Layer froze status = " (vl-princ-to-string (vla-get-Freeze Lay))))
           (exit)
         )
        )
       )
      )
     )
    )
    (princ)
    )
    Last edited by T.Willey; 2006-08-04 at 03:22 PM.

  4. #4
    All AUGI, all the time
    Join Date
    2003-10
    Posts
    706
    Login to Give a bone
    0

    Default Re: Layer search upon each drawing OPEN

    I'll have the Lisp code automatically load from my own acad.lsp file so that's not a problem. I'm kinda old school when it comes to AutoLisp so I'm not familiar with the whole VisualLisp syntax. I'm using the old "tblsearch" code to search the dictionaries. See below. Then I'll go through the dotted pairs to list the status of each. The problem I'm having is the Xref name changing every time. Does anyone have an "old school" suggestion?


    (setq wmlayer (tblsearch "layer" "watermark"))

    The problem here is that the text "watermark" will always have the xref name in front of it.

  5. #5
    All AUGI, all the time Avatart's Avatar
    Join Date
    2004-06
    Location
    Upsidedown in dreamtown
    Posts
    927
    Login to Give a bone
    0

    Default Re: Layer search upon each drawing OPEN

    You could scroll through the layer table and apply a conditional test, if "true" return a value, a bit like:

    Code:
    (setq laynam (tblnext "layer"))
      (wcmatch (cdr (assoc 2 laynam)) "*|watermark*")
    The "*|watermark*" should find a layer called watermark on an xref layer. You would have to scroll this through the whole layer table obviously.
    ^^ Ceci n'est pas une post ^^

  6. #6
    All AUGI, all the time
    Join Date
    2003-10
    Posts
    706
    Login to Give a bone
    0

    Default Re: Layer search upon each drawing OPEN

    So the * (star) is a valid wildcard within the code? I tried using this in the tblsearch code and it just kicks it out with an error.

  7. #7
    All AUGI, all the time
    Join Date
    2015-12
    Location
    Central Oregon
    Posts
    591
    Login to Give a bone
    0

    Default Re: Layer search upon each drawing OPEN

    The star is valid when used with (wcmatch). It is NOT valid when using (tblsearch)

Similar Threads

  1. Auto-Search Function in Open Dialogue
    By inventor.wishlist1738 in forum Inventor Wish List
    Replies: 2
    Last Post: 2012-12-15, 05:56 PM
  2. Replies: 2
    Last Post: 2006-05-10, 06:38 PM
  3. Replies: 8
    Last Post: 2006-05-01, 06:39 PM
  4. Open sheet set manager without a drawing open
    By autocad.wishlist1734 in forum AutoCAD Wish List
    Replies: 3
    Last Post: 2006-01-15, 05:30 AM
  5. Layer Manager & Layer drop down are slow to open.
    By Glenn Pope in forum AutoCAD FAQ (Read only)
    Replies: 0
    Last Post: 2005-03-17, 06:01 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •