2 Replies Latest reply on Nov 19, 2012 12:45 PM by Rick Remer

    how to get custom property embedded in note annotation

    Rick Remer



      I'm writing some code (in VBA) to check over a drawing and ensure that sheet format text has not been altered.  In particular, I want to check the notes that are linked to drawing custom properties.  I'm currently using SW 2010 sp5.0

      For example, one of our custom properties is "Description", and is set to "Spinner".  A note in the sheet format where this is to appear would actually contain $PRP:"Description" but resolves as "Spinner".


      My code is looping thru all the Annotaion objects (View.GetFirstAnnotation3, Annotation.GetNext3), picking out the Note types (Set Note = Annotation.GetSpecificAnnotation), but when I use Note.GetText, it only returns the resolved text (e.g. "Spinner"), not the actual embedded code.


      I've dug thru all the documentation on the Annotation and Note objects, but there is no mention of how to get the true note text.


      So how is this done?  TIA.

        • Re: how to get custom property embedded in note annotation
          Keith Rice

          Hi Rick,


          INote::PropertyLinkedText should do what you need. Here is some code from our Macro Library that displays the resolved and linked text in all notes in a drawing:



          'Preconditions: drawing is open
          'Postconditions: note text and the custom propery to which the note is linked are _
               displayed in immediate window
          Dim swApp As SldWorks.SldWorks
          Dim swModel As SldWorks.ModelDoc2
          Dim swDraw As SldWorks.DrawingDoc
          Dim swView As SldWorks.View
          Dim swNote As SldWorks.Note
          Sub main()
               Set swApp = Application.SldWorks
               Set swModel = swApp.ActiveDoc
               Set swDraw = swModel
               Set swView = swDraw.GetFirstView
               While Not swView Is Nothing
                   Set swNote = swView.GetFirstNote
                   While Not swNote Is Nothing
                       Debug.Print swNote.GetText
                       Debug.Print swNote.PropertyLinkedText
                       Set swNote = swNote.GetNext
                   Set swView = swView.GetNextView
          End Sub





          Video Tutorials for the SolidWorks API