Jump to content

Place layout copy next to the original


itacad

Recommended Posts

Hello, I have a stupid problem but how often I do this makes it become important.

Is it possible to create a copy of a layout by placing it near to the original layout?

I have files with many layouts, and this operation forces me to waste time every time to move the new layouts created (which are placed either at the beginning or at the end of existing layouts).

Thanks in advance for any help

Link to comment
Share on other sites

15 hours ago, itacad said:

Hello, I have a stupid problem but how often I do this makes it become important.

Is it possible to create a copy of a layout by placing it near to the original layout?

I have files with many layouts, and this operation forces me to waste time every time to move the new layouts created (which are placed either at the beginning or at the end of existing layouts).

Thanks in advance for any help

A simple google copy of a layout

Link to comment
Share on other sites

I think Itacad wants like copy layout3 so new is now layout4 not layout23. A copy is added to end of layouts.

 

You can reset the layout order so get layout name to be copied and find its current postion then find last and push all layouts to new order.

 

Note need to remove "MODEL" from the vla-get-layouts.

 

Started it but struggling for time. 

Link to comment
Share on other sites

Thanks everyone for your opinions, I know TabSort lisp very well and it saves me a lot of time! that is great!

Unfortunately, when working with files of up to 240 layouts, the trivial operation of creating a copy of a layout but finding it "distant" from the original wastes a lot of time for moving.
Fortunately TabSort speeds up the sorting operation a lot

 

Link to comment
Share on other sites

  • 2 weeks later...

Sorry it took so long I lost my to do list and found again. Give this a try.

; https://www.cadtutor.net/forum/topic/76384-place-layout-copy-next-to-the-original/
; By Alanh DEC 2022

(defun c:tab-after ( / tabs pos1 pos2 lst lst2 x cnt layname layname2)
(vl-load-com)
(setq layname (strcase (getstring "\nEnter Layout name to copy ")))
(setq layname2 (getstring "\nEnter New layout name "))

(command "layout" "C" layname layname2)
(setq tabs (vla-get-Layouts (vla-get-Activedocument (vlax-get-acad-object))))
(setq cnt (- (vla-get-count tabs) 1))
(setq lst '())
(vlax-for tab tabs 
  (setq lst (cons (list (vla-get-TabOrder tab) (vla-get-name tab) ) lst))
)
(setq lst (vl-remove (list 0 "Model") lst))
(setq lst (vl-sort lst '(lambda (x y) (< (car x)(car y)))))

(setq x 0 lst2 '())

(repeat (- (length lst) 1)
  (if (= (strcase (cadr (nth x lst)))layname)
  (progn
  (setq lst2 (cons (nth x lst)  lst2))
  (setq lst2 (cons (last lst) lst2))
  ) 
  (setq lst2 (cons (nth x lst)  lst2))
  )
  (setq x (1+ x))
)
(setq lst2 (reverse lst2))

(setq cnt 1)
(foreach lay lst2
  (vla-put-taborder (vla-item (vla-get-layouts (vla-get-activedocument (vlax-get-acad-object)))(cadr lay)) cnt)
  (setq cnt (1+ cnt))
)

(setvar 'ctab layname2)
(princ "\nTo run again type tab-after ")
(princ)
)
(c:tab-after)

 

We used a simple layout naming convention D01 D02 etc so for me the extra step is do a rename of all layouts to new order. The other is renumber the sheet numbers in the title blocks in the layouts.

Edited by BIGAL
Link to comment
Share on other sites

Thank you for your works! I tried it and I report this anomaly:

At the end of the lisp execution, the new layout is created to the right of the layout indicated for copying, but between them is placed the last layout that already existed before the lisp execution.

Maybe it depends on the method I name the layouts?

 

 

Link to comment
Share on other sites

I did not do anything about checking layout names, yes d01 is different to D01, if wrong will add to end, have adjusted code to removes case problem.

Edited by BIGAL
Link to comment
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
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  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.

×
×
  • Create New...