Results 1 to 6 of 6

Thread: Excluding xref-dependent layers with tblnext

  1. #1
    Member tuomo.jarvinen's Avatar
    Join Date
    2015-09
    Location
    Jyväskylä, Finland
    Posts
    49
    Login to Give a bone
    0

    Default Excluding xref-dependent layers with tblnext

    Hi, how can I browse through layers with tblnext but jump over the xref-dependent ones?
    (setq layerinturn (cdr (cadr (tblnext "layer")))) gives me all of them.

  2. #2
    I could stop if I wanted to
    Join Date
    2009-03
    Location
    London, England
    Posts
    304
    Login to Give a bone
    0

    Default Re: Excluding xref-dependent layers with tblnext

    Perhaps:

    Code:
    (defun NonXrefLayers ( / def lst )
        (while (setq def (tblnext "LAYER" (null def)))
            (if (not (wcmatch (cdr (assoc 2 def)) "*|*"))
                (setq lst (cons (cdr (assoc 2 def)) lst))
            )
        )
        (acad_strlsort lst)
    )

  3. #3
    Member tuomo.jarvinen's Avatar
    Join Date
    2015-09
    Location
    Jyväskylä, Finland
    Posts
    49
    Login to Give a bone
    0

    Default Re: Excluding xref-dependent layers with tblnext

    Thank You, I got the list of layers ok!

    What I'm trying is to give different colours to all layers. Something is still wrong, because the following try gives me "error: no function definition: NULL".

    Code:
    (defun c:cbl (/ null def Ent a layerinturn)
    
    ;Trying to color all layers with different colours
    
    (setvar "cmdecho" 0)
    (command "_.undo" "begin")
    (command "-layer" "on" "*" "t" "*" "")
    
    (command "change" "all" "" "p" "C" "bylayer" "lw" "bylayer" "")
    
        (while (setq def (tblnext "LAYER" (null def)))
            (if (not (wcmatch (cdr (assoc 2 def)) "*|*"))
                (setq lst (cons (cdr (assoc 2 def)) lst))
            )
        )
        (acad_strlsort lst)
    
    (setq a 1)
    
    (repeat (sslength lst)
    (setq layerinturn (ssname lst a))
    
    (command "_.-layer" "c" a layerinturn "")
    (setq a (+ 1 a))
    )
    
    (command "_.undo" "end")
    (setvar "cmdecho" 1)
    (princ)
    )
    Last edited by tuomo.jarvinen; 2011-10-26 at 12:31 PM.

  4. #4
    I could stop if I wanted to
    Join Date
    2009-03
    Location
    London, England
    Posts
    304
    Login to Give a bone
    0

    Default Re: Excluding xref-dependent layers with tblnext

    Your error is due to you localising the protected 'null' function in the defun expression, also 'lst' is not a SelectionSet, so sslength and ssname will error.

    Are you using a code editor with syntax highlighting to write your code?

  5. #5
    I could stop if I wanted to
    Join Date
    2009-03
    Location
    London, England
    Posts
    304
    Login to Give a bone
    0

    Default Re: Excluding xref-dependent layers with tblnext

    Consider this code:

    Code:
    (defun c:laycol ( / col def lst name )
        (setq col 0)
        (while (setq def (tblnext "LAYER" (null def)))
            (if (not (wcmatch (setq name (cdr (assoc 2 def))) "*|*"))
                (progn
                    (setq lst (entget (tblobjname "LAYER" name)))
                    (entmod (subst (cons 62 (setq col (1+ col))) (assoc 62 lst) lst))
                )
            )
        )
        (princ)
    )

  6. #6
    Member tuomo.jarvinen's Avatar
    Join Date
    2015-09
    Location
    Jyväskylä, Finland
    Posts
    49
    Login to Give a bone
    0

    Default Re: Excluding xref-dependent layers with tblnext

    Oops! You solved it for me already... thanks!! Looks so easy when you can!

    - I'm only using notepad for editing.

    How do I rate this issue solved?
    Last edited by tuomo.jarvinen; 2011-10-26 at 01:35 PM.

Similar Threads

  1. can i keep certain layers from XREF'ing?
    By JRBOURNE in forum AutoCAD General
    Replies: 10
    Last Post: 2012-05-25, 06:38 PM
  2. Dependent views not acting dependent
    By mjdanowski in forum Revit MEP - General
    Replies: 2
    Last Post: 2010-08-16, 09:11 PM
  3. Layers and XREF's
    By dlane.162299 in forum AutoCAD General
    Replies: 1
    Last Post: 2008-05-23, 05:27 PM
  4. Replies: 2
    Last Post: 2007-06-12, 12:20 PM
  5. Replies: 3
    Last Post: 2006-09-22, 08:22 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
  •