Solved! Go to Solution.
import arcpy, os from arcpy import mapping as m arcpy.env.overwriteOutput = True mapPath = r'C:\Users\GIS\Desktop\maptest.mxd' outpath = r'C:\Users\GIS\Desktop\Exports' mxd = m.MapDocument(mapPath) df = m.ListDataFrames(mxd)[0] # Loop through layers for lyr in m.ListLayers(mxd, 'Buildings*'): lyr.visible = True lyr.showLabels = True # I'm assuming this is where you have the properties? jpg = os.path.join(outpath, lyr.name + '.jpg') m.ExportToJPEG(mxd, jpg) print 'Exported %s' %jpg lyr.visible = False del mxd
Yes, this can be done with Python. I did a simple test where I just had 12 building layers and roads were my lines and turned off all buildings layers. I numbered them like Building1, Building2, etc. In your case you may want to give the layers a more descriptive name. I used a wildcard to search for all layers that start with 'Buildings*' and looped through to turn only that layer on (lines layer is always on). I am assuming your properties you want to show are set up as a label?import arcpy, os from arcpy import mapping as m arcpy.env.overwriteOutput = True mapPath = r'C:\Users\GIS\Desktop\maptest.mxd' outpath = r'C:\Users\GIS\Desktop\Exports' mxd = m.MapDocument(mapPath) df = m.ListDataFrames(mxd)[0] # Loop through layers for lyr in m.ListLayers(mxd, 'Buildings*'): lyr.visible = True lyr.showLabels = True # I'm assuming this is where you have the properties? jpg = os.path.join(outpath, lyr.name + '.jpg') m.ExportToJPEG(mxd, jpg) print 'Exported %s' %jpg lyr.visible = False del mxd
You could get a lot more fancy with this, but this should get you started in the right direction. Since you are at 10.1, you have more control over the legend and you can turn on/off the auto-add feature to add the current layer inside the loop to the legend.
Here is a shot of my map and the folder with all the output jpgs.
[ATTACH=CONFIG]24423[/ATTACH][ATTACH=CONFIG]24424[/ATTACH]
Ok, I made it into a script tool for you. You can open this up inside the current map and run it from the toolbox like any other tool. It takes one parameter, which will be the output folder for all your .jpg files. I tested this on the UntitledII.mxd and it worked fine.
Ok, I made it into a script tool for you. You can open this up inside the current map and run it from the toolbox like any other tool. It takes one parameter, which will be the output folder for all your .jpg files. I tested this on the UntitledII.mxd and it worked fine.
Ok, I made it into a script tool for you. You can open this up inside the current map and run it from the toolbox like any other tool. It takes one parameter, which will be the output folder for all your .jpg files. I tested this on the UntitledII.mxd and it worked fine.
Executing: Script2 Start Time: Sun May 19 12:00:47 2013 Running script Script2... <type 'exceptions.SyntaxError'>: invalid syntax (<string>, line 26) Failed to execute (Script2). End Time: Sun May 19 12:00:47 2013 (Elapsed Time: 0.00 seconds)
Hi Jamal,
I was able to alter the tool to do what you wanted, however, every time I run it ArcMap freezes after it is complete. It properly exports all the jpgs but then I have to force close ArcMap afterwards. I do not really know what is going on with that, I could not figure out what is causing the issue. I played around with deleting the mxd object, refreshing the active view and a few others but same result every time, I don't know why. See if you can reproduce this issue. Here is the tool, hopefully it will work without freezing ArcMap for you.
If anyone else tests this out (v 10.1 tool) and can figure out why it might be crashing ArcMap I would love to know!
Hi,
I wanted to use your tool in my project but when i'm trying to run it's end up with the below error. i missed something..???
I'm using Arcmap 9.3.1..Executing: Script2 Start Time: Sun May 19 12:00:47 2013 Running script Script2... <type 'exceptions.SyntaxError'>: invalid syntax (<string>, line 26) Failed to execute (Script2). End Time: Sun May 19 12:00:47 2013 (Elapsed Time: 0.00 seconds)
Can you please guide me step by step.. because i'm very new to python programming...i wanted to learn it by doing...please help me..!!
Thanks..