7 Replies Latest reply on Sep 28, 2017 1:01 AM by Krzysztof W.

    Trying to get sketch lines and text numbers at a certain distance with a given excel table.

    Ivan Chan

      Hello, I'm trying to design a measuring part, but am having trouble thinking of a way, to get my sketch line and the sketch number text to be at a certain height with a given excel tables without having to manually to input the numbers. I have been using the table driven pattern feature to get my extrude cuts at certain distances. But i would like to use make it easier, where i can use the given excel table to get the lines and sketch number text to work together and make the number go in sequence as it goes up along the part.

       

      below is a sample of what im trying to do.

        • Re: Trying to get lines and Numbers at a certain height with excel table.
          Ivan Chan

          Here is a sample of the finish design. Hopefully this will give you a good enough idea, of what i would like to achieve.

          my feature manager tree of the measuring stick

          • Re: Trying to get sketch lines and text numbers at a certain distance with a given excel table.
            Elmar Klammer

            Try this, however I couldn't get the text to constrain to the line.

             

            Dim swApp As SldWorks.SldWorks
            Dim Part As SldWorks.ModelDoc2
            Dim Linie() As SldWorks.SketchLine
            Dim nText As SldWorks.SketchText
            Dim swSelData As SldWorks.selectdata
            Dim boolstatus As Boolean
            Dim swSelMgr As SldWorks.SelectionMgr
            Dim swSketchMgr As SldWorks.SketchManager
            Dim swsketchseg As SldWorks.SketchSegment
            Dim selectdata As SldWorks.selectdata
            Dim SketchLineID As Variant
            Dim linename, no As String
            Sub Skala()
                Dim i As Integer
                Dim Max As Integer
                Max = 10
                Set swApp = Application.SldWorks
                Set Part = swApp.ActiveDoc
                Set swext = Part.Extension
                Set swSelMgr = Part.SelectionManager
                Set swSketchMgr = Part.SketchManager
               
               
                If Part.IGetActiveSketch2 Is Nothing Then
                MsgBox "You must be in sketch edit mode for this macro to work!" & Chr(13) & Chr(13) & "Edit a sketch a then try again."
                Exit Sub
            End If

              
            '    swSketchMgr.InsertSketch (True)
                Part.ClearSelection2 (True)
               
                ReDim Linie(Max)
                For i = 1 To Max
                    X1Pos = (280 - i * 10) / 1000
                    X2Pos = (270 - i * 10) / 1000
                    Y1Pos = (80) / 1000
                    Y2Pos = (80) / 1000
                    Set Linie(i) = Part.CreateLine2(X1Pos, Y1Pos, 0, X2Pos, Y2Pos, 0)
                    Linie(i).ConstructionGeometry = True
                    Set swsketchseg = swSelMgr.GetSelectedObject6(1, -1)

            '       Stop
                  
                    Set swSelData = swSelMgr.CreateSelectData
                    Part.ClearSelection2 (True)
                   

                    boolstatus = Linie(i).Select4(False, swSelData)

                     no = CStr(i)
                    Set nText = Part.InsertSketchText((X1Pos + X2Pos) / 2, Y1Pos, 0, no, 0, 0, 0, 100, 100)
                   
                    
                Next i
                For i = 1 To Max
                    If i = 1 Then boolstatus = False Else boolstatus = True
                    boolstatus = Linie(i).Select4(boolstatus, swSelData)
                Next i
                Part.SketchAddConstraints "sgSAMELENGTH"
                swSketchMgr.InsertSketch (True)
            End Sub