Page 1 of 2 12 LastLast
Results 1 to 10 of 13

Thread: How to Find a Layer if It Exists?

  1. #1
    AUGI Addict
    Join Date
    2006-04
    Location
    (getpoint "Anywhere on the Enter Key =>")
    Posts
    1,160
    Login to Give a bone
    0

    Default How to Find a Layer if It Exists?

    Hello ALL,

    I had a problem with my routine.
    What I want is:
    (1) Find a layer "Landscape" if it exists;
    (2) If the layer exist, change it's color to "green" bylayer.
    (3) If it doesn't exist, create it then set it to current.

    I can do the steps (2) & (3) except step (1)

    Any helps would be appreciated.

  2. #2
    Administrator Opie's Avatar
    Join Date
    2002-01
    Location
    jUSt Here (a lot)
    Posts
    8,917
    Login to Give a bone
    0

    Default Re: How to Find a Layer if It Exists?

    Try
    Code:
    (tblsearch "LAYER" "Landscape")
    If you have a technical question, please find the appropriate forum and ask it there.
    You will get a quicker response from your fellow AUGI members than if you sent it to me via a PM or email.
    jUSt

  3. #3
    AUGI Addict
    Join Date
    2006-04
    Location
    (getpoint "Anywhere on the Enter Key =>")
    Posts
    1,160
    Login to Give a bone
    0

    Default Re: How to Find a Layer if It Exists?

    Quote Originally Posted by Opie View Post
    Try
    Code:
    (tblsearch "LAYER" "Landscape")
    Thanks, tblsearch is the one, but how could it tell if it found the layer?
    I mean, what is the statement exactly?
    Will it be:
    (if (eq (tblsearch "LAYER" "Landscape"))
    (command "-layer" "set" "Landscape" "color" "3" "" ""))

    I am sure that the eq function is wrong.
    But what is the replacement for it?

  4. #4
    100 Club CADmium's Avatar
    Join Date
    2004-08
    Location
    Eberswalde, Germany, Europe
    Posts
    128
    Login to Give a bone
    0

    Default Re: How to Find a Layer if It Exists?

    (if (tblsearch "LAYER" "Landscape")
    (command "_-layer" "_set" "Landscape" "_color" "3" "" "")
    (command "_-layer" "_make" "Landscape" "_color" "3" "" "")
    )

  5. #5
    Administrator rkmcswain's Avatar
    Join Date
    2004-09
    Location
    Earth
    Posts
    9,803
    Login to Give a bone
    0

    Default Re: How to Find a Layer if It Exists?

    Quote Originally Posted by BoKirra View Post
    ...but how could it tell if it found the layer?
    The (tblsearch) function will return nil if the table entry is not found.
    So you just test it for a non-nil value.

    http://www.hyperpics.com/customizati...nce.asp?id=200
    R.K. McSwain | CAD Panacea |

  6. #6
    AUGI Addict
    Join Date
    2006-04
    Location
    (getpoint "Anywhere on the Enter Key =>")
    Posts
    1,160
    Login to Give a bone
    0

    Default Re: How to Find a Layer if It Exists?

    Quote Originally Posted by rkmcswain View Post
    The (tblsearch) function will return nil if the table entry is not found.
    So you just test it for a non-nil value.

    http://www.hyperpics.com/customizati...nce.asp?id=200
    with thanks to all.

  7. #7
    AUGI Addict
    Join Date
    2006-04
    Location
    (getpoint "Anywhere on the Enter Key =>")
    Posts
    1,160
    Login to Give a bone
    0

    Default Re: How to Find a Layer if It Exists?

    Quote Originally Posted by Opie View Post
    Try
    Code:
    (tblsearch "LAYER" "Landscape")
    From the HELP, I found the following description for the tblsearch function:
    (tblsearch table-name symbol [setnext])

    With your sample, the table-name is LAYER.
    And another one I know is STYLE.

    How to get the complete list of table-name?

    Thanks again.

  8. #8
    AUGI Addict kennet.sjoberg's Avatar
    Join Date
    2002-05
    Posts
    1,707
    Login to Give a bone
    0

    Default Re: How to Find a Layer if It Exists?

    Quote Originally Posted by BoKirra View Post
    . . . How to get the complete list of table-name?
    From the HELP tblnext, valid table-name values are "LAYER", "LTYPE", "VIEW", "STYLE", "BLOCK", "UCS", "APPID", "DIMSTYLE", and "VPORT".

    : ) Happy Computing !

    kennet

  9. #9
    Certifiable AUGI Addict
    Join Date
    2015-11
    Location
    Jo'burg SA
    Posts
    4,512
    Login to Give a bone
    0

    Default Re: How to Find a Layer if It Exists?

    And to see exactly what's returned if the layer is found with tblsearch, check the DXF / TABLES Section in Developer Help.

  10. #10
    AUGI Addict
    Join Date
    2006-04
    Location
    (getpoint "Anywhere on the Enter Key =>")
    Posts
    1,160
    Login to Give a bone
    0

    Default Re: How to Find a Layer if It Exists?

    Quote Originally Posted by kennet.sjoberg View Post
    From the HELP tblnext, valid table-name values are "LAYER", "LTYPE", "VIEW", "STYLE", "BLOCK", "UCS", "APPID", "DIMSTYLE", and "VPORT".

    : ) Happy Computing !

    kennet
    Thank you & also thanks to irneb.

Page 1 of 2 12 LastLast

Similar Threads

  1. Find text, change layer
    By demetrius.adams707933 in forum AutoLISP
    Replies: 1
    Last Post: 2015-09-01, 11:24 PM
  2. 2015: Cannot see or find veiwport layer!
    By Cosmic Traveller in forum AutoCAD General
    Replies: 2
    Last Post: 2015-07-23, 04:41 AM
  3. Layer - Find References
    By Wish List System in forum AutoCAD Wish List
    Replies: 2
    Last Post: 2013-02-19, 03:38 PM
  4. Can't find created layer
    By Jamord00 in forum ACA General
    Replies: 2
    Last Post: 2008-01-10, 10:11 PM
  5. Replies: 19
    Last Post: 2006-02-12, 11:06 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
  •