3 Replies Latest reply on Feb 10, 2015 8:59 PM by Hernan Dario Patino Duque

    How to inserts a symbol into a  note with API.

    Yong Ning

      000.jpg

      Private Sub LL()

        Dim SwApp As SldWorks.SldWorks, SwModel As ModelDoc2, SwDraw As DrawingDoc

          Set SwApp = GetObject(, "SldWorks.Application")

          Set SwModel = SwApp.ActiveDoc

          Set SwDraw = SwModel

        Dim SwSelMgr As SelectionMgr, SwNote As Note

          Set SwSelMgr = SwModel.SelectionManager

          Set SwNote = SwSelMgr.GetSelectedObject2(1)

          Debug.Print SwNote.GetText

      End Sub

        • Re: How to inserts a symbol into a  note with API.
          Jim Sculley

          If you know what symbol you want, you can simply call SetText with the appropriate tag added to the value returned from GetText.

           

          You can determine the tag to use by creating a note that looks the way you want and then right clicking and selecting Edit Text In Window which will show you the tags:

           

          sym.png

          Jim S.

          • Re: How to inserts a symbol into a  note with API.
            Yong Ning

            Private Sub ll()

              Dim SwApp As SldWorks.SldWorks, SwModel As ModelDoc2

                 Set SwApp = Application.SldWorks

                 Set SwModel = SwApp.ActiveDoc

                 SwModel.ClearSelection2 True

              Dim SwSelMgr As SelectionMgr

                 Set SwSelMgr = SwModel.SelectionManager

              Dim SwDraw As DrawingDoc

                 Set SwDraw = SwModel

              Dim SwFeat As Feature, SwView As View

                 Set SwFeat = SwDraw.FeatureByName("浮头管板Dn700右视图")

                 SwFeat.Select True

                 Set SwView = SwSelMgr.GetSelectedObject5(1)

              Dim SwNote As Note, NoteName

              Dim SwAnn As Annotation

                 'Set SwNote = SwDraw.InsertNote("fffff")

                 'Debug.Print SwNote.GetName

                 'SwNote.SetName "aaa"

                 'Debug.Print SwNote.GetName

                 NoteName = "aaa@" & SwView.GetName2

                

                 boolstatus = SwDraw.Extension.SelectByID2(NoteName, "NOTE", 0, 0, 0, False, 0, Nothing, 0)

                 If boolstatus Then

                   Set SwNote = SwSelMgr.GetSelectedObject5(1)

                   Set SwAnn = SwNote.GetAnnotation

                  

                   ss = SwView.GetOutline

                  

                   SwAnn.SetPosition ss(2), ss(3), 0

                 End If

                 Stop

            End Sub