vki

set the extent of a dataframe

Discussion created by vki on Dec 7, 2011
Latest reply on Dec 7, 2011 by vki
In my script I select a feature (layer with definition query) and set the extent of the dataframe to the extent of this feature. This works fine, as long as just one feature is selected.
Sometimes though, two features need to be selected. In this case, I do get the extent of the features and I can set the extent of the dataframe, but nothing gets drawn.

Here's my code:

    Layer_xy.definitionQuery = DefinitionQuery

    newExtent = Layer_xy.getExtent(True)
#  newExtent = Layer_xy.getSelectedExtent(True)
    df.extent = newExtent
    df.panToExtent(df.extent)
    
    print "Extent of feature:\nXMin: %f, YMin: %f, \nXMax: %f, YMax: %f" % \
                      (df.extent.XMin,df.extent.YMin,df.extent.XMax,df.extent.YMax)


I tried it both with Layer_xy.getExtent and Layer_xy.getSelectedExtent and with or without panToExtent, with Layer_xy.getSelectedExtent(True) or (False), but nothing was ever drawn...

Any suggestions? Thanks for your help.
Vera

Outcomes