Jump to content
Sign in to follow this  
GLORY

Multiple CTAB

Recommended Posts

GLORY

Hello,

 

Need some help regarding the code  I found. What it does is copy a single layout and increment it based on the last character of the last layout name, if its Alphabet, the new layout name will be the next character of the alphabet and same with numbers. All I want is to add a variable if want to copy it depending on the number of copies i want.

Here's the code...

 

(vl-load-com)
  (setq m:err *error* *error* *merrmsg*)
  (setq layout_names (LAYOUTLIST))
  (setq old_layout_name (getvar "CTAB"))
  (if (member old_layout_name layout_names)
    (progn
      (setq new_layout_name old_layout_name
           last_layout_name new_layout_name
            buf "" i (strlen new_layout_name))
      (while (or
               (member
               (setq new_layout_name (incsuff new_layout_name 1 Only-number))
               layout_names
               )
               (null new_layout_name)
               )
        (if new_layout_name
          (setq last_layout_name new_layout_name)
          (progn
            (if (= 0 i)
            (setq buf "" new_layout_name (strcat old_layout_name "-0"))
            (setq buf (strcat buf  (substr old_layout_name (strlen old_layout_name)))
                  new_layout_name (substr old_layout_name 1  (setq i (1- i)))
                  )
              )
            )
          )
        )
      (setq new_layout_name (strcat new_layout_name buf))
      (setq i (vla-get-TabOrder (vla-item (vla-get-layouts(vla-get-activedocument
      (vlax-get-acad-object))) last_layout_name)))
      (command "_.LAYOUT" "_C" old_layout_name new_layout_name)
      (vla-put-TabOrder (vla-item(vla-get-layouts(vla-get-activedocument
      (vlax-get-acad-object))) new_layout_name) (1+ i))
      (setvar "CTAB" new_layout_name)
    )
    (alert (if(= (getvar "DWGCODEPAGE") "ANSI_1252") "Not Allowed in Model Space."))
  )

 

Share this post


Link to post
Share on other sites
BIGAL

Quick and dirty try this

 


(vl-load-com)
 (defun addlayouts ( )
  (setq m:err *error* *error* *merrmsg*)
  (setq layout_names (LAYOUTLIST))
  (setq old_layout_name (getvar "CTAB"))
  (if (member old_layout_name layout_names)
    (progn
      (setq new_layout_name old_layout_name
           last_layout_name new_layout_name
            buf "" i (strlen new_layout_name))
      (while (or
               (member
               (setq new_layout_name (incsuff new_layout_name 1 Only-number))
               layout_names
               )
               (null new_layout_name)
               )
        (if new_layout_name
          (setq last_layout_name new_layout_name)
          (progn
            (if (= 0 i)
            (setq buf "" new_layout_name (strcat old_layout_name "-0"))
            (setq buf (strcat buf  (substr old_layout_name (strlen old_layout_name)))
                  new_layout_name (substr old_layout_name 1  (setq i (1- i)))
                  )
              )
            )
          )
        )
      (setq new_layout_name (strcat new_layout_name buf))
      (setq i (vla-get-TabOrder (vla-item (vla-get-layouts(vla-get-activedocument
      (vlax-get-acad-object))) last_layout_name)))
      (command "_.LAYOUT" "_C" old_layout_name new_layout_name)
      (vla-put-TabOrder (vla-item(vla-get-layouts(vla-get-activedocument
      (vlax-get-acad-object))) new_layout_name) (1+ i))
      (setvar "CTAB" new_layout_name)
    )
    (alert (if(= (getvar "DWGCODEPAGE") "ANSI_1252") "Not Allowed in Model Space."))
  )
)

(setq x (getint "Enter how many layouts to be added"))
(repeat x)
 (addlayouts)
)

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Sign in to follow this  

×
×
  • Create New...