Visual LISP, AutoLISP and General Customization
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Layout order

9 REPLIES 9
Reply
Message 1 of 10
sujeev
4755 Views, 9 Replies

Layout order

Hi all

 

I am looking for a lisp that will rename all the layouts automatically. I tried the Layoutlist function but the output is not in order. Is there anyway that i can get all the layouts in a drawing from left to right order. for eg. i have layouts from layout1, layout 2........layout10). The layoutlist returns as layout1,layout10 etc...instead of layout 1 layout 2.

 

Can somebody help

 

Thanks and regards

 

sujeev

9 REPLIES 9
Message 2 of 10
devitg
in reply to: sujeev

As a own matter of the PC processor , the natural order is 

1 10 11..............19 2 21 ......................29 3  and so on 

If you have more than 10, up to 99 layouts you shall name 01 02 03 ...................09 10 11 .................19.20 .............................99

If it are more than 100 up to 999  layouts you shall name 001 002 003 .................009...... ........999

Message 3 of 10
Kent1Cooper
in reply to: devitg


@Anonymous wrote:
I am looking for a lisp that will rename all the layouts automatically. I tried the Layoutlist function but the output is not in order. Is there anyway that i can get all the layouts in a drawing from left to right order....
@devitg wrote:

... the natural order is 

1 10 11..............19 2 21 ......................29 3  and so on 

....


However, no matter how you number or name the Layouts, sorting them into some kind of order [numerically or otherwise] will not give you their left to right order in the tabs at the bottom of the drawing [unless, of course, that order coincidentally agrees with the sorted order].  The (layoutlist) function doesn't return them that order, but always sorted by name.  I have a drawing in which I added a couple of new Layouts and let AutoCAD give them the default names, so that:

 

Command: (layoutlist)

returns
("Layout1" "Layout2" "Layout3")

 

Then I moved Layout1 to the end [far right tab], but (layoutlist) still returned the same thing, with "Layout1" listed first.

 

EDIT:  Check this out:

http://forums.autodesk.com/t5/Visual-LISP-AutoLISP-and-General/LAYOUT-Tab-order/m-p/842023/highlight/true#M67681

A more extensive Search could well lead to more directly applicable threads.

Kent Cooper, AIA
Message 4 of 10
pbejse
in reply to: sujeev


@Anonymous wrote:

Hi all

 

I am looking for a lisp that will rename all the layouts automatically. I tried the Layoutlist function but the output is not in order. Is there anyway that i can get all the layouts in a drawing from left to right order. for eg. i have layouts from layout1, layout 2........layout10). The layoutlist returns as layout1,layout10 etc...instead of layout 1 layout 2.

 

Can somebody help

 

Thanks and regards

 

sujeev


(defun Layorder (/ order)(vl-load-com)
      (vlax-for
             lay (vla-get-layouts (vla-get-ActiveDocument (vlax-get-acad-object)))
            (setq order (cons
                              (list (vla-get-name lay)
                                    (vla-get-taborder lay))
                              order
                              )
                  )
            )
      (mapcar 'car (Cdr (vl-sort order '(lambda (j k)
                        (< (cadr j) (cadr k))
                        )
                 )
           )
      )
      )

 

 (layoutorder)

 

HTH

 

Message 5 of 10
devitg
in reply to: pbejse

From

ø¤º°`°º¤ø TabSort.lsp ~ Copyright © by Lee McDonnell ø¤º°`°º¤ø
~¤~ ...Type "TabSort" to Invoke... ~¤~

 

 

Message 6 of 10
irishrandy26
in reply to: devitg

I am looking to close make a quick command that closes the drawing I am in, but I want it to select the first layout tab that isn't model space. The problem I am running into is every drawing has a different name for that layout tab. Is there any way of doing this?

 

Message 7 of 10
hmsilva
in reply to: irishrandy26


@irishrandy26 wrote:

I am looking to close make a quick command that closes the drawing I am in, but I want it to select the first layout tab that isn't model space. The problem I am running into is every drawing has a different name for that layout tab. Is there any way of doing this?

 


Before save and close, try

 

(vl-load-com)
(vlax-for layt
	  (vla-get-layouts (vla-get-ActiveDocument (vlax-get-acad-object)))
  (if (= (vla-get-TabOrder layt) 1)
    (setvar 'CTAB (vla-get-Name layt))
  )
)

 

HTH

Henrique

EESignature

Message 8 of 10
pbejse
in reply to: hmsilva

Another

 

(setq ly (vla-get-layouts (vla-get-ActiveDocument (vlax-get-acad-object))))
(setvar	'CTAB
	(vl-some '(lambda (l)
		    (if	(= (vla-get-TabOrder (vla-item ly l))
			   1
			)
		      l
		    )
		  )
		 (layoutlist)
	)
)

 

 HTH

 

Message 9 of 10
alanjt_
in reply to: pbejse

Slight mod on pb's...

 

((lambda (layouts)
   (vl-some (function (lambda (layout)
                        (if (eq (vla-get-taborder (vla-item layouts layout)) 1)
                          (setvar 'CTAB layout)
                        )
                      )
            )
            (layoutlist)
   )
 )
  (vla-get-layouts (vla-get-activedocument (vlax-get-acad-object)))
)

 

Message 10 of 10
irishrandy26
in reply to: alanjt_

Thank you all for your help!

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report

”Boost