I am relatively new working with python and arcobjects. Under normal limitations I know that you cannot create a Legend or any arcobject with arcpy.mapping. Is there a generic example of creating a legend or an arcobject using comtypes to get me in the right direction?
I am trying to create as script to automate several maps and export them to jpg after. (All the code is figured out outside the codeblocks with comtypes)
I was able to figure out (with some search) how create a MXD but not sure which arcobjects to be replace for creating a legend with CreateObject.
import arcpy, os
from comtypes.client import GetModule, CreateObject
from Snippets import GetStandaloneModules, InitStandalone
arcpy.env.workspace = r"E:\foo"
wksp = arcpy.env.workspace
# Code that is out of the scope of the question
# Get the Carto module
esriCarto = GetModule(r"C:\Program Files (x86)\ArcGIS\Desktop10.2\com\esriCarto.olb")
for boro in boros:
# Create a map document object
mxdobj = CreateObject(esriCarto.MapDocument, interface=esriCarto.IMapDocument)
# Create a new borough mxd with mapping.MapDocument
print "Creating Wifi_{}.mxd".format(boro)
path = r"{}\Wifi_{}.mxd".format(wksp,boro)
print path
# Creates mxd
mxdobj.new(path)
#delete obj
del mxdobj
# Rest of the code