Quantcast
Channel: Question and Answer » arcpy
Viewing all articles
Browse latest Browse all 767

ArcPy: No Label appear on .pdf output but are present in Layout

$
0
0

Do labels needed to be coded into an arcpy script in order to be visible on an arcpy .pdf output? In ArcGIS the labels are visible for various features, but when I use the arcpy script (either in IDLE or in ArcGIS directly) only certain labels appear. I’ve checked the Label manager and verified the expressions (i.e. making sure they’re visible at a large scale (1:1000) but everything looks ok). Interestingly, it’s only the labels for the features that are run through the script that don’t appear. Any thoughts would be much appreciated

Edit:
I’ve checked to make sure the layers are visiblelabel manager view

Two things that are additionally weird: 1) every time I run the code I get a slightly different result, i.e. some with label, some without, and 2) although the code is producing the right number of individual .pdfs, they are all for the same record, i.e. there are 17 .pdfs produced for 17 records, but each one is the same (I know this last part is likely considered a second question, but something tells me they’re related).

Here’s the full code:

mxd = arcpy.mapping.MapDocument("C:\temp\Graffiti_DM3.mxd")
df = arcpy.mapping.ListDataFrames(mxd, "*")[0]
graffitilyr=arcpy.mapping.ListLayers(mxd, "*", df)[0]

newquery = '"Incident_Z" =' + "'10003'"
graffitilyr.definitionQuery=newquery
features = arcpy.SearchCursor(graffitilyr)
count = 1

print "let's get started"
for feature in features:
        df.rotation = "0"
        arcpy.SelectLayerByAttribute_management(graffitilyr, "NEW_SELECTION", "FID=" + str(count))
        #df.extent = graffitilyr.getSelectedExtent(True)
        df.zoomToSelectedFeatures()
        df.scale = df.scale * .004
        arcpy.RefreshActiveView()
        df.panToExtent(graffitilyr.getSelectedExtent())
        #df.scale = "1000"
        outpdf="C:\temp\" + str(count) + ".pdf"
        arcpy.mapping.ExportToPDF(mxd,outpdf)
        count = count+1

Viewing all articles
Browse latest Browse all 767

Trending Articles