1

I have an issue where the ExportFrame would use the extent instead of the full extent after right clicking on arcmap and selected "Full extent".

Sometime it will use the ExportFrame of the full extent, sometime i will be the ExportFrame of the extent

This is two case where it should be similar, it is not consistent ;

this would be the proper one proper

this would be the incorrect one incorrect

code used(before this code is called, I'm doing a right click on the map and selecting "full extent");

IActiveView docActiveView = (IActiveView)ArcMap.Document.FocusMap;
docActiveView.Refresh();
var exportRECT = docActiveView.ExportFrame;
var pPixelBoundsEnv = new Envelope();

var bmp = new Bitmap(exportRECT.right, exportRECT.bottom);
var myGraphics = Graphics.FromImage(bmp);

pPixelBoundsEnv.PutCoords(0, 0, 0, 0);
myGraphics.Clear(System.Drawing.Color.Aqua);
docActiveView.Output((int)myGraphics.GetHdc(), 96, ref exportRECT, (IEnvelope)pPixelBoundsEnv, null);
myGraphics.ReleaseHdc();

bmp.Save(@"....");

Why do i get a inconsistency in this case?

edit #1

to remove the manual click on arcmap to reset to full extent, i added this before the code above but the behavior describe previously still happen at random time.

var uidFullExtent = new UID();

//esriArcMapUI.FullExtentCommand
uidFullExtent.Value = "{0830FB35-7EE6-11D0-87EC-080009EC732A}";
uidFullExtent.SubType = 3;
IMxDocument doc = (IMxDocument)ArcMap.Document;
ArcMap.Application.Document.CommandBars.Find(uidFullExtent).Execute();
//uncommenting this line make it seem to always produce the first screenshot (my expected behavior) 
//ArcMap.Application.Document.CommandBars.Find(uidFullExtent).Execute();

why calling the command twice would seem to fix my issue?

edit #2

this is (in my opinion) an ugly fix but seem to work...

private void fixBound()
{
    var uidFullExtent = new UID();

    //esriArcMapUI.FullExtentCommand
    uidFullExtent.Value = "{0830FB35-7EE6-11D0-87EC-080009EC732A}";
    uidFullExtent.SubType = 3;            

    IActiveView docActiveView = (IActiveView)ArcMap.Document.FocusMap;

    do
    {
        var fullEnvelope = docActiveView.FullExtent.Envelope;
        var boundEnvelope = docActiveView.ScreenDisplay.DisplayTransformation.ConstrainedBounds.Envelope; 

        bool same =
            fullEnvelope.YMin == boundEnvelope.YMin &&
            fullEnvelope.YMax == boundEnvelope.YMax &&
            fullEnvelope.XMin == boundEnvelope.XMin &&
            fullEnvelope.XMax == boundEnvelope.XMax;

        if (!same)
            ArcMap.Application.Document.CommandBars.Find(uidFullExtent).Execute();
        else
            break;

    }
    while (true);
}

is there a better way of getting what i'm expecting?

  • It looks like both extents have the same height but different widths, you need to adjust the pixel bounds not to ExportFrame and visible bounds to the minimum (i.e. extent of your data) see resources.arcgis.com/en/help/arcobjects-net/componenthelp/… about calculating the pixel bounds from a known extent (3rd example). – Michael Stimson Mar 15 '17 at 22:32
  • @MichaelMiles-Stimson thanks, i'm looking into it and i updated my question but i'm not sure playing with the visible bound would fix my issue. – Fredou Mar 16 '17 at 12:56

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.