Jump to content

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);

Link to comment

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.   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...