6 Replies Latest reply on Mar 4, 2016 3:42 AM by Divyanshu Bhardwaj

    Create userform for inserting notes into drawing sheet

    Divyanshu Bhardwaj

      Hi Everybody,

                     I have never created userform before in solidworks. But need to create one this time, where i want to put all the standard notes along with their description, check boxes and options to select flag.

      1. Suppose there are 15 notes, out of which any number of notes can be placed in sheet.

      2. Check Boxes need to be placed in front of the Note names, once checked only those notes will be inserted.

      3. Flag (Kind of option box), once checked need to insert a triangular flag over a corresponding number of a note.

      And some buttons like continue/ cancel etc.

       

                     Now, the coding part i can do, but i don't know how to create and associate those controls to the specific codes. Please Suggest a way to proceed. Thank you

          • Re: Create userform for inserting notes into drawing sheet
            Divyanshu Bhardwaj

            Hi Deepak,

                      Thanks for quick reply and working link. But here i am having little problem with the second check-box. As shown below i want something

            like this. There will be 14 more notes (similar to as shown here only one line). But i am having difficulty in associating both the check boxes. The first one inserts a note. While if checked, the second one adds a triangular box over the number. How to make this possible.

            adsfasf.JPG

            The code i wrote for this is....

            Dim swApp As SldWorks.SldWorks

            Private Sub Continue_Click()

                Call SL1_Click

            End Sub

            Private Sub Note1_Click()

                If Note1.Value = True Then

                    Set swApp = Application.SldWorks

                    Dim swModel As SldWorks.ModelDoc2

                    Set swModel = swApp.ActiveDoc

                    Dim swNote As SldWorks.Note

                    Set swNote = swModel.InsertNote("Part Number Marking Per Find Number SPCX, PROCEDURE X, (But Do Not Serialize).")

                    If Not swNote Is Nothing Then

                       swNote.LockPosition = False

                       swNote.Angle = 0

                       boolstatus = swNote.SetBalloon(9, 0)

                       Set myAnnotation = swNote.GetAnnotation()

                       If Not myAnnotation Is Nothing Then

                          longstatus = myAnnotation.SetLeader3(swLeaderStyle_e.swNO_LEADER, 0, True, False, False, False)

                          boolstatus = myAnnotation.SetPosition(0, 0, 0)

                  

                          Set myTextFormat = swModel.GetUserPreferenceTextFormat(0)

                          myTextFormat.Italic = False

                          myTextFormat.Underline = False

                          myTextFormat.Strikeout = False

                          myTextFormat.Bold = False

                          myTextFormat.Escapement = 0

                          myTextFormat.LineSpacing = 0.001

                          myTextFormat.CharHeight = 0.003175

                          myTextFormat.TypeFaceName = "Century Gothic"

                          myTextFormat.WidthFactor = 1

                          myTextFormat.ObliqueAngle = 0

                          myTextFormat.LineLength = 0

                          myTextFormat.Vertical = False

                          myTextFormat.BackWards = False

                          myTextFormat.UpsideDown = False

                          myTextFormat.CharSpacingFactor = 1

                          boolstatus = myAnnotation.SetTextFormat(0, False, myTextFormat)

                       End If

                    End If

                End If

            Unload Me

            Exit Sub

            swModel.ClearSelection2 True

            swModel.WindowRedraw

            End Sub

             

            Private Sub SL1_Click()

                Set swApp = Application.SldWorks

                Dim swModel As SldWorks.ModelDoc2

                Set swModel = swApp.ActiveDoc

                If SL1.Value = True Then

                    Dim swNote As SldWorks.Note

                    Set swNote = swModel.InsertNote("Part Number Marking Per Find Number SPCX, PROCEDURE X, (But Do Not Serialize).")

                    Call Note1_Click

                ElseIf SL1.Value = False Then

                    MsgBox "Nothing Checked!!! Exiting Sub..."

                    Exit Sub

                End If

                Unload Me

            End Sub

             

            Note: SL1 is the name for first checkbox while Note1 the second.