TBC Macros and Extensions

 View Only

TML - Copy Layer Group Members (V2)

By Gary Lantaff posted 12-05-2018 08:29

  

This TML will copy a layer group and all the layers (that have members) into a new layer group where the group and each layer is named the existing name with a prefix (or suffix). Just select the layer group and enter a layer/group prefix.

 

I have updated the macro to allow the "prefix" text to be place after the layer or layer group name. Just enter the "^" character for the first character in the name and the layer name will be first with the new text appended. So if "^-P2" entered for prefix text, the layer group would be named "old-name-P2"

 

There is also a checkbox to allow "replacing" the prefix text. In this case, the same number of characters contained in the prefix will be removed from the existing name. So if you wanted to copy a layer group named "P2-Road intersection line" to a group named "P3-Road intersection line", just enter "P3" for prefix and select the replace option. Note, this applies to all the newly created layer too.

 

The new layer group name is now displayed in the Textbox so it can be checked before pressing the "Ok" button.

After running cmd, the view filter will show the new group and all the layers.



10 comments
8 views

Permalink

Comments

02-27-2019 06:23

Hello Gary,

 

Had my first need to use this command today. Copied/created the group and layers as expected, however, the command also copied the members of the source layers as well. Is this intended? Did I do something incorrectly? If intended, would it be possible to add a checkbox in the macro to exclude the source group layer members and only copy the group, layer names and the layer properties? Thanks.

If the Replace Old Prefix box is checked before you enter the prefix with “^” you get this error message and TBC will shut down. Other wise it will work fine.

(Error 'startIndex must be less than length of string.

Parameter name: startIndex' while generating exception string)

 

Sent from Mail for Windows 10

01-18-2019 09:43

When using the "replace" option, the new layer group name will be displayed in the text box. If your text is at the end of the line, you still need to use the "^" character in addition to the replace option.

Example.

   Layer group name "Existing"

run command and enter "^-Phase2" for prefix text. That will create a new layer group named "Existing-Phase2"

If you then want to create another layer group from this one, enter "^-Phase3" and check the "Replace" option. This will remove the last seven characters (length of prefix string ignoring the ^ character) and then append the new string. You should now have a layer group named "Existing-Phase3".

The replace option is limited in that it only trims the same number of characters as the new prefix text.

 

What error message did you get?

Gary,     That will work to put the date at the end the first time, but if you check the box to replace the date for the second one you get this error message and it will remove from the front end text.

 

Sent from Mail for Windows 10

01-16-2019 19:18

If you put a ^ character as the first character in the prefix string, the

prefix will be put at the end of the old name.

Gary,     That is the idea I was thinking of, but I keep the dates on the end so the names line up in the view filter. Can this be changed to work from the end instead of the beginning?

 

Sent from Mail for Windows 10

01-16-2019 13:12

I have updated to TML so you can add suffix text instead of prefix text. It also now allows you to replace some of the text so changing the date should work (as long as same number of characters)

Was able to get the prefix on the end by switching it in the code. For more that one change is there a way to remove old date before the new prefix is added?

Is there a way to add the prefix to the end instead of the beginning. The layer groups that I make have the date on the end and when I have to make a new one the same  I just change the date on the end.

12-08-2018 05:54

Looks like it will certainly be useful. Thank you. 

Will give it a shot and report back with any comments.