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

Thread: Adding Suffix to All Layers

  1. #1
    I could stop if I wanted to
    Join Date
    2015-12
    Posts
    385
    Login to Give a bone
    0

    Cool Adding Suffix to All Layers

    Hello all,
    I am trying to write a LSP that will add a sufix to all my layer names. (Obviously not 0)
    For this post lets use the one I am currently working on. I Am trying to add "-EXST" does anyone have any ideas on how to begin this lisp?

    Thank you all in advance,
    Andre

  2. #2
    AUGI Addict .T.'s Avatar
    Join Date
    2000-12
    Location
    Lost
    Posts
    1,473
    Login to Give a bone
    0

    Default Re: Adding Suffix to All Layers

    Quote Originally Posted by ReachAndre
    Hello all,
    I am trying to write a LSP that will add a sufix to all my layer names. (Obviously not 0)
    For this post lets use the one I am currently working on. I Am trying to add "-EXST" does anyone have any ideas on how to begin this lisp?

    Thank you all in advance,
    Andre
    Maybe this for a start:
    Code:
    (defun c:layers-exst ( / layers_col nam)
      (vl-load-com)
      (or *acaddoc* (setq *acaddoc* (vla-get-activedocument (vlax-get-acad-object))))
      (setq layers_col (vla-get-layers *acaddoc*))
      (vlax-for item layers_col
        (setq nam (vlax-get-property item 'Name))
        (if (and (/= nam "0")(/= nam "Defpoints"))
             (vlax-put-property item 'Name (strcat nam "-EXST"))
        )  
      )
    (princ)
    )

  3. #3
    Certifiable AUGI Addict tedg's Avatar
    Join Date
    2005-06
    Location
    in the upper right corner
    Posts
    3,507
    Login to Give a bone
    0

    Default Re: Adding Suffix to All Layers

    Quote Originally Posted by ReachAndre
    Hello all,
    I am trying to write a LSP that will add a sufix to all my layer names. (Obviously not 0)
    For this post lets use the one I am currently working on. I Am trying to add "-EXST" does anyone have any ideas on how to begin this lisp?

    Thank you all in advance,
    Andre
    I know this isn't a lisp routine, but did you consider the "rename" command with wild-cards?
    Use the rename command and select layers,


    in the old name box you would put A-* (or what ever your common layer situation is)

    In the Rename to box you would put A-*-EXST and hit ok. It will rename all of them instantly!

    Not a lisp but it works great.

  4. #4
    I could stop if I wanted to
    Join Date
    2015-12
    Posts
    385
    Login to Give a bone
    0

    Default Re: Adding Suffix to All Layers

    Tim,
    Thanks a bunch, I think I owe you something, you've been very hellpful on several of my posts.

    What I am trying to do now is to add the option to work on certain layers,
    Below is what I have but it doesnt seem to work.

    I am unfamiliar so far with VL commands, nut I do want to learn

    Code:
    (defun c:layers-exst ( / layers_col nam)
      (vl-load-com)
      (or *acaddoc* (setq *acaddoc* (vla-get-activedocument (vlax-get-acad-object))))
      (setq layers_col (vla-get-layers *acaddoc*))
      (vlax-for item layers_col
        (setq nam (vlax-get-property item 'Name))
        (if (and (/= nam "0")(/= nam "Defpoints")(= (strcat discipline "-*")))
             (vlax-put-property item 'Name (strcat nam "-EXST"))
        )  
      )
    (princ)
    )
    Code:
    (defun c:lsuf (/ odiscipline)
      (if (not discipline) (setq discipline "M"))
      (setq odiscipline discipline)
      (if
        (=
          (setq discipline
                 (getstring (strcat"What discipline are you working in? (Mechanical,Plumbing,Fireprotection, or Electrical <" odiscipline ">: "))
                )
          "")
        (setq discipline odiscipline)
        )
      (c:layers-exst)
      (princ)
    )
    Thanks again all,
    Andre

    [ Moderator Action = ON ] What are [ CODE ] tags... [ Moderator Action = OFF ]
    Last edited by Mike.Perry; 2007-03-06 at 02:18 PM. Reason: [CODE] tags added.

  5. #5
    AUGI Addict .T.'s Avatar
    Join Date
    2000-12
    Location
    Lost
    Posts
    1,473
    Login to Give a bone
    0

    Default Re: Adding Suffix to All Layers

    Quote Originally Posted by ReachAndre
    Tim,
    Thanks a bunch, I think I owe you something, you've been very hellpful on several of my posts.

    What I am trying to do now is to add the option to work on certain layers,
    Below is what I have but it doesnt seem to work.
    No problem Andre.

    First, have a look at this:
    Code:
    (defun c:test (/ dis) ;dis is local
      (or *dis* (setq *dis* "Mechanical"))  ;leave *dis* global
      (initget "Mechanical,M Plumbing,P Fireprotection,F Electrical,E");initget the keywords
      (setq dis (getkword
    	    (strcat
    "\nWhat discipline are you working in? <M>ech.,<P>lumbing,<F>irePro or <E>lect:"
    	       "<" *dis* ">"
    	    );strcat
    	  );getkword
    );setq
    (if (not dis)(setq dis *dis*)(setq *dis* dis))
    );defun
    and digest it a little bit. I'll help more when I have time later.

  6. #6
    AUGI Addict .T.'s Avatar
    Join Date
    2000-12
    Location
    Lost
    Posts
    1,473
    Login to Give a bone
    0

    Default Re: Adding Suffix to All Layers

    Hi Andre,

    Give this a try:

    Code:
    (defun c:test (/ dis ans) ;dis is local - no, i'm not dis'n you :)
      (or *dis* (setq *dis* "Mechanical"))  ;leave *dis* global 
      (initget "Mechanical,M Plumbing,P FireProtection,F Electrical,E");initget the keywords
      (setq ans (getkword
    	    (strcat
    "\nWhat discipline are you working in? <M>ech.,<P>lumbing,<F>irePro or <E>lect:"
    	       "<" *dis* ">"
    	    );strcat
    	  );getkword
    );setq
    (cond ((= ans "Mechanical")(setq dis "Mech")(setq *dis* "Mechanical"))
          ((= ans "Plumbing")(setq dis "Plum")(setq *dis* "Plumbing"))
          ((= ans "FireProtection")(setq dis "Fire")(setq *dis*  "FireProtection"))
          ((= ans "Electrical")(setq dis "Elec")(setq *dis* "Electrical"))
          (T (cond ((= *dis* "Mechanical")(setq dis "Mech"))
                   ((= *dis* "Plumbing")(setq dis "Plum"))
                   ((= *dis* "FireProtection")(setq dis "Fire"))
                   ((= *dis* "Electrical")(setq dis "Elec"))
             )
          )
    )
    (layers-exst dis)
    (princ (strcat *dis* "layers renamed"))
    (princ)  
    );defun
    
    (defun layers-exst (dis_match / layers_col nam)
      (vl-load-com)
      (or *acaddoc* (setq *acaddoc* (vla-get-activedocument (vlax-get-acad-object))))
                                             ;get the acad document
      (setq layers_col (vla-get-layers *acaddoc*))
                                             ;get the layers collection from the acad document
      (vlax-for item layers_col;walk through the layers collection
        (if
          (and
            (wcmatch (strcase (vlax-get-property item 'Name))(strcase (strcat dis_match "*")))
                                                      ;if the characters match
            (not (wcmatch (strcase (vlax-get-property item 'Name)) "*-EXST"))
                                                      ;and hasn't already been changed (cheers Chris)
          )  
          (vlax-put-property item 'Name (strcat (vlax-get-property item 'Name) "-EXST"))
                                                       ;rename the layer
        )
      )
      (princ)
    )
    With slight modifications, c:layers-exst becomes layers-exst, a function that will process the layers based on the argument dis_match. dis_match needs to be a string that reflects the first letters that are common with the discipline depending on your layer naming scheme. In this example, I used Mech, Plum, Fire and Elec, thinking that your layer scheme may look something like:

    Mech-Ductwork
    Mech-Annotation
    Plum-Fittings
    Elec-Conduit
    Etc.
    Etc.

    Change the values in the cond section (in red) to reflect your actual situation. Don't worry about the stuff in the prompt, and you can even spell out the disciplines, like changing FirePro to Fire Protection - I just ran out of room in the post editor.

    Let us know if you need more help.
    Last edited by .T.; 2007-03-07 at 11:03 AM. Reason: Better version; it was keeping me awake.

  7. #7
    Member
    Join Date
    2005-02
    Posts
    46
    Login to Give a bone
    0

    Default Re: Adding Suffix to All Layers

    Sorry I will post this somewhere else
    Last edited by gab.83408; 2007-03-08 at 03:10 PM. Reason: [CODE] tags added

  8. #8
    AUGI Addict .T.'s Avatar
    Join Date
    2000-12
    Location
    Lost
    Posts
    1,473
    Login to Give a bone
    0

    Default Re: Adding Suffix to All Layers

    Quote Originally Posted by gab.83408
    Sorry I will post this somewhere else
    Where'd you go, gab? I don't see another post.

  9. #9
    I could stop if I wanted to
    Join Date
    2003-11
    Posts
    277
    Login to Give a bone
    0

    Default Re: Adding Suffix to All Layers

    Quote Originally Posted by ReachAndre
    Hello all,
    I am trying to write a LSP that will add a sufix to all my layer names. (Obviously not 0)
    For this post lets use the one I am currently working on. I Am trying to add "-EXST" does anyone have any ideas on how to begin this lisp?

    Thank you all in advance,
    Andre
    Hi Andre,
    How about this code
    Code:
    (defun table (s / d r)                     ; Michael Puckett
      (while
        (setq d (tblnext s (null d)))
        (setq r (cons (cdr (assoc 2 d)) r))
        )
      )
    
    (defun c:test (/ add leng lst)
      (setq add "-EXST")
      (setq lst (cdr (reverse (table "layer")))) 
      (if (= lst nil)(alert "\nThis layer only 0 layer")) 
      (setq leng (length lst))
      (if
        (> leng 1)
        (progn
          (foreach x lst
    	(command "_rename" "layer" x (strcat add x))
    	)   ; foreach
          )     ; progn
        (progn
          (alert (strcat "\nThis layer only " (car lst) " layer"))
          )     ; progn
        )       ; if
      (princ)
      )         ; defun
    Last edited by Adesu; 2007-03-09 at 01:24 AM. Reason: fixed [code] tags

  10. #10
    Member
    Join Date
    2016-01
    Posts
    10
    Login to Give a bone
    0

    Default Re: Adding Suffix to All Layers

    Quote Originally Posted by ReachAndre View Post
    Hello all,
    )
    (layers-exst dis)
    (princ (strcat *dis* "layers renamed"))
    (princ)
    );defun

    (defun layers-exst (dis_match / layers_col nam)
    (vl-load-com)
    (or *acaddoc* (setq *acaddoc* (vla-get-activedocument (vlax-get-acad-object))))
    ;get the acad document
    (setq layers_col (vla-get-layers *acaddoc*))
    ;get the layers collection from the acad document
    (vlax-for item layers_col;walk through the layers collection
    (if
    (and
    (wcmatch (strcase (vlax-get-property item 'Name))(strcase (strcat dis_match "*")))
    ;if the characters match
    (not (wcmatch (strcase (vlax-get-property item 'Name)) "*-EXST"))
    ;and hasn't already been changed (cheers Chris)
    )
    (vlax-put-property item 'Name (strcat (vlax-get-property item 'Name) "-EXST"))
    ;rename the layer
    )
    )
    (princ)
    )
    is there anyway to automate this to be done on a directory of files?

    I need to combine this somehow with this .scr:


    -layer
    Unlock
    *
    Color
    9
    *
    LWeight
    .025
    *
    LOck
    *

    -PURGE
    ALL
    *
    N

    Zoom
    Extents

    QSAVE

    CLOSE



    I know this portion can be done with tools like Auto Script, but I need these combined somehow into one tool.....any ideas???

Page 1 of 2 12 LastLast

Similar Threads

  1. adding suffix width sheet name to a view
    By Wish List System in forum Revit Architecture - Wish List
    Replies: 1
    Last Post: 2013-11-15, 06:03 PM
  2. Adding a Suffix to the drawing name
    By ReachAndre in forum AutoLISP
    Replies: 4
    Last Post: 2007-08-27, 07:57 PM
  3. Adding a suffix to certain Layer names
    By mtlynn in forum AutoLISP
    Replies: 6
    Last Post: 2007-01-04, 08:20 PM
  4. Adding Prefix and Suffix parameter in Text
    By jrichardson in forum Revit Structure - General
    Replies: 2
    Last Post: 2006-12-08, 02:46 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •