Title: Problem Solving with ArcObjects
1Problem Solving with ArcObjects
- Brent Hedquist
- GIS III
- Lab 3 Part 2
2Describe the problem in ArcObjects terms
- Add x and y coordinates to attribute table of the
selected point layer.
3Identify Subtasks
- Subtask 1 Define the document and layer in use
- Subtask 2 Create a feature class and import
selected layer - Subtask 3 Create new fields in attribute table
- Subtask 4 Find the first feature, then the
extent of each point. - Subtask 5 Add the position of each point and
save, then repeat as necessary until ending loop.
4Decide where to write code
- VBA Macro in ArcGIS application using a
UIButtonControl click option.
5Find an existing sample or recommended methodology
Procedure on how to put X and Y coordinates in
context
6Find an existing sample or recommended methodology
Question regarding X,Y coordinates answered On
ESRI Listserv
7Part Two 1) Identify a Subtask
- Create new fields in attribute table
Subtask 3 code Dim xfield As IFieldEdit Dim
yfield As IFieldEdit Set xfield New Field Set
yfield New Field With xfield .Type 3 .name
"XFIELD" End With With yfield .Type 3 .name
"YFIELD" End With  theFC.AddField
xfield theFC.AddField yfield
Keywords New Field, Add Field
83. Search for the correct object model diagram
(for creating a new field)
9Search for the correct object model diagram (for
creating a new field)
10Review the documentation
11Part Three Navigate the Object Model Diagram
Review the structure of the object model diagram
12 Trace the flow between
classes
Dim xfield As IFieldEditDim yfield As
IFieldEditSet xfield New FieldSet yfield
New Field
Create new x and y fields in attribute table
Definitions
Addfield object.addfield adds field to this
object class
theFC.AddField xfield theFC.AddField yfield
13Subtask 5 Add the position of each point and
save, then repeat as necessary until ending loop
Dim indexX As Long indexX theFC.FindField("XFIEL
D") Dim indexY As Long indexY
theFC.FindField("YFIELD") thefeature.Value(index
X) xcoor 'thefeature.Store thefeature.Value(inde
xY) ycoor thefeature.Store Set thefeature
thefeaturecursor.NextFeature Wend end
while loop
Definitions
Store object.store stores the row FindField
object.FindField the index of the field with
the specified name