VBA - Use data not loaded in ArcMap - Use data directly from source?

771
4
11-19-2010 04:16 AM
ShaunConway
Occasional Contributor II
Good Morning - Thanks in advance for the help.

I'm a novice at VBA and need some help in what may be a simple question.

I have written some code that incorporates an event listener, which when triggered, spatially intersects the newly created point with a polygon layer. The attribution from this polygon layer is then used to populate a corresponding field in the point layer. The use of this tool generated interest from other users. They would now like to run this same process iteratively, collecting attribute values from a series (10+) of polygon layers whenever a new point (address point) is created.

I have expanded the tool to make this possible, however, it requires that the source (polygon) layers be within the map document. Is there a way to do this without having all of the source layers loaded in the map document? Can I call the data directly from the sql db?
0 Kudos
4 Replies
NeilClemmons
Regular Contributor III
Yes, use IWorkspaceFactory to open a workspace (IFeatureWorkspace).  Use IFeatureWorkspace.OpenFeatureClass to open the datasource.
0 Kudos
ShaunConway
Occasional Contributor II
Yes, use IWorkspaceFactory to open a workspace (IFeatureWorkspace).  Use IFeatureWorkspace.OpenFeatureClass to open the datasource.


Thanks for the quick response Neil! I do have a follow up question if you don't mind. What effect might this have on performance? I'm sure its dependent on FC size etc etc. I'm unfamiliar with how the app handles this command in the background - is the performance similar to loading the FC say from the "add data" command?

Thanks Again Neil,
Shaun
0 Kudos
NeilClemmons
Regular Contributor III
The ArcGIS Desktop applications are built using ArcObjects.  The Add Data command uses workspace factories, workspaces, feature classes, etc. when adding data to the map.  Not having the data already in the map will affect performance because more time is needed to make the data connections.  Other than that, it should work pretty much the same.
0 Kudos
ShaunConway
Occasional Contributor II
The ArcGIS Desktop applications are built using ArcObjects.  The Add Data command uses workspace factories, workspaces, feature classes, etc. when adding data to the map.  Not having the data already in the map will affect performance because more time is needed to make the data connections.  Other than that, it should work pretty much the same.


Thanks again Neil - I've got the code changes made and functioning.
0 Kudos