change layers of multiple objects

Discussion in 'AutoCAD' started by James K., Mar 28, 2005.

  1. James K.

    James K. Guest

    Hello all,
    I'm new to the world of LISP and would appreciate some guidance in the following matter:

    I'm interested in writing a lisp file that can filter through a selection set of mixed objects for a list of pre-defined layer names. If an object exists on that specific layer, it needs to be changed to a different specific layer. The sequence would go something like this:

    IF Layer = M-SUPPLY-DUCT --> change to XM-SUPPLY,
    IF Layer = M-RETURN-DUCT --> change to XM-RETURN,
    ETC....
    ETC....
    ELSE END

    I've been trying to figure it out by sifting through the autocad help files, but this is proving to be tedious. A nudge in the right direction would be a big help. Specifically which expressions I should be focusing on....

    Thanks in advance,
    James
     
    James K., Mar 28, 2005
    #1
    1. Advertisements

  2. James K.

    ECCAD Guest

    This should get you started.
    ;;IF Layer = M-SUPPLY-DUCT --> change to XM-SUPPLY,
    ;;IF Layer = M-RETURN-DUCT --> change to XM-RETURN,

    (command "_layer" "m" "XM-SUPPLY" ""); make if not existing
    (setq ss (ssget "X" (list (cons 8 "M-SUPPLY-DUCT"))))
    (if ss
    (command "_change" ss "" "_p" "_la" "XM-SUPPLY" "")
    ); if

    Bob
     
    ECCAD, Mar 28, 2005
    #2
    1. Advertisements

  3. Sounds like a job for the Express Tools "Layer Merge" (LAYMRG) command. Not only do you not have to do any selection set, or sort through looking for objects and changing them to a different layer individually, but it also gets rid of the old layer entirely in the process.
    --
    Kent Cooper
    ...
    Hello all,
    I'm new to the world of LISP and would appreciate some guidance in the following matter:

    I'm interested in writing a lisp file that can filter through a selection set of mixed objects for a list of pre-defined layer names. If an object exists on that specific layer, it needs to be changed to a different specific layer. The sequence would go something like this:

    IF Layer = M-SUPPLY-DUCT --> change to XM-SUPPLY,
    IF Layer = M-RETURN-DUCT --> change to XM-RETURN,
    ETC....
    ETC....
    ELSE END

    I've been trying to figure it out by sifting through the autocad help files, but this is proving to be tedious. A nudge in the right direction would be a big help. Specifically which expressions I should be focusing on....

    Thanks in advance,
    James
     
    Kent Cooper, AIA, Mar 29, 2005
    #3
  4. James K.

    ECCAD Guest

    Kent,
    Snippet.Looks like to me he wants to roll-his-own.
    It will be a good on-line exercise :)
    Bob
     
    ECCAD, Mar 29, 2005
    #4
  5. James K.

    James Buzbee Guest

    You can't just change the layer names?

    jb
     
    James Buzbee, Mar 29, 2005
    #5
  6. James K.

    James K. Guest

    Thanks Bob, I am in fact using this opportunity as a learning exercise. I appreciate the kick-start.

    Kent, thanks for the tip. I was unaware of that function within xpress tools. I just upgraded from Autocad LT-04 and am discovering many new things about the full version on a daily basis... much appreciated.

    James



    Kent,
    Snippet.Looks like to me he wants to roll-his-own.
    It will be a good on-line exercise :)
    Bob
     
    James K., Mar 29, 2005
    #6
    1. Advertisements

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.