1 Reply Latest reply on Mar 30, 2017 8:02 PM by テ ソ ン キ ム

    Can get Annotation which in Block with API?

    テ ソ ン キ ム

      Hi all.

       

      I have a program to get All Annotations's text in draw.

       

      This is sample(Skip part of source)

      -----

      SldWorks swApp;

      ModelDoc2 swModel;

      DrawingDoc swDrawing;

      View swView;

      Annotation swAnn;

      DisplayData swDispData;

       

      swModel = (ModelDoc2)swApp.OpenDoc6(DrawPath, (int)swDocumentTypes_e.swDocDRAWING, (int)swOpenDocOptions_e.swOpenDocOptions_Silent, "", ref errors, ref warnings);

      swDrawing = (DrawingDoc)swModel;

      swView = swDrawing.GetFirstView();

      while (swView != null)

      {

               swAnn = swView.GetFirstAnnotation3();

               int AnnoCnt = swView.GetAnnotationCount();

               while (swAnn != null)

               {

                        swDispData = swAnn.GetDisplayData();

                        displayText = displayText + swDispData.GetTextAtIndex(a);

                        swAnn = swAnn.GetNext3();

               }

               swView = swView.GetNextView();

      }

       

      And this is My problem

       

      Green Area : Can get Annotations.

      Red Area : Block areas, I want to get text from note in this area.

      White Box : just for security.

       

      How can i get that notes.

       

      Sorry can't explain detail in English.

      But if you know about this or you need more information, comment to me.

       

      Thank you.

        • Re: Can get Annotation which in Block with API?
          テ ソ ン キ ム

          It was can by using SketchManager and SketchBlockDefinition Class.

           

          SketchManager swSketch = swModel.SketchManager;

          var blocks = swSketch.GetSketchBlockDefinitions();

          for (int z = 0; z < blocks.Length; z++)

          {

                   SketchBlockDefinition block = blocks[z];

                   var swNotes = block.GetNotes();

                   for (int x = 0; x < swNotes.Length; x++)

                   {

                        

                   }

          }

           

          But, the note which got from block have weird position. So I still have a problem.