AnsweredAssumed Answered

Convert GxDialog to Workspace

Question asked by warpengine on Jul 6, 2017
Latest reply on Jul 7, 2017 by warpengine

ArcGIS 10.1 with VB2010

I am using the GxDialog to get the users option to save a feature class. The target can be a shapefile, geodatabase, or Dataset inside a geodatabase.

I can’t wrap my head around how I am supposed to parse the Workspace, FeatureDataset, and FeatureClass name to use in creating the feature class.


So far I have


            'setup the save dialog

            Dim pGxDialog As IGxDialog = New GxDialog

            Dim pGxObjFilterSh As IGxObjectFilter = New GxFilterShapefiles          'shapefiles

            Dim pGxObjFilterPg As IGxObjectFilter = New GxFilterPGDBFeatureClasses  'personal geodb (Access db)

            'Dim pGxObjFilterFg As IGxObjectFilter = New GxFilterFGDBFeatureClasses  'file geodb (ESRI db)

            Dim pGxObjectFilterCollection As IGxObjectFilterCollection = CType(pGxDialog, IGxObjectFilterCollection)

            pGxObjectFilterCollection.AddFilter(pGxObjFilterSh, True)

            pGxObjectFilterCollection.AddFilter(pGxObjFilterPg, False) 'this one actually contains both file and personal geodb feature classes

            'pGxObjectFilterCollection.AddFilter(pGxObjFilterFg, False)


            'get the users selection (it can be a shapefile or a geodb). Catalog paths consist of two parts: the workspace and the base name.

            If pGxDialog.DoModalSave(MyApp.hWnd) Then

                Dim catalogPath As String = My.Computer.FileSystem.CombinePath(pGxDialog.FinalLocation.FullName, pGxDialog.Name)

                Dim workspaceCategory As String = pGxDialog.FinalLocation.Category

                Debug.Print(String.Format("catalogPath={0}, workspaceCategory={1}", catalogPath, workspaceCategory))

                Debug.Print("ClassID={0}", pGxDialog.FinalLocation.ClassID)


                'I can use the workspaceCategory to get the target type. But how do I split out either the entire string path or

                'the pGxDialog to create a Workspace object. How do I set up the objects to allow a Feature Dataset?

          Select Case workspaceCategory

              Case "Personal Geodatabase", "Personal Geodatabase Feature Dataset"

                  'personal geodb (Access database C:\myData\mypGDB.mdb)

                  wkspFactory = New AccessWorkspaceFactory

                  pCLSID.Value = "esriGeodatabase.Feature"

              Case "File Geodatabase", "File Geodatabase Feature Dataset"

                  'file geodb (File database C:\myData\myfGDB.gdb)

                  wkspFactory = New FileGDBWorkspaceFactory

                  pCLSID.Value = "esriGeodatabase.Feature"

              Case "Folder"

                  'shapefile (c:\mydata\)

                  wkspFactory = New ShapefileWorkspaceFactory

                  pCLSID.Value = "esriCore.Feature"

              Case Else

                  Throw New Exception("Unsupported workspace category: " & workspaceCategory)

          End Select

            End If