We have non feature linked water annotation and water mains with feature linked annotation.In order to transfer existing anno to feature linked annotation the user selects an existing annotation feature and a water main.The program then creates a new feature linked annotation feature where the selected non-feature linked annotation is placed. The program also assigns the Water Main OID of the selected water main to the feature linked annotation LinkedFeatureID. The feature linked annotation is forced to update by setting a field in the water main. In our case, we just updated the Owner field to its current value and then the feature linked annotation is forced to update.Finally the program deletes the non-feature linked annotation.Attached is the code that does the items described above. public static IFeatureClass FCmain_anno; - set to feature linked annotation feature class
public static IFeatureClass FCmain; - set to water main feature class
public static IFeatureSelection FMainSel; set to selected water main
public static ISelectionSet MainSelSet;
public static ISelectionSet Anno_SelSet;
public static IFeatureCursor FCur_main;
public static IFeatureCursor FCur_anno;
public static IFeature FMain;
public static IFeature F_anno;
public static IAnnotationFeature2 Anno_Feat;
FCmain_anno = FLmain_anno.FeatureClass;
FCmain = FLmain.FeatureClass;
//get main feature
IQueryFilter QF = null;
FMainSel = (IFeatureSelection)FLmain;
MainSelSet = FMainSel.SelectionSet;
MainSelSet.Search(QF, false, out Cur_Main);
FCur_main = (IFeatureCursor)Cur_Main;
FMain = FCur_main.NextFeature();
//get existing anno feature
F_annoSel = (IFeatureSelection)FL_anno;
Anno_SelSet = F_annoSel.SelectionSet;
Anno_SelSet.Search(QF, false, out Cur_anno);
FCur_anno = (IFeatureCursor)Cur_anno;
F_anno = FCur_anno.NextFeature();
Anno_Feat = (IAnnotationFeature2)F_anno;
//create new main anno feature
IFeature wmannoFeature = FCmain_anno.CreateFeature();
IAnnotationFeature2 FLannoFeat = (IAnnotationFeature2)wmannoFeature;
FLannoFeat.Annotation = Anno_Feat.Annotation;
UID edUID = new UIDClass();
edUID.Value = "{F8842F20-BB23-11D0-802B-0000F8037368}";
IEditor editor = (IEditor)m_application.FindExtensionByCLSID(edUID);
IEditLayers EditLayers = (IEditLayers)editor;
EditLayers.SetCurrentLayer(FLmain_anno, 0);
//assign OID to feature linked anno
int OIDFieldvalue = FMain.OID;
FLannoFeat.LinkedFeatureID = OIDFieldvalue;
//assign AnnoClassID
int annoclassid = 0;
FLannoFeat.AnnotationClassID = annoclassid;
//store feature
editor.StartOperation();
wmannoFeature.Store();
editor.StopOperation("Done");
////Get new feature linked anno feature and set symbolID
IQueryFilter pQF = new QueryFilterClass();
pQF.WhereClause = "FeatureID = " + OIDFieldvalue;
IFeatureCursor FLannoCursor = FCmain_anno.Update(pQF, false);
long symbolid = 0;
wmannoFeature = FLannoCursor.NextFeature();
wmannoFeature.set_Value((FCmain_anno.FindField("SymbolId")), symbolid);
editor.StartOperation();
FLannoCursor.UpdateFeature(wmannoFeature);
wmannoFeature.Store();
editor.StopOperation("IDs updated");
IQueryFilter mQF = new QueryFilterClass();
mQF.WhereClause = "OBJECTID = " + OIDFieldvalue;
IFeatureCursor mFCursor = FCmain.Update(mQF, false);
IFeature mF = mFCursor.NextFeature();
mF.set_Value(FCmain.FindField("Owner"), mF.get_Value(FCmain.FindField("Owner")));
editor.StartOperation();
mFCursor.UpdateFeature(mF);
editor.StopOperation("Main Updated");
//delete original anno
F_anno.Delete();
pMap.ClearSelection();
mxDoc.ActiveView.Refresh();
I hadn't look at this code for a while so I had to step through the code to jog my fading memory. I hope this makes sample makes some sense.Mele