2 Replies Latest reply on Sep 4, 2015 10:01 AM by Yong Ning

    Balloon Settings→Item Number

    Yong Ning

      Manual modification of part number, Item Number 3-1

      0.jpg

       

      But use code don't  modification Item Number

       

      Private Sub ll1()

         Dim SwApp As SldWorks.SldWorks, SwModel As ModelDoc2

            Set SwApp = Application.SldWorks

            Set SwModel = SwApp.ActiveDoc

         Dim SwSelMgr As SelectionMgr, Str

            Set SwSelMgr = SwModel.SelectionManager

         Dim SwNote As Note

            Set SwNote = SwSelMgr.GetSelectedObject5(1)

            Debug.Print SwNote.GetName, SwNote.GetText

            'SwModel.EditBalloonProperties swBS_Underline, swBF_Tightest, swDetailingNoteTextCustom, "3-" & SwNote.GetText, swDetailingNoteTextItemNumber, "1"

            Str = "3-" & SwNote.GetText

            'SwModel.EditBalloonProperties swBS_Underline, swBF_Tightest, 0, Str, swDetailingNoteTextItemNumber, "1"

            SwModel.EditBalloonProperties swBS_FlagTriangle, swBF_Tightest, swDetailingNoteTextQuantity, Str, swDetailingNoteTextItemNumber, "1"

            SwModel.EditBalloonProperties swBS_Underline, swBF_Tightest, swDetailingNoteTextItemNumber, "", swDetailingNoteTextItemNumber, "1"

           'SwModel.EditBalloonProperties 10, 0, 0, "3-2", 2, "1"

      End Sub

        • Re: Balloon Settings→Item Number
          Bruce Perry

          I wrote this earlier and it was part of a larger program.

          I needed a more individual use; so I extracted it out to make a stand alone version.

          Maybe some of this will help. P.S. Using 2011 so you might need to modify?

           

          Dim swApp As Object

           

          Dim Part As Object

          Dim boolStatus As Boolean

          Dim longstatus As Long, longwarnings As Long

           

          Sub SetBalloonProperties()

          Dim myTextFormat As Object

          Set swApp = Application.SldWorks

          Set Part = swApp.ActiveDoc

          If Part Is Nothing Then

                  MsgBox "Sorry! Needs an Active File to Function." & vbCrLf & _

                         "Please open a drawing, and try again."

              End

              End If

             

          If Part.GetType <> swDocDRAWING Then 'Is document a Drawing?

                  MsgBox "Sorry! Needs an Active Drawing to Function." & vbCrLf & _

                         "Please open a drawing, and try again."

              End

              End If

           

              boolStatus = Part.SetUserPreferenceToggle(swUserPreferenceToggle_e.swDisplayOrigins, False) 'Hide Origin

              Part.ClearSelection2 True

             

          'Set Balloon Leader

          boolStatus = Part.Extension.SetUserPreferenceInteger(swUserPreferenceIntegerValue_e.swDetailingBalloonLeaderStyle, 0, swLeaderStyle_e.swBENT)

          'Set single Balloon Charaters

          boolStatus = Part.Extension.SetUserPreferenceInteger(swUserPreferenceIntegerValue_e.swDetailingBOMBalloonFit, 0, swBalloonFit_e.swBF_3Chars)

          'Set Balloon Font

          Set myTextFormat = Part.Extension.GetUserPreferenceTextFormat(swUserPreferenceTextFormat_e.swDetailingBalloonTextFormat, 0)

          myTextFormat.CharHeightInPts = 18

          boolStatus = Part.Extension.SetUserPreferenceTextFormat(swUserPreferenceTextFormat_e.swDetailingBalloonTextFormat, 0, myTextFormat)

           

          End Sub

          • Re: Balloon Settings→Item Number
            Yong Ning

            ! ! ! !How to get like property of Note | SOLIDWORKS Forums

            https://forum.solidworks.com/message/504333#504333

            Sub main()

                Dim swApp                       As SldWorks.SldWorks

                Dim swModel                     As SldWorks.ModelDoc

                Dim swSelMgr                    As SldWorks.SelectionMgr

                Dim swNote                      As SldWorks.Note

                Dim swAnn                       As SldWorks.Annotation

                Dim vAttEntArr                  As Variant

                Dim vAttEntTypeArr              As Variant

                Dim swEnt                       As SldWorks.Entity

                Dim swComp                      As SldWorks.Component

                Dim swCompModel                 As SldWorks.ModelDoc

                Dim i                           As Long

                Dim bRet                        As Boolean

             

                Set swApp = Application.SldWorks

                Set swModel = swApp.ActiveDoc

                Set swSelMgr = swModel.SelectionManager

                Set swNote = swSelMgr.GetSelectedObject5(1)

                Set swAnn = swNote.GetAnnotation

             

                Debug.Assert swNote.IsBomBalloon

             

                vAttEntArr = swAnn.GetAttachedEntities2: If IsEmpty(vAttEntArr) Then Exit Sub

                vAttEntTypeArr = swAnn.GetAttachedEntityTypes

                Debug.Assert UBound(vAttEntArr) = UBound(vAttEntTypeArr)

             

                Debug.Print "File = " & swModel.GetPathName

                Debug.Print "  Name                 = " & swAnn.GetName

                Debug.Print "    Upper text         = " & swNote.GetBomBalloonText(True) & " [" & swNote.GetBomBalloonTextStyle(True) & "]"

                Debug.Print "    Lower text         = " & swNote.GetBomBalloonText(False) & " [" & swNote.GetBomBalloonTextStyle(False) & "]"

                Debug.Print "    Balloon fit        = " & swNote.GetBalloonSize

                Debug.Print "    Balloon style      = " & swNote.GetBalloonStyle

                Debug.Print "    Is stacked          = " & swNote.IsStackedBalloon

                Debug.Print "    Is stacked master    = " & swNote.IsStackedBalloonMaster

             

                For i = 0 To UBound(vAttEntArr)

                    Debug.Print "    AttEntType         = " & vAttEntTypeArr(i)

                

                    If swSelNOTHING <> vAttEntTypeArr(i) Then

                        Set swEnt = vAttEntArr(i)

                        Set swComp = swEnt.GetComponent

                        Set swCompModel = swComp.GetModelDoc

                            

                        Debug.Print "    AttEnt             = " & swComp.GetPathName & " <" & swComp.ReferencedConfiguration & ">" & " --> " & swCompModel.GetPathName

                    End If

                Next i

            End Sub

            '---------------------------------------------------

             

             

            Private Sub ll3()

               Dim SwApp As SldWorks.SldWorks, SwModel As ModelDoc2

                  Set SwApp = Application.SldWorks

                  Set SwModel = SwApp.ActiveDoc

               Dim SwDraw As DrawingDoc

                  Set SwDraw = SwModel

               Dim SwSelMgr As SelectionMgr

                  Set SwSelMgr = SwModel.SelectionManager

               Dim SwFeat As Feature, SwBomFeat As BomFeature

                  Set SwBomFeat = SwSelMgr.GetSelectedObject5(1)

                  Set SwFeat = SwBomFeat.GetFeature

               Dim SwView As View

                  Set SwView = SwDraw.GetFirstView

                  Set SwView = SwView.GetNextView

                  SwFeat.Name = SwView.GetName2 & "BOM"

                  ''

               Dim SwBomTabAnn As BomTableAnnotation

                 Set SwBomTabAnn = SwBomFeat.GetTableAnnotations(0)

                 Ss = SwBomTabAnn.GetAllCustomProperties   

                 Ss1 = SwBomTabAnn.GetColumnCustomProperty(1)   

                 For jj = 0 To 9

                    Debug.Print SwBomTabAnn.GetColumnCustomProperty(jj)

                 Next jj

               

            End Sub