Jump to content

Merging Layers


Recommended Posts

On second thought: as this certainly is a problem for many who do not have Architect or Landmark, here are two scripts that enable more intelligent layer remapping.

 
PROCEDURE LayerMappingData; { ? Petri Sakkinen 1998 - 2007 }

VAR 
layerCount, counter, rowNo : INTEGER; 
layerName : STRING; 
theLayer, theWorksheet : HANDLE; 

BEGIN
layerCount := NUMLAYERS + 1;
theLayer := FLAYER;
theWorksheet := GETOBJECT('Layer mapping');
DELOBJECT(theWorksheet);
theWorksheet := CREATEWS('Layer mapping',layerCount, 2 );
SELECTSS(theWorksheet);
LOADCELL(1, 1, 'Layer name');
LOADCELL(1, 2, 'Mapped to');
FOR rowNo := 2 TO layerCount DO BEGIN 
	layerName := GETLNAME(theLayer);
	LOADCELL(rowNo, 1, layerName);
	theLayer := NEXTLAYER(theLayer);
END;
END;

RUN(LayerMappingData);

PROCEDURE RemapLayers; { ? Petri Sakkinen 1999 - 2007 } 
VAR 
n, i, rowCount, colCount : INTEGER; 
oldLayer, newLayer  : STRING; 
theWorksheet, theLayer : HANDLE; 
ok : BOOLEAN; 

PROCEDURE RemapLayer (h : HANDLE);
BEGIN
   ok := SETPARENT(h, theLayer); 
END;

BEGIN 
theWorksheet := GETOBJECT('Layer mapping');
SPRDSIZE(theWorksheet, rowCount, colCount);
SELECTSS(theWorksheet);
FOR n := 2 TO rowCount DO BEGIN  
	oldLayer := GETCELLSTR(theWorksheet, n, 1);
	newLayer := GETCELLSTR(theWorksheet, n, 2);
	IF NOT(newLayer='') THEN BEGIN 
		theLayer := GETLAYERBYNAME(newLayer); 
		FOREACHOBJECT(RemapLayer, L = oldLayer); 
	END;
END;
END;

RUN(RemapLayers);

So, first you run LayerMappingData, which creates a worksheet with all layer names.

Then for those layers you want to merge with another layer, type (or paste) the name of the new layer into column B of the worksheet.

Finally you run RemapLayers.

If you get data with the same setup frequently, import the worksheet into the new file and just run RemapLayers.

And what the heck, I'm in a generous mood. One more - this groups everything on each layer. It may be a wise thing to do before merging because you can (with some effort) get the contents of one layer extracted.

PROCEDURE Layers2groups;  { ? Petri Sakkinen 1995 - 2007 }
VAR 
theLayer : HANDLE; 
layerName : STRING; 
ok : BOOLEAN;
BEGIN
theLayer := FLAYER; 
ok  :=  YNDIALOG('This macro sets your layer options to active only');
IF ok THEN BEGIN 
	DOMENUTEXTBYNAME('Layer options', 1);
	WHILE NOT(theLayer = NIL) DO BEGIN;
		LayerName:=GETLNAME(theLayer);
		LAYER(LayerName);
		SELECTALL; 
		GROUP;
		theLayer := NEXTLAYER(theLayer); 
	END;		
END;
END;
RUN(Layers2groups);

Link to comment
  • 2 weeks later...

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