Jump to content
Sign in to follow this  
Pat Stanford

Sort Layers By Name

Recommended Posts

A members of the Los Angeles users group requested a way to sort the layers in a file. The attached script does exactly that.

Procedure SortLayers;
{Sorts Layers into Alphabetical Order}
{Very Lightly Tested. Save File Before Using}
{It is the users responibility to maintain a current backup before using this script}
{Use at your own risk.}

{February 28, 2012}
{? 2012, Coviana, Inc - Pat Stanford pat@coviana.com}
{Licensed under the GNU Lesser General Public License}



Type	LayerStruct = Structure
		LayerName: String;
		LayerHandle:	Handle;
End;


Var		MyLayer:	Handle;
	MyName:		String;
	MyCount:	Integer;
	MyArray:	DYNARRAY of LayerStruct;
	ArrayCount:	Integer;
	LoopCount:	Integer;


Begin
MyCount:=NumLayers;
Allocate MyArray[1..Mycount];

MyLayer:=FLayer;
ArrayCount:=1;
While MyLayer <> Nil do
	Begin
		MyArray[ArrayCount].LayerName:=GetLName(MyLayer);
		MyArray[ArrayCount].LayerHandle:=MyLayer;
		ArrayCount:=ArrayCount+1;
		MyLayer:=NextLayer(MyLayer);
	End;

ArrayCount:=ArrayCount-1;
SortArray(MyArray,ArrayCount,1);

For LoopCount := ArrayCount downto 1 do
	Begin
		MyLayer:=MyArray[LoopCount].LayerHandle;
		HMoveForward(MyLayer,True);
	End;

End;

Run(SortLayers);

Share this post


Link to post

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

 

7150 Riverwood Drive, Columbia, Maryland 21046, USA   |   Contact Us:   410-290-5114

 

© 2018 Vectorworks, Inc. All Rights Reserved. Vectorworks, Inc. is part of the Nemetschek Group.

×