MariusKolleck

mxd-content to filegeodatabase converter

Discussion created by MariusKolleck on Sep 29, 2010
hi !
I'm using VB.NET to create a programm which opens a *.mxd File, reads the layers, and exports those to a filegeodatabase. I'm new to arcobjects, but i've read a lot and the main function of my program works as far. It reads the mxd, takes all features existing in it and all rasters, and copies them to my fgdb.

but now i'm kind of stuck, and i need some hints to finish it :

-  how can i get the tables in the mxd file ? My program only gets the features and the rasters
             
       
pMapDoc = New MapDocument
        pMapDoc.Open(sMXD)
       
        pMap = pMapDoc.Map(0)
        pLayers = pMap.Layers
        pLayers.Reset()


-   is it posible to read the sql-query which is applied to a layer, so my program only copies the features, which are actualy displayed in my mxd ?



In addition i'll post some code snippets, maybe it helps !

this is how i convert the features:
    Public Sub GeolineTestAuslesen(ByVal str As String)

        Dim paramsl As PropertySet
        Dim TrackCancel As ITrackCancel = Nothing
        Dim pGPMessages As IGPMessages
        Dim aMessage As GPMessage
        Dim g As New GpDispatch

        paramsl = New PropertySet                                         
        paramsl.SetProperty("Input_Features", dgnpath & "\" & str)                      
        paramsl.SetProperty("Output_Geodatabase", preExistingGDB)        
        paramsl.SetProperty("Derived_Geodatabase", preExistingGDB)          
        pGPMessages = g.Execute("FeatureClassToGeodatabase", paramsl, TrackCancel)   

        Console.WriteLine()
        sw.WriteLine("----Feature schreiben----")
        
        For n = 0 To pGPMessages.Count - 1
            aMessage = pGPMessages.Messages.Element(n)
            Console.WriteLine(aMessage.Description)
            sw.WriteLine()
            sw.WriteLine(aMessage.Description)
            sw.WriteLine()
            Console.WriteLine()

        Next
    End Sub



this is how i read in the layers and save them to a generic list :

  
        pMapDoc = New MapDocument
        pMapDoc.Open(sMXD)

        
        pMap = pMapDoc.Map(0)
        pLayers = pMap.Layers
        pLayers.Reset()

        Header()
        
        Dim i As Integer = 0
        pLayer = pLayers.Next
        fcs.Add(pLayer)
        Console.Write("Layer " & i & " : ")
        Console.ForegroundColor = ConsoleColor.Green
        Console.Write(pLayer.Name.ToString)
        Console.ResetColor()
        Console.WriteLine(" eingelesen")
        sw.WriteLine()
        sw.WriteLine("Layer " & i & " : " & pLayer.Name.ToString & " eingelesen")
        i += 1

        Do While Not pLayer Is Nothing

            pLayer = pLayers.Next


            If pLayer Is Nothing Then
            Else
                Console.Write("Layer " & i & " : ")
                Console.ForegroundColor = ConsoleColor.Green
                Console.Write(pLayer.Name.ToString)
                Console.ResetColor()
                Console.WriteLine(" eingelesen")
                sw.WriteLine("Layer " & i & " : " & pLayer.Name.ToString & " eingelesen")
                fcs.Add(pLayer)

            End If

            i = i + 1
        Loop



Maybe someone can help, i really want to get this done, cause im a student and i'm on my internship, and its my challenge to do this :) thank you !

Outcomes