1 Reply Latest reply on Jan 3, 2014 6:51 PM by Yong Ning

    How to use WidthFactor in TableAnnotation

    Yong Ning

      0.jpg

       

      Sub replSwAnn()

        Dim rr, Str

        Dim SwDraw As DrawingDoc, swDrawExt As SldWorks.ModelDocExtension

        Dim SwSelMgr As SldWorks.SelectionMgr  ''

        Dim swTable As SldWorks.TableAnnotation

        Dim SwAnn As Annotation

        Dim SwTextFormat As TextFormat

       

       

        Set SwDraw = Application.SldWorks.ActiveDoc

        Set swDrawExt = SwDraw.Extension

        Set SwSelMgr = SwDraw.SelectionManager

        ' Select general table feature in FeatureManager design tree

        Set swTable = SwSelMgr.GetSelectedObject6(1, 0)

       

        With swTable

           Set SwAnn = .GetAnnotation

        End With

        ''

        Set SwTextFormat = SwAnn.GetTextFormat(0)'' SwTextFormat Result is Nothing

        With SwTextFormat

           .WidthFactor = 0.9 '→ don't run WidthFactor

        End With

      End Sub

        • Re: How to use WidthFactor in TableAnnotation
          Yong Ning

          Select Note result is True

          2.jpg

           

          Sub tSwAnn()

            Dim rr, Str

            Dim SwDraw As DrawingDoc, swDrawExt As SldWorks.ModelDocExtension

            Dim SwSelMgr As SldWorks.SelectionMgr

            ''

            Dim swTable As SldWorks.TableAnnotation

            Dim SwNote As Note

            Dim SwAnn As Annotation

            Dim SwTextFormat As TextFormat

            ''

            Set SwDraw = Application.SldWorks.ActiveDoc

            Set swDrawExt = SwDraw.Extension

            Set SwSelMgr = SwDraw.SelectionManager

            ' Select general table feature in FeatureManager design tree

            Set SwNote = SwSelMgr.GetSelectedObject6(1, 0)

            Set SwAnn = SwNote.GetAnnotation

            ''

            ''

            Set SwTextFormat = SwAnn.GetTextFormat(0)

           

            Debug.Print SwAnn.GetTextFormatCount

            Stop

            With SwTextFormat

               .WidthFactor = 0.9

            End With

            SwAnn.SetTextFormat 0, False, SwTextFormat

          End Sub

           

          code

            Set SwTextFormat = SwAnn.GetTextFormat(0) → don't Nothing

           

            Debug.Print SwAnn.GetTextFormatCount → result is 1

          3.jpg