English

Problem: Unable to incorporate representations in a feature layer for a stand-alone Python script

Description

Existing representations can be incorporated in a feature layer for use with cartography tools such as the Align Marker To Stroke Or Fill tool. However, in some cases these tools fail when running a stand-alone Python script and returns the following error:

Error 000802: The layer does not contain a representation

Below is a sample code that may return the error:

featureLayer=arcpy.MakeFeatureLayer_management(fcName, "Name Of Feature Layer")

arcpy.AlignMarkerToStrokeOrFill_cartography(featureLayer, input2, bufferDistance, "PERPENDICULAR")

Cause

The Set Layer Representation tool used to associate the source's feature class representation with the feature layer is temporarily stored in ArcMap memory. Once ArcMap is closed, the representation is no longer associated with the feature layer, returning the error when running the stand-alone Python script.

Solution or Workaround

To incorporate the tool with the representation, the SetLayerRepresentation_cartography() method must be included in the code. This ensures the feature class is associated with the representation stored in the memory. The following is the code sample:

featureLayer=arcpy.MakeFeatureLayer_management(fcName, "Name Of Feature Layer")

setRepresentation=arcpy.SetLayerRepresentation_cartography(featureLayer, "Name of the Representation")

arcpy.AlignMarkerToStrokeOrFill_cartography(setRepresentation, input2, "Buffer Distance", "PERPENDICULAR")

Related Information