' anno2shp.ave ' Converts currently active annotation theme into a point shapefile with ' text attributes '**** get active theme theTitle = "Anno to Shape" theView = av.GetActiveDoc ThemeList = theView.GetActiveThemes if (ThemeList.Count = 0) then MsgBox.Info("No Active Theme",theTitle) exit end theTheme = ThemeList.Get(0) if (theTheme.Is(FTheme).Not) then MsgBox.Info("Active Theme is not an FTheme",theTitle) exit end theFTab = theTheme.GetFTab aRecord = theFTab.ReturnValue(theFTab.FindField("shape"),0) if (aRecord.Is(Annotation).Not) then MsgBox.Info("Active Theme is not an Annotation Theme",theTitle) exit end '**** get output file out_name = FileName.GetCWD.MakeTmp("Theme","shp") out_name = FileDialog.Put(out_name, "*.shp", "Output Shapefile") if (out_name = nil) then exit end '**** create shapefile and fields Pshape = FTab.MakeNew(out_name, Point) fields = List.Make fields.Add(Field.Make("text",#FIELD_CHAR,254,0)) fields.Add(Field.Make("angle",#FIELD_FLOAT,8,1)) fields.Add(Field.Make("level",#FIELD_LONG,11,0)) fields.Add(Field.Make("height",#FIELD_FLOAT,13,6)) fields.Add(Field.Make("symbol",#FIELD_LONG,11,0)) Pshape.AddFields(fields) '**** process features i = 0 numrec = theFTab.GetNumRecords av.ShowMsg("Converting Annotation...") for each r in theFTab theAnno = theFTab.ReturnValue(theFTab.FindField("shape"),r) '**** get point and attributes blist = theAnno.GetBaseline.AsList.Get(0) thePoint = blist.Get(0) endPoint = blist.Get(blist.Count - 1) dx = endPoint.GetX - thePoint.GetX dy = endPoint.GetY - thePoint.GetY d = ((dx * dx) + (dy * dy)).Sqrt theAngle = (dx / d).Acos.AsDegrees if (dy < 0) then theAngle = -theAngle end theText = theAnno.GetText theLevel = theAnno.GetLevel theHeight = theAnno.GetHeight theSymbol = theAnno.GetSymbol '**** create shape entry recno = Pshape.AddRecord Pshape.SetValue(Pshape.FindField("shape"),recno,thePoint) Pshape.SetValue(Pshape.FindField("text"),recno,theText) Pshape.SetValue(Pshape.FindField("angle"),recno,theAngle) Pshape.SetValue(Pshape.FindField("level"),recno,theLevel) Pshape.SetValue(Pshape.FindField("height"),recno,theHeight) Pshape.SetValue(Pshape.FindField("symbol"),recno,theSymbol) i = i + 1 av.SetStatus(100*i/numrec) end av.ClearMsg av.ClearStatus '**** ask if add to View theView = av.GetActiveDoc if (MsgBox.YesNo("Add shapefile as theme to the view?",theTitle,true)) then fthm = FTheme.Make(PShape) theView.AddTheme(fthm) theView.GetWin.Activate end