Setting custom full extent?

450
3
12-14-2010 11:17 AM
StephenKilburn
New Contributor III
Using (still) 9.3.1:

The IActiveView diagram shows the FullExtent property as being Get/Put.

What I want to do is programatically override the default full extent, i.e. have a program do the equivalent of View > Data Frame Properties... > Extent Used By Full Extent Command: Other > Specify Extent (specify custom extent).

But when I do the following:

Dim pMxDocument As IMxDocument
Dim pMap As IMap
Set pMxDocument = Application.Document
Set pMap = pMxDocument.FocusMap
Dim pActiveView As IActiveView
Set pActiveView = pMap
' let's presume we want to use the current extent, and it is different from the current full extent
pActiveView.FullExtent = pActiveView.Extent
' or
pActiveView.FullExtent.PutCoords pActiveView.XMin, pActiveView.YMin, pActiveView.XMax, pActiveView.YMax


The FullExtent property stubbornly remains as the extent of all layers.

I'm left wondering whether the Map.RecalcFullExtent method is being fired when I change FullExtent and changing the envelope back to one surrounding all layers.

Does anyone have any suggestions or insight?
0 Kudos
3 Replies
NeilClemmons
Regular Contributor III
I could be wrong but I believe IActiveView.FullExtent is automatically calculated and this will overwrite any custom value you set.  In order to set a custom full extent, I believe you need to set IMap.AreaOfInterest.
0 Kudos
StephenKilburn
New Contributor III
I could be wrong but I believe IActiveView.FullExtent is automatically calculated and this will overwrite any custom value you set.  In order to set a custom full extent, I believe you need to set IMap.AreaOfInterest.


You're right. I thought maybe I should be looking at an attribute of the Map, but I missed that one (even though I'm actually setting the default extent to an IRasterLayer.AreaOfInterest --should have figured that one out!)

Thanks!
0 Kudos
AkhilParujanwala
New Contributor III
I was just about to make a thread about this exact question. I tried searching but couldn't find an answer, but I decided to perform one last search, which was "custom extent dd", and I saw this thread.

*Sorry for resurrecting an old thread.

Thank you so much for posting the answer, this worked perfectly, I am providing my code below for anyone who is having difficulties. I too overlooked the AreaOfInterest property.

[PHP]
        public static void SetDataFrameACustomFullExtent(IMapDocument pMapDocument)
        {         
            IActiveView pActiveView = pMapDocument.ActiveView;

            IEnvelope pEnvelope = new EnvelopeClass();           
            pEnvelope.XMax = 86.343146273; //Change these numbers to your numbers
            pEnvelope.XMin = -86.343146273;
            pEnvelope.YMax = 55.036972317;
            pEnvelope.YMin = -55.036972317;

            pMapDocument.Map[0].AreaOfInterest = pEnvelope;
        }
[/PHP]

THANKS!
0 Kudos