jan.rykr

Symbol Rotation Error when Exporting to AI using arcpy

Discussion created by jan.rykr on Apr 17, 2018

Symbols end up being non rotated when exporting to AI or PDF using arcpy in Arcmap 10.4.1.

When exporting through standard way (File>Export>...) everything works fine. But when exporting using arcpy the symbols end up non rotated. This behaviour affects both standard and data driven mxds.

 

The symbols are rotated based on a field value in symbology:

 

 

The layers in MXD appear like this:

MXD

However, in Illustrator file or PDF file the symbols all face north:

 

The code I am using:

import arcpy, os

MapMainFolder = r"Z:\Workspace"  # topmost folder
AIoutLoc = r"J:\CURRENT PROJECTS"
for (root, dirs, files) in os.walk (MapMainFolder):
  for fileName in files:
    if os.path.splitext (fileName)[1] == ".mxd":
      arcpy.AddMessage (fileName)
      fullPath = os.path.join (root, fileName)
      mxd = arcpy.mapping.MapDocument (fullPath)
      print fileName
      df = arcpy.mapping.ListDataFrames(mxd, "Layers")[0]
     
#ungoup layers
      for lyr in arcpy.mapping.ListLayers(mxd, "*", df):
          depth = len(lyr.longName.split("\\"))
          if depth == 1:
              refLayer = lyr
          elif depth == 2:
              moveLayer = lyr
              arcpy.mapping.MoveLayer(df, refLayer, moveLayer, "BEFORE")

      arcpy.RefreshTOC()     
     
#export AI     
      ai = fileName.replace (".mxd",".ai")
      AIpath = os.path.join (AIoutLoc,ai)
      arcpy.AddMessage ("Exporting " + ai)
      arcpy.mapping.ExportToAI(mxd,AIpath,"PAGE_LAYOUT",0,0, resolution=300, image_quality="BEST", convert_markers="true")

 

 

A workaround I found is to convert the symbology of each layer to graphics but given the number of MXDs I need to export it is not a permanent solution.

Possible options I can think of but don't know how to do:

  • Edit the export arcpy script (below)
  • Batch convert the symbology to graphics in each MXD
  • ...else?

 

Thanks for Help!

Attachments

Outcomes