1 Reply Latest reply on Nov 19, 2015 11:10 AM by Steven Barry

    Delete annotation style

    Chris Manger

      I have a macro that uses the code below to insert a annotation favorite.   Before inserting though, I woudl like to delete the favorite if it exist in the drawing.  I found the Method to do this but I am not sure how to call it correctly.


      Code to insert the annotation favorite:

          Set myAnnotation = swDrawing.Extension
          Set myAnnotation = swDrawing.Extension.InsertAnnotationFavorite(FavoriteNameHere)


      The method to delete the style

      2015 SOLIDWORKS API Help - DeleteStyle Method (IAnnotation)

        • Re: Delete annotation style
          Steven Barry

          The method you are referring to belongs to the Annotation object.  According to the documentation, you need the name of the style to delete (which it sounds like you already have).  Also, this method returns a Boolean value, so you will need to assign some Boolean value to its output.


          In order to use it, it sounds like you will have to loop through all annotations in your document and call this method.  I am not sure if this will keep the note or not, or which is your goal, but you might also want to look at GetStyleName.  This will let you check if the Annotation's style matches the one you want to delete.