I have written a script which allows me to select multiple feature classes and apply both a representation (based on a template layer) and set a transparency value before adding to the map. Unfortunately only the first layer receives the representation. What am I doing wrong?

import arcpy
mxd = arcpy.mapping.MapDocument("CURRENT")
df = arcpy.mapping.ListDataFrames(mxd, "*")[0]
addlayers = arcpy.GetParameterAsText(0) # featureclasses (multivalue entry)
theFolder = arcpy.GetParameterAsText(1) # workspace - geodatabase
theRep = arcpy.GetParameterAsText(2) # featureclass with representation
theValue = arcpy.GetParameterAsText(3) # Transparency value

# Set reference layer and create representations for selection
rep_layer = "{0}\{1}".format(theFolder,theRep)

# Add layers and transparency
theLayers = addlayers.split(";")
for layer in theLayers:
    lay = arcpy.mapping.Layer(layer.strip("'"))
    desc = arcpy.Describe(lay)
    for child in desc.representations:
        if child.dataType =="RepresentationClass":
            rep_name = "{0}_rep".format(desc.baseName)
    lay.transparency = int(theValue)

closed as unclear what you're asking by PolyGeo Feb 28 '17 at 22:12

Please clarify your specific problem or add additional details to highlight exactly what you need. As it's currently written, it’s hard to tell exactly what you're asking. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.

  • 3
    Shouldn't it be desc = arcpy.Describe(lay) instead of desc = arcpy.Describe(layer)? And why theRep is never used in the script? – Alex Tereshenkov Mar 17 '16 at 13:33
  • @AlexTereshenkov, well spotted, had to strip this out a bigger script so made a couple of mistakes transcribing,... – wunderkind Mar 19 '16 at 7:30
  • Please include print statements to show us a test value for each variable that you are receiving from your tool dialog. – PolyGeo Mar 25 '16 at 3:58