Symbology & changing versions - a total newbie needs help

669
0
12-27-2013 09:41 AM
AshleyC
New Contributor
Python beginner here. I know what I want to do, but I don't know what all the parts of code are called, so I'm hoping someone can bear with me and help.

I'm working on a script to add layers to a blank mxd, set the symbology of each layer, and convert the mxd to version 9.3 (per project requirements). The geodatabase has to stay in 9.3 also.

A script is already in place that creates the blank mxd (copies a template), a blank geodatabase with 5 polylines, and a couple other shapefiles in the main model folder. I've gotten a script to work using arcpy that pulls in the all those things into the map in the correct order. I've created a template model with all the symbology I want, and have created .lyr files of everything. What I need to do now is get that symbology applied to the folder that I'm inputting (which is Test_Cr right now), save the mxd in version 9.3, and make sure the geodatabase stays in 9.3.

If the map I'm starting with is v10_Test_Cr.mxd, the one that will be used is Test_Cr.mxd and v10 will get deleted.

I must be missing something, because I'm not getting an error but the symbology is not changed in either Test_Cr or v10_Test_Cr after the script is run. I know I also have a lot of extra lines of junk, mostly because I don't know what everything does and I'm copying from various places .



---
import arcpy
import os
import shutil
import sys
import arcgisscripting
from arcpy import env

gp = arcgisscripting.create(9.3)

OutputFolder = gp.GetParameterAsText(0)

gp.workspace = OutputFolder
arcpy.env.workspace = OutputFolder
model_path = OutputFolder

(head,tail) = os.path.split(model_path) # model path split
Reach_Code = tail # just reach code

#symbology locations
Symbology = r"F:\Script\Symbology"
Symbology_mxd = r"F:\Script\Symbology\Symbology.mxd"

mxd = arcpy.mapping.MapDocument(r"F:\Test_Cr\v10_Test_Cr.mxd")

# make geometry feature classes into layers
arcpy.MakeFeatureLayer_management(r"F:\Test_Cr\Test_Cr.mdb\Layers\River_Test_Cr", "Riverlyr")

# Save geometry layers as .lyr files
arcpy.SaveToLayerFile_management("Riverlyr", "Riverlyr.lyr")

#shortcuts for geometry layer files
River_Map = r"F:\Test_Cr\Riverlyr.lyr"

# shortcuts for symbology layer files
River_Symb = r"F:\Script\Symbology\Layers\River_Symbology.lyr"

#apply symbology
arcpy.ApplySymbologyFromLayer_management(River_Map, River_Symb)

mxd.save()
mxd.saveACopy(r"F:\Test_Cr\Test_Cr.mxd", '9.3')
Tags (2)
0 Kudos
0 Replies