3 Replies Latest reply on Sep 6, 2017 7:22 PM by Kim Chatto

    Macro to change Balloon Default Property

    Kim Chatto

      Hi,

      I have a balloon right now that has $PRPMODEL:"PartNo" as default property content.

      I want to change it to $PRPMODEL:"Description".

      I tried recording the steps but it all it records was just selections and none about changing the default property content.

      Right now I'm doing it manually or using the balloon style that I saved.

      I tried searching in API help but I haven't found the API call to do it.

      Does anyone know how to do it in macro?Thanks a lot.

        • Re: Macro to change Balloon Default Property
          Nilesh Patel

          Hi Kim,

           

          Macro recorder doesn't always record all user actions. Try following logic:

           

          1. Select the drawing view and get notes using IView::GetNotes method. It will return array of notes.

          2. Run the loop though the note array and check if the note is a Balloon or not using INote::IsBomBalloon.

          3. If yes, get the linked property text using INote::PropertyLinkedText property. If the string matches to your old liked property then replace it by setting the value to your new property again using INote::PropertyLinkedText.

           

          You will have to do some string manipulations to get the result you want. I haven't tried the codes but I think it should work.

           

          Hope it helps you.

           

          Regards,

          • Re: Macro to change Balloon Default Property
            Deepak Gupta

            With a balloon selected, try these codes

             

            Option Explicit

            Sub main()

                Dim swApp                       As SldWorks.SldWorks

                Dim swModel                     As SldWorks.ModelDoc2

                Dim swSelMgr                    As SldWorks.SelectionMgr

                Dim swNote                      As SldWorks.Note

                Dim swAnn                       As SldWorks.Annotation

                Dim bRet                        As Boolean

               

                Set swApp = Application.SldWorks

                Set swModel = swApp.ActiveDoc

                Set swSelMgr = swModel.SelectionManager

                Set swNote = swSelMgr.GetSelectedObject6(1, -1)

                Set swAnn = swNote.GetAnnotation

                bRet = swNote.SetBomBalloonText(swNote.GetBomBalloonTextStyle(True), "$PRPMODEL:" + Chr(34) + "Description" + Chr(34), swNote.GetBomBalloonTextStyle(False), swNote.GetBomBalloonText(False))

            End Sub