using System; using NXOpen; using NXOpen.UF; using NXOpenUI; using NXOpen.Annotations; using NXOpen.Utilities; using NXOpen.Drawings; class Programm { static Session theSession = null; static UI theUI = null; static UFSession theUFSession = null; static Part workPart = null; public Programm() { try { theSession = Session.GetSession(); theUFSession = UFSession.GetUFSession(); theUI = UI.GetUI(); workPart = theSession.Parts.Work; } catch (Exception ex) { //---- Enter your exception handling code here ----- throw ex; } } public static void Main(string[] args) { Programm pr = null; try { pr = new Programm(); pr.do_it(); } catch (Exception ex) { //---- Enter your exception handling code here ----- theUI.NXMessageBox.Show("Programm", NXMessageBox.DialogType.Warning, ex.Message); } } private void do_it() { Annotation.AssociativeOriginData aod; Point3d origin; int count = 0; View dv = workPart.DrawingSheets.ToArray()[0].View; Tag oTag = Tag.Null; Echo(""); Echo("I. ============================="); foreach(DisplayableObject displayableObj in dv.AskVisibleObjects()) { if(displayableObj is NXOpen.Annotations.NoteBase) { NoteBase nb = (NoteBase)displayableObj; Echo(++count + ". " + nb.GetText()[0]); aod = nb.GetAssociativeOrigin(out origin); if(aod.View != null) Echo("\tAssociated View is " + aod.View.Name); else Echo("\tNot Associated View"); } } Echo(""); Echo("II. ============================="); count = 0; do { theUFSession.View.CycleObjects(dv.Tag, UFView.CycleObjectsEnum.VisibleObjects, ref oTag); TaggedObject taggedObj = NXObjectManager.Get(oTag); if(oTag == Tag.Null) break; if(taggedObj is NXOpen.Annotations.NoteBase) { NoteBase nb = (NoteBase)taggedObj; Echo(++count + ". " + nb.GetText()[0]); aod = nb.GetAssociativeOrigin(out origin); if(aod.View != null) Echo("\tAssociated View is " + aod.View.Name); else Echo("\tNot Associated View"); } } while(true); } static void Echo(string output) { theSession.ListingWindow.Open(); theSession.ListingWindow.WriteLine(output); } public static int GetUnloadOption(string dummy) { return (int)Session.LibraryUnloadOption.Immediately; } }