brodreger

Populate geodatabase annotation feature from a shape point layer (VBA)

Discussion created by brodreger on Sep 7, 2010
Latest reply on Sep 8, 2010 by brodreger
Hello.

I have a shape with points and attributes.
I would like to obtain some annotations in an annotation feature class in a file GeoDatabase.

I have difficulties with the IannotateLayerProperties

Public Function CreaAnnoFromPoint()

    'les variables pour utiliser ArcMap
    Dim pMxApp As IMxApplication
    Dim pDoc As IMxDocument
    Dim pMap As IMap

    'les objets ArcMap
    Set pMxApp = Application
    Set pDoc = Application.Document
    Set pMap = pDoc.FocusMap
  
  

    Dim plPoint As IFeatureLayer
    Dim pfPoint As IFeature
    
    Dim plAnno As IFeatureLayer
    Dim pfAnnoClass As IFeatureClass
    Dim pfAnno As IFeature
    
    Dim pCursor As ICursor
     
   
   
    'set the layers
    Set plPoint = pMap.Layer(1)
    Set plAnno = pMap.Layer(0)
        Set pfAnnoClass = plAnno.FeatureClass
    
    
    
    'cursor
    Set pCursor = plPoint.Search(Nothing, False)

    'go to first line
    Set pfPoint = pCursor.NextRow
    
    
    connString = "...\data\my_file_geodb.gdb"
    
    Dim pWorkspace As IWorkspace
    Dim pWorkspaceFactory As IWorkspaceFactory

    Set openFGDBWorkspace = Nothing

    Set pWorkspaceFactory = New FileGDBWorkspaceFactory
    Set pWorkspace = pWorkspaceFactory.OpenFromFile(connString, 0)
    Set openFGDBWorkspace = pWorkspace

    'open edit session
        Dim pEditor As IEditor
        Set pEditor = Application.FindExtensionByName("ESRI Object Editor")
        pEditor.StartEditing pWorkspace
    
    Debug.Print "session open"
    
    
    Dim l As Long
    
    'the loop on the points
    While Not (pfPoint Is Nothing)
        
        
        zSymbolID = 3
        zTextString = pfPoint.Value(8)
        zFontName = pfPoint.Value(9)
        zFontSize = pfPoint.Value(10)
        zAngle = pfPoint.Value(18)
        
        voie_id = pfPoint.Value(25)
        adresse_id = pfPoint.Value(26)
        adresse_numero = pfPoint.Value(27)
        adresse_extension = pfPoint.Value(28)
        adresse_batiment = pfPoint.Value(29)
        adresse_origine = pfPoint.Value(30)
        
        'for test
        Debug.Print adresse_id
        
        
        'create a new record on the annotation feature class
           
           Dim pElement As IElement
           Dim pTextElement As ITextElement
           
           Dim pPoint As esriGeometry.IPoint
           
           Dim pAnnotationFeature As IAnnotateFeature
           Dim pAnnotationProperties As IAnnotateLayerProperties
           
           
           'definition of annotation's propreties
            Set pTextElement = New TextElement
                pTextElement.Text = zTextString
                pTextElement.ScaleText = True
            
            'what else ?
            
           
            
            
        
        l = l + 1
        
        If (l = 10) Then GoTo fin
        'Ligne suivante
        Set pfPoint = pCursor.NextRow
    Wend

    
    
    
    
fin:
    'on ferme la session
    pEditor.StopEditing True
    Debug.Print "session fermée"
    
    Debug.Print "==== FIN ===="


End Function



Thank you for your help.

Outcomes