3 Replies Latest reply on Jun 18, 2015 8:24 AM by Yong Ning

    How to get GetAnnotations in Sheet format?

    Yong Ning

      Why  don't find View in xxx.SldDrt file?

       

       

      In Sheet Format, SwDraw.GetFirstView → don't find View → Ss = SwView.GetAnnotations → result is 0

       

       

       

      01.jpg

       

       

       

      Follow code is  swview.GetFirstView

       

      Private Sub ll()

        Dim SwApp As SldWorks.SldWorks, SwModel As ModelDoc2

           Set SwApp = Application.SldWorks

           Set SwModel = SwApp.ActiveDoc

        Dim SwDraw As DrawingDoc, SwView As View

           Set SwDraw = SwModel

           Set SwView = SwDraw.GetFirstView

           Debug.Print SwView.GetName2,

           'Set SwView = SwView.GetNextView

           'Debug.Print SwView.GetName2

        Dim SwAnn As Annotation, Ss, ii

          

           'SwModel.HideShowDimensions

           Debug.Print SwView.GetAnnotationCount

           'Stop

           Ss = SwView.GetAnnotations

           'Stop

           For ii = 0 To UBound(Ss)

              Set SwAnn = Ss(ii)

              SwAnn.Select True

              'Stop

              Debug.Print SwAnn.GetName

              SwAnn.Visible = 1

           Next ii

         

          Dim SwSheet As Sheet

             Set SwSheet = SwDraw.GetCurrentSheet

             Stop

             Ss = SwSheet.CustomPropertyView

            

      End Sub

       

       

       

      00.jpg

        • Re: How to get GetAnnotations in Sheet format?
          Viswanath Rangubhatla

          I can't see any views in the picture you posted above. I believe you need to create a drawing view to run the above code.

            • Re: How to get GetAnnotations in Sheet format?
              Yong Ning

              Thank you replay

               

               

               

              2010 SOLIDWORKS API Help - Get Names of Annotations Example (VBA)

              http://help.solidworks.com/2010/english/api/sldworksapi/get_names_of_annotations_example_vb.htm

               

               

              This example shows how to get the names of all of the annotations in a drawing. This example also shows you how to get an annotation by name and select it in a drawing.

               

              Question

               

              Why have view in sheet?

               

              Why not have view in  the xxx.SldDrt file →How to get annotation?

               

              Set swDrView = swDrawing.GetFirstView → AnnArray = swDrView.GetAnnotations

                • Re: How to get GetAnnotations in Sheet format?
                  Yong Ning

                  Private Sub ll2()

                     Dim SwApp As SldWorks.SldWorks, SwModel As ModelDoc2

                         Set SwApp = Application.SldWorks

                         Set SwModel = SwApp.ActiveDoc

                     Dim SwDraw As DrawingDoc, SwView As View

                         Set SwDraw = SwModel

                         Set SwView = SwDraw.GetFirstView

                       

                     Dim SwAnn As Annotation, swDisplayData As IDisplayData

                   

                   

                         Do While Not SwView Is Nothing

                             Set SwAnn = SwView.GetFirstAnnotation2

                             Do While Not SwAnn Is Nothing

                                If SwAnn.GetType = 4 Then

                                  Debug.Print SwAnn.GetName

                                  Set swDisplayData = SwAnn.GetDisplayData

                                  'Stop

                                  With swDisplayData

                                   

                                  End With

                                  SwAnn.Visible = 1

                                End If

                                Set SwAnn = SwAnn.GetNext2

                              

                             Loop

                           

                             Set SwView = SwView.GetNextView

                         Loop

                   

                   

                  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, SwView As View

                     Dim ii, kk

                         Set SwDraw = SwModel

                         Set SwView = SwDraw.GetFirstView

                       

                     Dim SwAnn() As IAnnotation, SwDispDim As DisplayDimension

                         kk = 0

                   

                   

                         Do While Not SwView Is Nothing

                             Set SwDispDim = SwView.GetFirstDisplayDimension

                             Do While Not SwDispDim Is Nothing

                                ReDim Preserve SwAnn(kk) As IAnnotation

                                Set SwAnn(kk) = SwDispDim.GetAnnotation

                                'SwAnn.Visible = 3

                                kk = kk + 1

                                Set SwDispDim = SwDispDim.GetNext

                             Loop

                             Set SwView = SwView.GetNextView

                         Loop

                         ''

                         For ii = 0 To UBound(SwAnn)

                             Debug.Print SwAnn(ii).GetType, SwAnn(ii).GetName

                             SwAnn(ii).Visible = 3

                         Next ii

                         Stop

                   

                   

                  End Sub

                   

                   

                  ''

                  Private Sub ll4()

                     Dim SwApp As SldWorks.SldWorks, SwModel As ModelDoc2

                         Set SwApp = Application.SldWorks

                         Set SwModel = SwApp.ActiveDoc

                     Dim SwDraw As DrawingDoc, SwView As View

                         Set SwDraw = SwModel

                         Set SwView = SwDraw.GetFirstView

                       

                     Dim SwAnn As Annotation, swDisplayData As IDisplayData

                   

                   

                   

                   

                         Do While Not SwView Is Nothing

                             Set SwAnn = SwView.GetFirstAnnotation2

                             Do While Not SwAnn Is Nothing

                                If SwAnn.GetType = 4 Then

                                  Debug.Print SwAnn.GetName

                                  SwAnn.Visible = 1

                                End If

                                Set SwAnn = SwAnn.GetNext2

                              

                             Loop

                           

                             Set SwView = SwView.GetNextView

                         Loop

                   

                   

                  End Sub