Macro to change Balloon Default Property

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.

SolidworksApi macros
Answers 3
NP
NP 2017-09-05 Best Answer

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,

DG
DG 2017-09-05

With a balloon selected, try these codes

<p>Option Explicit</p><p>Sub main()</p><p>    Dim swApp                       As SldWorks.SldWorks</p><p>    Dim swModel                     As SldWorks.ModelDoc2</p><p>    Dim swSelMgr                    As SldWorks.SelectionMgr</p><p>    Dim swNote                      As SldWorks.Note</p><p>    Dim swAnn                       As SldWorks.Annotation</p><p>    Dim bRet                        As Boolean</p><p>    </p><p>    Set swApp = Application.SldWorks</p><p>    Set swModel = swApp.ActiveDoc</p><p>    Set swSelMgr = swModel.SelectionManager</p><p>    Set swNote = swSelMgr.GetSelectedObject6(1, -1)</p><p>    Set swAnn = swNote.GetAnnotation</p><p>    bRet = swNote.SetBomBalloonText(swNote.GetBomBalloonTextStyle(True), "$PRPMODEL:" + Chr(34) + "Description" + Chr(34), swNote.GetBomBalloonTextStyle(False), swNote.GetBomBalloonText(False))</p><p>End Sub</p>
KC
KC 2017-09-06

It works.

Thanks a lot Deepak.