9

This is related to the following Retain ESRI symbology in Mapinfo TAB . As an initial step (in arcpy) I want to access the symbology of all the datasets and create a document which has the details of the symbology as per the graphic below. enter image description here

Is this possible (should I invest the time to work it out) or if it isn't possible I will just have to get cracking on doing it manually on hundreds of MXD's (:-

To break down the steps -hopefully I can automate at least part of the process.

  1. scrolling through mxd's and getting the datasets that are on is no problem

    lyrFile = arcpy.mapping.Layer if lyrFile.visible == True:

  2. as it finds a dataset it should create a .lyr file (as most are just shp/gdb files) and then AttribXXX=lyrFile.xxx

where XXX and xxx are

BRIGHTNESS = lyrFile.brightness

(above format to following)

CONTRAST —contrast
DATASETNAME —datasetName
DATASOURCE —dataSource
DESCRIPTION —description
LABELCLASSES —labelClasses
LONGNAME —longName
NAME —name
SHOWLABELS —showLabels
TRANSPARENCY —transparency
WORKSPACEPATH —A layer's workspace or connection file path

The issue is I can't find anything that gets the RGB, line/point/polygon type, line weights, font etc. If these can be found then the next step

  1. write each of the values above to a CSV (easy)...for example (this has to be expanded)

                    f = open(origPath+'\\LayerAtrributes_LOG.txt', 'a')
                    f.write(str(DATASETNAME)+","+str(DATASOURCE)+","+str(DESCRIPTION)+","+str(MXDName)+"\n")
                    f.close()
    
  2. If possible a jpg of the symbology should be produced as in the example and the link to it added to the csv.

Am is asking to much of arcpy?

4
  • This may be possible with ArcObjects but definitely not arcpy.
    – blah238
    Commented Jun 20, 2012 at 6:17
  • thanks. Can anyone assist with the arcobjects processing then?
    – GeorgeC
    Commented Jun 20, 2012 at 6:27
  • Only can point you where to start: ArcObjects .NET SDK Help; Working with symbols and colors and Working with layers and renderers. If nothing else perhaps after reading through those you'll be able to define your requirements more precisely and limit the scope of work, because it will be a lot of work, I think.
    – blah238
    Commented Jun 20, 2012 at 6:39
  • Here's an old VB6 sample for exporting style symbols: Style Dump. Check StyleDump.bas for the meat of it.
    – blah238
    Commented Jun 20, 2012 at 7:01

2 Answers 2

3

I solved a similar problem by converting an MXD document to a MSD (which is just a zip file) so if you change the extension to ".zip" and open it you will find some .xml documents that contain alot of information about how each layer within the mxd is displayed. arcpy.ConvertToMSD There might be some work involed in getting the information you want but it should be in there somewhere. Hope that helps!

2
  • Thanks for this seminal idea. It is really helpful. The code generated in the xml is quite complex, did you program automatically capturing the relevant xml and if so can you share it, if not I will start working on this aspect.
    – GeorgeC
    Commented Jun 29, 2012 at 1:09
  • I was only interested in two values in the xml so anything I had will be very hard to build on. But there are heaps of really good python xml tutorials out there so if you are prepared to spend some time reading I'm sure you will solve the problem. Happy coding :)
    – dango
    Commented Jun 29, 2012 at 6:15
2

Basically this was not possible but figured out a roundabout way to get the result. See arcgis python script to tool issue for final result.

Other questions to get to this stage are

Converting ArcGIS style (symbology) to font for MapInfo/OpenGeo?

Retain ESRI symbology in Mapinfo TAB

and

Creating summary table of symbology of all datasets in multiple MXDs?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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