Set Layer name only once

Discussion in 'AutoCAD' started by stephen4444, Feb 9, 2004.

  1. stephen4444

    stephen4444 Guest

    Within the same opened drawing.

    How do you program a lsp so that when you
    run it the first time it prompt you to enter a layer name (then other comands .....), but then run it again the second time that the lsp remember the name you enter the first time so it wouldn't prompt you again for the layer name the second time (it just run other commands....) or the third or the forth until a new dwg session is open again?

    making sense?

    TIA
     
    stephen4444, Feb 9, 2004
    #1
  2. stephen4444

    dean_bourke Guest

    Do a check to see if the layer exists:
    (setq layername "XXXX")
    (if(null (tblsearch "LAYER" layername))
    (progn
    (command ".layer" "M" layername "")
    ;;;do stufff
    )
    (progn
    ;;;do stuff
    )
    (princ)
    )

    (NOT CHECKED)

    Dean
     
    dean_bourke, Feb 9, 2004
    #2
  3. Couple of different ideas for you.

    ;;;With the use of global variable
    (while (not lay-name)
    (setq lay-name
    (getstring "\nInput Layer Name: "))
    (if (not (tblsearch "layer" lay-name))
    (setq lay-name nil)
    (setvar "clayer" lay-name)
    )
    )

    ;;;With the use of local variable, but using
    ;;;user variable that is not saved in drawing.
    (while (not lay-name)
    (setq lay-name
    (getvar "users1"))
    (while (not (tbsearch "layer" lay-name))
    (setvar "users1" (setq lay-name (getstring "\nInput layer name:
    ")))
    )
    (setvar "clayer" lay-name)
    )
    --
    Ken Alexander
    Acad2004
    Windows2000 Prof.

    "We can't solve problems by using the same kind
    of thinking we used when we created them."
    --Albert Einstein

    other comands .....), but then run it again the second time that the
    lsp remember the name you enter the first time so it wouldn't prompt
    you again for the layer name the second time (it just run other
    commands....) or the third or the forth until a new dwg session is
    open again?
     
    Ken Alexander, Feb 9, 2004
    #3
  4. stephen4444

    stephen4444 Guest

    that will work, thanks
     
    stephen4444, Feb 10, 2004
    #4
  5. Welcome.

    --
    Ken Alexander
    Acad2004
    Windows2000 Prof.

    "We can't solve problems by using the same kind
    of thinking we used when we created them."
    --Albert Einstein
     
    Ken Alexander, Feb 10, 2004
    #5
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.