PictureElement

Zusammenfassung

Provides access to properties that enable its repositioning on the page layout as well as getting and setting its data source

Beschreibung

The PictureElement object represents a raster or image that has been inserted into a page layout. In addition to the standard element properties, the PictureElement is unique in that is has a sourceImage property that allows you to read or modify the source location. The ListLayoutElements function returns a Python list of page layout element objects. It is necessary to then iterate through each item in the list or specify an index number to reference a specific page element object. To return a list of only PictureElements, use the PICTURE_ELEMENT constant for the element_type parameter. A wild card can also be used to further refine the search based on the element name.

It is recommended that each page layout element be given a unique name so that it can be easily isolated using arcpy scripting. X and y element positions are based on the element's anchor position, which is set via the Size and Position tab on the Elements Properties dialog box in ArcMap.

Eigenschaften

EigenschaftErläuterungDatentyp
elementHeight
(Lesen und schreiben)

The height of the element in page units. The units assigned or reported are in page units.

Double
elementPositionX
(Lesen und schreiben)

The x location of the data frame element's anchor position. The units assigned or reported are in page units.

Double
elementPositionY
(Lesen und schreiben)

The y location of the data frame element's anchor position. The units assigned or reported are in page units.

Double
elementWidth
(Lesen und schreiben)

The width of the element in page units. The units assigned or reported are in page units.

Double
name
(Lesen und schreiben)

The name of the element.

String
sourceImage
(Lesen und schreiben)

A text string that represents the path to the image data source.

String
type
(Nur lesen)

Returns the element type for any given page layout element.

  • DATAFRAME_ELEMENTData frame element
  • GRAPHIC_ELEMENTGraphic element
  • LEGEND_ELEMENTLegend element
  • MAPSURROUND_ELEMENTMap surround element
  • PICTURE_ELEMENTPicture element
  • TEXT_ELEMENTText element
String

Codebeispiel

PictureElement example

The following script will find an image by name and set its data source to a new location.

import arcpy
mxd = arcpy.mapping.MapDocument(r"C:\Project\Project.mxd")
for elm in arcpy.mapping.ListLayoutElements(mxd, "PICTURE_ELEMENT"):
    if elm.name == "Photo1":
        elm.sourceImage = r"C:\Project\Data\Photo.bmp"
mxd.save()
del mxd

7/10/2012