Select to view content in your preferred language

How can I access to the Scale Text? in arcpy

774
3
09-06-2012 04:07 PM
AlmaMigens
Emerging Contributor
Hey there! I'm a newbie and I'm having some issues with this rutine, I have a .mxd with several parcels and I'm trying to make an arcpy rutine to identify the scale text among the layout element objects, I know Scale text belongs to MapSurround Elements, but I haven't found the way to acces to it! what I want is to export some selected parcels to a PDF only if they are of a certain scale, if I have 10 parcels with different scales, I want to export only the ones associated with this condition "Scale < 2000"



I always get this message:

AttributeError: 'MapSurroundElement' object has no attribute 'scaleText'



Here is what I've tried:



mxd = arcpy.mapping.MapDocument(r"D:\00salida\Plantilla_8x11.mxd")

for elm in arcpy.mapping.ListLayoutElements(mxd, "MAPSURROUND_ELEMENT"):

    if elm.scaleText < 2000:

        arcpy.mapping.ExportToPDF(mxd, r"\00salida\PDFS\C" + str(i) + ".PDF")

        pdfDoc = arcpy.mapping.PDFDocumentOpen(r"d:\00salida\PDFS\C" + str(i) + ".PDF")

        pdfDoc.appendPages(r"d:\00salida\posterior.pdf")

        pdfDoc.saveAndClose()

del mxd, elm

I hope someone can help me! :confused:

PS: English isn't my native language 😛
Tags (2)
0 Kudos
3 Replies
AlmaMigens
Emerging Contributor
I also tried this  :cool:


import arcpy, string

mxd = arcpy.mapping.MapDocument(r"D:\00salida\Plantilla_8x11.mxd")

for elm in arcpy.mapping.ListLayoutElements(mxd, "MAPSURROUND_ELEMENT", "Scale Text"):

    if elm.Text < 1350:

        arcpy.mapping.ExportToPDF(mxd, r"\00salida\PDFS\C" + str(i) + ".PDF")

        pdfDoc = arcpy.mapping.PDFDocumentOpen(r"d:\00salida\PDFS\C" + str(i) + ".PDF")

        pdfDoc.appendPages(r"d:\00salida\posterior.pdf")

        pdfDoc.saveAndClose()

del mxd
0 Kudos
JeffBarrette
Esri Regular Contributor
Rather than working with the scale text, have you considered working with the data frame scale?  Scale text is a string and it is formated differently than the actual data frame scale.  It possible to work with scale text but its far more work.

df = arcpy.mapping.ListDataFrames(mxd)[0]
if df.scale < 1350:
  #do something


Jeff
0 Kudos
AlmaMigens
Emerging Contributor
Ok Jeff I'll try to do it the way that you suggest


Thanks for the reply 😉
0 Kudos