0

I want to use modelbuilder to apply symbology from layer file. I use "Apply Symbology From Layer" with one feature layer and one symbology layer as input.

In my map I often have many features with the same name, and therefore I want to loop through all the features and apply the same symbology, see attached picture.

The different input features are store in each separate geodatabase

But I can't figure out how to make this loop input function. Any tips?

enter image description here

EDIT 1: As response to first answer (new pictures):

ModelBuilder: enter image description here

To the left: TableOfContents (symbology). To the right:Run log

(The forth loop deletes symbology established in third loop.) enter image description here

EDIT 2: I tried to make a loop for each lyr-file, but it seems that I am only allowed to only add one iterator. Any tips how I can loop through the map, and link each layer in TOC to its corresponding lyr-file? Now I use "KpSamferdselPunkt" as wildcard in "Iterate Layers" to find the right layer in the first loop.

My idea was to make an iterator to each layer-type, see fig. below: enter image description here

2

If your layers are loaded into one map and you have at least ArcPro 2.7 then you could loop through your layers in the map using the iterate layers iterator. This avoids having to iterate over workspaces which would mean you would need have models within models.

4
  • Thanks. That works well! But when I have three layers, for example, modelbuilder loops through 4 times, and the forth time "Iterate layer" deletes the last symbology. See new picture in my first post (Im not allowed to post pics here). Any tips why the last loop deletes the last symbology?
    – gobrandal
    Apr 28 at 13:06
  • @gobrandal, no idea, does this error occur say if you have 5 layers in the toc?
    – Hornbydd
    Apr 28 at 14:59
  • It always occurs on the last layer. I can solve this by making a dummy layer as the last layer, but this is not so satisfactory :)
    – gobrandal
    Apr 29 at 7:20
  • Sounds like a bug in the tool? You should report it to esri.
    – Hornbydd
    Apr 29 at 8:12
0

1) "Iterate Layers":

Loop through each layer in TOC. Name of layer is stored as a string ("Name"), which is used in 2).

2) "Apply Symbology From Layer":

The lyr-file must have same name as layer in TOC

enter image description here

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.