Take the 2-minute tour ×
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

I would like to be able to develop a procedure that runs through all layers in the TOC and if the layer (name) exists in a specific folder where I am storing layer files with complex symbology I would like to import the procedure to import the symbology from the layer files. I have a similar procedure for importing stored Label schema so combining the two into a more dynamic solution would save me a lot of time. Thanks

share|improve this question

1 Answer 1

up vote 5 down vote accepted

A while back, I wrote some VB code to persist and de-persist renderers in ArcObjects. It's a slightly different spin on your question but I think what you need is there. The code can be found at: http://arcscripts.esri.com/details.asp?dbid=12474

I hope this helps.

Bill

share|improve this answer
    
Thanks Bill. I tried your script and just simply passed the path to the ".lyr" file as a parameter to the LoadRenderer procedure which raises an unspecified automation error. Any ideas? Thanks –  Jakub Oct 8 '10 at 20:29
    
OK. It does work. When i create an ".agl" file with the SaveRenderer procedure i can successfully load it into a layer. Can i make this work with existing Layer Files? –  Jakub Oct 8 '10 at 20:38
    
I suppose I should explain the intent of the code. A .lyr file saves the data source information and everything else necessary to recreate an object that implements ILayer. We didn't need that; we just wanted to save the renderer. As a result, it starts lower down in the object hierarchy. –  Bill Dollins Oct 9 '10 at 11:00
    
Here's a link to a discussion of handling .lyr files in C#: forums.esri.com/Thread.asp?c=159&f=1705&t=134959#391529 –  Bill Dollins Oct 9 '10 at 11:02
    
To open .lyr files, you should just be able to use the LayerFile coClass (edndoc.esri.com/arcobjects/9.2/ComponentHelp/esriCarto/…). With that, you can get at the layer through the ILayerFile.Layer property. You then need to cast it to an appropriate object (IGeoFeatureLayer for example) to get access to the Renderer property. –  Bill Dollins Oct 9 '10 at 11:07

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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