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

Thread: Layer Swap routine giving me issues

  1. #1
    Member
    Join Date
    2007-04
    Location
    Boise, ID
    Posts
    47
    Login to Give a bone
    0

    Default Layer Swap routine giving me issues

    I can't figure out why this lsip is failing on "some" of my drawings. Does anyone see any issue with the code?
    Code:
    (defun C:HU-LSRD (/)
       (setvar "cmdecho" 0)
       (vl-cmdf "_-layer" "new" "G-MAINFRAME" "c" "31" "G-MAINFRAME" "l" "CONTINUOUS" "G-MAINFRAME" "")
       (vl-cmdf "_-layer" "new" "G-EQUIP" "c" "31" "G-EQUIP" "l" "CONTINUOUS" "G-EQUIP" "")
       (vl-cmdf "_-layer" "new" "G-FLEX" "c" "6" "G-FLEX" "l" "ZIGZAG" "G-FLEX" "")
       (vl-cmdf "_-layer" "new" "G-GUTTER" "c" "6" "G-GUTTER" "l" "DASHDOT2" "G-GUTTER" "")
       (vl-cmdf "_-layer" "new" "G-HEAVY" "c" "6" "G-HEAVY" "l" "CONTINUOUS" "G-HEAVY" "")
       (vl-cmdf "_-layer" "new" "G-KEYN" "c" "3" "G-KEYN" "l" "CONTINUOUS" "G-KEYN" "")
       (vl-cmdf "_-layer" "new" "G-SYMBOL" "c" "6" "G-SYMBOL" "l" "CONTINUOUS" "G-SYMBOL" "")
       (vl-cmdf "_-layer" "new" "G-TEXT" "c" "3" "G-TEXT" "l" "CONTINUOUS" "G-TEXT" "")
       (vl-cmdf "_-layer" "new" "G-TRAY" "c" "6" "G-TRAY" "l" "FENCELINE2" "G-TRAY" "")
       (vl-cmdf "_-layer" "new" "G-VENDOR(S)+MICRON(I)" "c" "6" "G-VENDOR(S)+MICRON(I)" "l" "HIDDEN" "G-VENDOR(S)+MICRON(I)" "")
       (vl-cmdf "_-layer" "new" "G-VENDOR(S+I)" "c" "3" "G-VENDOR(S+I)" "l" "HIDDEN2" "G-VENDOR(S+I)" "")
       (vl-cmdf "_-layer" "new" "G-EQUIP-E" "c" "3" "G-EQUIP-E" "l" "CONTINUOUS" "G-EQUIP-E" "")
       (vl-cmdf "_-layer" "new" "G-FLEX-E" "c" "4" "G-FLEX-E" "l" "ZIGZAG" "G-FLEX-E" "")
       (vl-cmdf "_-layer" "new" "G-GUTTER-E" "c" "4" "G-GUTTER-E" "l" "DASHDOT2" "G-GUTTER-E" "")
       (vl-cmdf "_-layer" "new" "G-KEYN-E" "c" "4" "G-KEYN-E" "l" "CONTINUOUS" "G-KEYN-E" "")
       (vl-cmdf "_-layer" "new" "G-SYMBOL-E" "c" "4" "G-SYMBOL-E" "l" "CONTINUOUS" "G-SYMBOL-E" "")
       (vl-cmdf "_-layer" "new" "G-TEXT-E" "c" "4" "G-TEXT-E" "l" "CONTINUOUS" "G-TEXT-E" "")
       (vl-cmdf "_-layer" "new" "G-TRAY-E" "c" "4" "G-TRAY-E" "l" "FENCELINE2" "G-TRAY-E" "")
       (vl-cmdf "_-layer" "new" "G-VENDOR(S)+MICRON(I)-E" "c" "4" "G-VENDOR(S)+MICRON(I)-E" "l" "HIDDEN" "G-VENDOR(S)+MICRON(I)-E" "")
       (vl-cmdf "_-layer" "new" "G-VENDOR(S+I)-E" "c" "4" "G-VENDOR(S+I)-E" "l" "HIDDEN2" "G-VENDOR(S+I)-E" "")
       (vl-cmdf "_-layer" "new" "G-LITE" "c" "4" "G-LITE" "l" "CONTINUOUS" "G-LITE" "")
    
    (setq ss (ssget "x" (list (cons 8 "G-FLEX"))));;;; "G-FLEX" new scope layer name
    (if (/= ss nil)
    (vl-cmdf "_change" ss "" "p" "la" "G-FLEX-E" ""));;; "G-FLEX-E" existing scope layer name
    
    (setq ss (ssget "x" (list (cons 8 "G-GUTTER"))))
    (if (/= ss nil)
    (vl-cmdf "_change" ss "" "p" "la" "G-GUTTER-E" ""))
    
    (setq ss (ssget "x" (list (cons 8 "G-HEAVY"))))
    (if (/= ss nil)
    (vl-cmdf "_change" ss "" "p" "la" "G-LITE" ""))
    
    (setq ss (ssget "x" (list (cons 8 "G-KEYN"))))
    (if (/= ss nil)
    (vl-cmdf "_change" ss "" "p" "la" "G-KEYN-E" ""))
    
    (setq ss (ssget "x" (list (cons 8 "G-SYMBOL"))))
    (if (/= ss nil)
    (vl-cmdf "_change" ss "" "p" "la" "G-SYMBOL-E" ""))
    
    (setq ss (ssget "x" (list (cons 8 "G-TEXT"))))
    (if (/= ss nil)
    (vl-cmdf "_change" ss "" "p" "la" "G-TEXT-E" ""))
    
    (setq ss (ssget "x" (list (cons 8 "G-TRAY"))))
    (if (/= ss nil)
    (vl-cmdf "_change" ss "" "p" "la" "G-TRAY-E" ""))
    
    (setq ss (ssget "x" (list (cons 8 "G-VENDOR(S)+MICRON(I)"))))
    (if (/= ss nil)
    (vl-cmdf "_change" ss "" "p" "la" "G-VENDOR(S)+MICRON(I)-E" ""))
    
    (setq ss (ssget "x" (list (cons 8 "G-VENDOR(S+I)"))))
    (if (/= ss nil)
    (vl-cmdf "_change" ss "" "p" "la" "G-VENDOR(S+I)-E" ""))
    
    (setq ss (ssget "x" (list (cons 8 "G-EQUIP"))))
    (if (/= ss nil)
    (vl-cmdf "_change" ss "" "p" "la" "G-EQUIP-E" ""))
    
    (vl-cmdf "_regen")
    (princ)
    )
    Here is what Autocad is returning:
    Code:
    Command: HU-LSRD
    
    Layer "G-MAINFRAME" already exists.
    
    Layer "G-EQUIP" already exists.
    
    Layer "G-FLEX" already exists.
    
    Layer "G-GUTTER" already exists.
    
    Layer "G-HEAVY" already exists.
    
    Layer "G-KEYN" already exists.
    
    Layer "G-SYMBOL" already exists.
    
    Layer "G-TEXT" already exists.
    
    Layer "G-TRAY" already exists.
    
    Layer "G-VENDOR(S)+MICRON(I)" already exists.
    
    Layer "G-VENDOR(S+I)" already exists.
    
    Layer "G-EQUIP-E" already exists.
    
    Layer "G-FLEX-E" already exists.
    
    Layer "G-GUTTER-E" already exists.
    
    Layer "G-KEYN-E" already exists.
    
    Layer "G-SYMBOL-E" already exists.
    
    Layer "G-TEXT-E" already exists.
    
    Layer "G-TRAY-E" already exists.
    
    Layer "G-VENDOR(S)+MICRON(I)-E" already exists.
    
    Layer "G-VENDOR(S+I)-E" already exists.
    
    Layer "G-LITE" already exists.
    Unknown command "P".  Press F1 for help.
    Unknown command "LA".  Press F1 for help.
    Unknown command "G-FLEX-E".  Press F1 for help.
    Unknown command "HU-LSRD".  Press F1 for help.
    Unknown command "P".  Press F1 for help.
    Unknown command "LA".  Press F1 for help.
    Unknown command "G-GUTTER-E".  Press F1 for help.
    Unknown command "HU-LSRD".  Press F1 for help.
    Unknown command "P".  Press F1 for help.
    Unknown command "LA".  Press F1 for help.
    Unknown command "G-LITE".  Press F1 for help.
    Unknown command "HU-LSRD".  Press F1 for help.
    Unknown command "P".  Press F1 for help.
    Unknown command "LA".  Press F1 for help.
    Unknown command "G-SYMBOL-E".  Press F1 for help.
    Unknown command "HU-LSRD".  Press F1 for help.
    Unknown command "P".  Press F1 for help.
    Unknown command "LA".  Press F1 for help.
    Unknown command "G-TEXT-E".  Press F1 for help.
    Unknown command "HU-LSRD".  Press F1 for help.
    Unknown command "P".  Press F1 for help.
    Unknown command "LA".  Press F1 for help.
    Unknown command "G-TRAY-E".  Press F1 for help.
    Unknown command "HU-LSRD".  Press F1 for help.
    Unknown command "P".  Press F1 for help.
    Unknown command "LA".  Press F1 for help.
    Unknown command "G-VENDOR(S)+MICRON(I)-E".  Press F1 for help.
    Unknown command "HU-LSRD".  Press F1 for help.
    Unknown command "P".  Press F1 for help.
    Unknown command "LA".  Press F1 for help.
    Unknown command "G-VENDOR(S+I)-E".  Press F1 for help.
    Unknown command "HU-LSRD".  Press F1 for help.
    Unknown command "P".  Press F1 for help.
    Unknown command "LA".  Press F1 for help.
    Unknown command "G-EQUIP-E".  Press F1 for help.
    Unknown command "HU-LSRD".  Press F1 for help.

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

    Default Re: Layer Swap routine giving me issues

    Instead of ' new ', use ' make ' option in the layer command.

  3. #3
    Member
    Join Date
    2007-04
    Location
    Boise, ID
    Posts
    47
    Login to Give a bone
    0

    Question Re: Layer Swap routine giving me issues

    After I replaced "new" with "make", the "layer already exists strings went away. But the "unkown command" errors are still there. It is almost like it doesn't recognise the command "change". I tried it with "chprop" and got the same unknown command errors?

  4. #4
    Member
    Join Date
    2007-04
    Location
    Boise, ID
    Posts
    47
    Login to Give a bone
    0

    Default Re: Layer Swap routine giving me issues

    Could it be a drawing varible setting, because this routine works on other drawings?

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

    Default Re: Layer Swap routine giving me issues

    Maybe the change command is being overridden. If so, put a period in from of the command call. Ie (command "_.change" ...... )

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

    Default Re: Layer Swap routine giving me issues

    Can you find out exactly what line it's failing on?

    It would appear to be this one...
    (vl-cmdf "_change" ss "" "p" "la" "G-FLEX-E" ""))

    If so, try running that code at the command line (not using lisp)


    BTW: your original code works fine here in 2008.
    R.K. McSwain | CAD Panacea |

  7. #7
    Member
    Join Date
    2007-04
    Location
    Boise, ID
    Posts
    47
    Login to Give a bone
    0

    Default Re: Layer Swap routine giving me issues

    I tried the period and had the same issue. It is failing at the first change command. It may have something to do with the selection set is created. I am now sure though that it works on an older version of tghe same drawing, and not on the new version. I've attached both DWG's.
    Attached Files Attached Files

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

    Default Re: Layer Swap routine giving me issues

    Here is what the command line returned.

    Command: change

    Select objects: !ss
    <Selection set: 6ad>
    191 found
    191 were not in current space.

    Select objects:
    As you can see you are trying to change objects that are not in the current layout, so it will error as commands cannot do that. You will have to either step through the drawing a different way ( more advanced coding ) or just issue the command per layout, and only select items per layout, not ideal.

  9. #9
    Member
    Join Date
    2007-04
    Location
    Boise, ID
    Posts
    47
    Login to Give a bone
    0

    Thumbs up Re: Layer Swap routine giving me issues

    Quote Originally Posted by T.Willey View Post
    Here is what the command line returned.



    As you can see you are trying to change objects that are not in the current layout, so it will error as commands cannot do that. You will have to either step through the drawing a different way ( more advanced coding ) or just issue the command per layout, and only select items per layout, not ideal.
    Perfect...that did it!
    Thanks for your help

  10. #10
    Certifiable AUGI Addict ccowgill's Avatar
    Join Date
    2004-08
    Location
    Iron Station, NC
    Posts
    3,198
    Login to Give a bone
    0

    Default Re: Layer Swap routine giving me issues

    to filter out other layouts, you can use an additional filter to your ssget:
    Code:
    (setq ss (ssget "_X" (list '(-4 . "<and")
                                         (cons 410 (getvar "ctab"))
                                         '(8 . "G-FLEX")
                                         '(-4 . "and>")
                       )    ;end list
                     ) ;_ end of ssget
                  ) ;_ end of setq

Page 1 of 2 12 LastLast

Similar Threads

  1. Replies: 13
    Last Post: 2011-06-28, 03:31 PM
  2. Twin door giving me issues.
    By nate.carpenter in forum Revit Architecture - Families
    Replies: 10
    Last Post: 2007-12-10, 02:29 PM
  3. Replies: 8
    Last Post: 2007-05-16, 01:29 AM
  4. Replies: 10
    Last Post: 2007-04-27, 06:17 PM
  5. Swap Layer settings via a button
    By davidbassford in forum AutoCAD Customization
    Replies: 3
    Last Post: 2006-05-09, 01:39 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
  •