Accessing current workspace using an ArcObjects add-in for ArcMap

6420
6
07-31-2011 12:02 PM
Highlighted
New Contributor III
I am trying to create a point feature in ArcObjects for an ArcMap add-in in c#. To do this I need to get the feature class. To get the feature class I need to know the current workspace.

How do I find the current workspace opened from ArcMap from within the dockable window c# code?

Any help would be appreciated.

Thanks
Paul
Reply
0 Kudos
6 Replies
Highlighted
Regular Contributor III
Application
MxDocument
FocusMap
Layers - IFeatureLayer
FeatureClass - IFeatureClass
IDataset
Workspace

If you search the samples, I suspect that you will find the code.
Reply
0 Kudos
Highlighted
New Contributor III
Thanks for the quick response Richard.

To help anyone else that is looking, the current workspace can be found via:

   IWorkspace ws = ((IDataset)ArcMap.Document.ActiveView.FocusMap.Layer[0]).Workspace;
Reply
0 Kudos
Highlighted
New Contributor


To help anyone else that is looking, the current workspace can be found via:

   IWorkspace ws = ((IDataset)ArcMap.Document.ActiveView.FocusMap.Layer[0]).Workspace;


Looks good.  Any ideas how to rewrite that for Java?
Reply
0 Kudos
Highlighted
Regular Contributor
Here is a sample for opening a shapefile.  Or did you want to get the workspace from an existing layer in the map?


        IWorkspace workspace;
        IWorkspaceFactory workspacefactory;
        IFeatureWorkspace featureworkspace;

            workspacefactory = new ShapefileWorkspaceFactory();
           
            workspace = workspacefactory.openFromFile(filePath, 0);
           
            featureworkspace = (IFeatureWorkspace) workspace;
Reply
0 Kudos
Highlighted
New Contributor
Here is a sample for opening a shapefile.  Or did you want to get the workspace from an existing layer in the map?


        IWorkspace workspace;
        IWorkspaceFactory workspacefactory;
        IFeatureWorkspace featureworkspace;

            workspacefactory = new ShapefileWorkspaceFactory();
           
            workspace = workspacefactory.openFromFile(filePath, 0);
           
            featureworkspace = (IFeatureWorkspace) workspace;


yes i am very interested with  getting the workspace from an existing layer in the map , could you get it ?
Highlighted
New Contributor II

Was this question ever fully answered, perhaps someplace else? 

Reply
0 Kudos