VBA: Update Feature Class Extent PDF Print E-mail

Written by Bert Granberg,

Occasionally, after editing a feature class the spatial extent (a.k.a. bounding rectangle) associated with the feature class is not updated. This means that if you had a feature class of Utah National Parks and when you loaded the data initially, you accidently included Yosemite NP in California as a feature, a Zoom to Layer command would zoom to a much bigger geographic area, even after you deleted the Yosemite Park feature. Here's how to use it:

  1. Paste this script (below) into ArcCatalog's VBA editor (Tools --> Macros --> VBA Editor)
  2. Back in ArCatalog, select the feature class in the Contents tab view (not in the left hand tree view)
  3. Back in VBA Editor, click your mouse anywhere in this new script and hit the run button (blue triangle)
Public Sub updateFCExtent()
Dim pGXApplication As IGxApplication
Set pGXApplication = Application

Dim pGxObject As IGxObject
Set pGxObject = pGXApplication.SelectedObject

If Not TypeOf pGxObject.InternalObjectName Is IFeatureClassName Then
Exit Sub
End If

Dim pName As IName
Set pName = pGxObject.InternalObjectName
Dim pSchemaLock As ISchemaLock
Set pSchemaLock = pName.Open

pSchemaLock.ChangeSchemaLock esriExclusiveSchemaLock
Dim pFeatureClassManage As IFeatureClassManage
Set pFeatureClassManage = pSchemaLock
pFeatureClassManage.UpdateExtent

Exit Sub

ErrHandler:
pSchemaLock.ChangeSchemaLock esriSharedSchemaLock
End Sub
 
'SRC = http://edndoc.esri.com/arcobjects/9.2/ComponentHelp/
esriGeoDatabase/IFeatureClassManage_UpdateExtent_Example.htm

Users' Comments  
 

No comment posted

Add your comment

21, Oct. 2008
Last Updated ( 21, Oct. 2008 )
 
< Prev   Next >

AGRC Contacts | UGIC Contacts

feed image feed image

Utah GIS Portal © 2009 AGRC

Optimized for