ArcObjects Library Reference  (Carto)    

IFDOGraphicsLayer Example

The followng code example shows how to use the DoAddFeature method to insert annotation features into annotation feature class (pTargetFClass) from another annotation feature class (pSrcFClass).

[Visual Basic 6.0]
' set up fields for mapping Dim pOFlds As IFields Dim pIFlds As IFields Set pOFlds = pTargetFClass.Fields Set pIFlds = pSrcFClass.Fields Dim pFld As IField Dim lSrcFlds() As Long Dim lTrgFlds() As Long Dim lFld As Long, lExFld As Long, i As Long, lFld2 As Long lExFld = 0 For lFld = 0 To pIFlds.FieldCount - 1 Set pFld = pIFlds.Field(lFld) If Not pFld.Type = esriFieldTypeOID And Not pFld.Type = esriFieldTypeGeometry And Not UCase(pFld.Name) = "ELEMENT" And _ Not UCase(pFld.Name) = "ANNOTATIONCLASSID" And Not UCase(pFld.Name) = "ZORDER" And _ pFld.Editable Then lExFld = lExFld + 1 End If Next lFld ReDim lSrcFlds(lExFld) As Long ReDim lTrgFlds(lExFld) As Long i = 0 For lFld = 0 To pIFlds.FieldCount - 1 Set pFld = pIFlds.Field(lFld) If Not pFld.Type = esriFieldTypeOID And Not pFld.Type = esriFieldTypeGeometry And Not UCase(pFld.Name) = "ELEMENT" And _ Not UCase(pFld.Name) = "ANNOTATIONCLASSID" And Not UCase(pFld.Name) = "ZORDER" And _ pFld.Editable Then lSrcFlds(i) = lFld lTrgFlds(i) = pOFlds.FindField(pFld.Name) i = i + 1 End If Next lFld Dim pICursor As IFeatureCursor Set pICursor = pSrcFClass.Search(Nothing, True) Dim pIFeat As IFeature Set pIFeat = pICursor.NextFeature Dim pGLF As IFDOGraphicsLayerFactory Set pGLF = New FDOGraphicsLayerFactory Set pDataset = pTargetFClass Dim pFDOGLayer As IFDOGraphicsLayer Set pFDOGLayer = pGLF.OpenGraphicsLayer(pDataset.Workspace, pTargetFClass.FeatureDataset, pDataset.Name) Dim pFDOACon As IFDOAttributeConversion Set pFDOACon = pFDOGLayer pFDOGLayer.BeginAddElements pFDOACon.SetupAttributeConversion2 lExFld, lSrcFlds, lTrgFlds While Not pIFeat Is Nothing Set pAnnoFeature = pIFeat Set pAClone = pAnnoFeature.Annotation Set pGSElement = pAClone.Clone pFDOGLayer.DoAddFeature pIFeat, pGSElement, 0 Set pIFeat = pICursor.NextFeature m_frmProg.ProgressBar1.Value = m_frmProg.ProgressBar1.Value + 1 m_frmProg.lblCurrent = m_frmProg.ProgressBar1.Value m_frmProg.lblCurrent.Refresh Wend pFDOGLayer.EndAddElements

[Visual Basic .NET, C#, C++]
No example is available for Visual Basic .NET, C#, or C++. To view a Visual Basic 6.0 example, click the Language Filter button Language Filter in the upper-left corner of the page.